-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nexus] add sled provision state (#4520)
Add the notion of a sled provision state to Nexus. Currently, we will only use this to prevent new resources and regions from being provisioned to sleds. This PR includes: 1. Database updates and schema migrations. 2. Database APIs in `nexus-db-queries`. 3. An HTTP API. 4. Tests for resource and region allocation.
- Loading branch information
1 parent
0a6966c
commit 67cd482
Showing
23 changed files
with
607 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
use super::impl_enum_type; | ||
use nexus_types::external_api::views; | ||
use serde::{Deserialize, Serialize}; | ||
use thiserror::Error; | ||
|
||
impl_enum_type!( | ||
#[derive(Clone, SqlType, Debug, QueryId)] | ||
#[diesel(postgres_type(name = "sled_provision_state"))] | ||
pub struct SledProvisionStateEnum; | ||
|
||
#[derive(Clone, Copy, Debug, AsExpression, FromSqlRow, Serialize, Deserialize, PartialEq)] | ||
#[diesel(sql_type = SledProvisionStateEnum)] | ||
pub enum SledProvisionState; | ||
|
||
// Enum values | ||
Provisionable => b"provisionable" | ||
NonProvisionable => b"non_provisionable" | ||
); | ||
|
||
impl From<SledProvisionState> for views::SledProvisionState { | ||
fn from(state: SledProvisionState) -> Self { | ||
match state { | ||
SledProvisionState::Provisionable => { | ||
views::SledProvisionState::Provisionable | ||
} | ||
SledProvisionState::NonProvisionable => { | ||
views::SledProvisionState::NonProvisionable | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<views::SledProvisionState> for SledProvisionState { | ||
type Error = UnknownSledProvisionState; | ||
|
||
fn try_from(state: views::SledProvisionState) -> Result<Self, Self::Error> { | ||
match state { | ||
views::SledProvisionState::Provisionable => { | ||
Ok(SledProvisionState::Provisionable) | ||
} | ||
views::SledProvisionState::NonProvisionable => { | ||
Ok(SledProvisionState::NonProvisionable) | ||
} | ||
views::SledProvisionState::Unknown => { | ||
Err(UnknownSledProvisionState) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// An unknown [`views::SledProvisionState`] was encountered. | ||
#[derive(Clone, Debug, Error)] | ||
#[error("Unknown SledProvisionState")] | ||
pub struct UnknownSledProvisionState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.