Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nexus] remove views::SledProvisionState::Unknown #4608

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions nexus/db-model/src/sled_provision_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,14 @@ impl From<SledProvisionState> for views::SledProvisionState {
}
}

impl TryFrom<views::SledProvisionState> for SledProvisionState {
type Error = UnknownSledProvisionState;

fn try_from(state: views::SledProvisionState) -> Result<Self, Self::Error> {
impl From<views::SledProvisionState> for SledProvisionState {
fn from(state: views::SledProvisionState) -> Self {
match state {
views::SledProvisionState::Provisionable => {
Ok(SledProvisionState::Provisionable)
SledProvisionState::Provisionable
}
views::SledProvisionState::NonProvisionable => {
Ok(SledProvisionState::NonProvisionable)
}
views::SledProvisionState::Unknown => {
Err(UnknownSledProvisionState)
SledProvisionState::NonProvisionable
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4504,10 +4504,7 @@ async fn sled_set_provision_state(

let opctx = crate::context::op_context_for_external_api(&rqctx).await?;
// Convert the external `SledProvisionState` into our internal data model.
let new_state =
db::model::SledProvisionState::try_from(provision_state).map_err(
|error| HttpError::for_bad_request(None, format!("{error}")),
)?;
let new_state = db::model::SledProvisionState::from(provision_state);

let sled_lookup = nexus.sled_lookup(&opctx, &path.sled_id)?;

Expand Down
1 change: 0 additions & 1 deletion nexus/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ parse-display.workspace = true
schemars = { workspace = true, features = ["chrono", "uuid1"] }
serde.workspace = true
serde_json.workspace = true
serde_with.workspace = true
steno.workspace = true
strum.workspace = true
uuid.workspace = true
Expand Down
7 changes: 0 additions & 7 deletions nexus/types/src/external_api/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use omicron_common::api::external::{
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::rust::deserialize_ignore_any;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::net::IpAddr;
Expand Down Expand Up @@ -311,12 +310,6 @@ pub enum SledProvisionState {
/// resources will continue to be on this sled unless manually migrated
/// off.
NonProvisionable,

/// This is a state that isn't known yet.
///
/// This is defined to avoid API breakage.
#[serde(other, deserialize_with = "deserialize_ignore_any")]
Unknown,
}

/// An operator's view of an instance running on a given sled
Expand Down
7 changes: 0 additions & 7 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -13192,13 +13192,6 @@
"enum": [
"non_provisionable"
]
},
{
"description": "This is a state that isn't known yet.\n\nThis is defined to avoid API breakage.",
"type": "string",
"enum": [
"unknown"
]
}
]
},
Expand Down
Loading