diff --git a/dev-tools/omdb/src/bin/omdb/mgs.rs b/dev-tools/omdb/src/bin/omdb/mgs.rs index 681b3d7b3f2..65d35e9236a 100644 --- a/dev-tools/omdb/src/bin/omdb/mgs.rs +++ b/dev-tools/omdb/src/bin/omdb/mgs.rs @@ -195,7 +195,7 @@ fn show_sp_ids(sp_ids: &[SpIdentifier]) -> Result<(), anyhow::Error> { struct SpIdRow { #[tabled(rename = "TYPE")] type_: &'static str, - slot: u32, + slot: u16, } impl From<&SpIdentifier> for SpIdRow { @@ -221,7 +221,7 @@ fn show_sps_from_ignition( struct IgnitionRow { #[tabled(rename = "TYPE")] type_: &'static str, - slot: u32, + slot: u16, system_type: String, } @@ -269,7 +269,7 @@ fn show_sp_states( struct SpStateRow<'a> { #[tabled(rename = "TYPE")] type_: &'static str, - slot: u32, + slot: u16, model: String, serial: String, rev: u32, diff --git a/dev-tools/omdb/src/bin/omdb/mgs/sensors.rs b/dev-tools/omdb/src/bin/omdb/mgs/sensors.rs index d008b6f7e91..ef77fd21b8a 100644 --- a/dev-tools/omdb/src/bin/omdb/mgs/sensors.rs +++ b/dev-tools/omdb/src/bin/omdb/mgs/sensors.rs @@ -26,7 +26,7 @@ pub(crate) struct SensorsArgs { /// restrict to specified sled(s) #[clap(long, use_value_delimiter = true)] - pub sled: Vec, + pub sled: Vec, /// exclude sleds rather than include them #[clap(long, short)] @@ -256,7 +256,7 @@ struct SpInfo { async fn sp_info( mgs_client: gateway_client::Client, type_: SpType, - slot: u32, + slot: u16, ) -> Result { let mut devices = MultiMap::new(); let mut timestamps = vec![]; @@ -429,7 +429,7 @@ fn sp_info_csv( } }; - let slot = parts[1].parse::().or_else(|_| { + let slot = parts[1].parse::().or_else(|_| { bail!("invalid slot in \"{field}\""); })?; diff --git a/dev-tools/reconfigurator-sp-updater/src/main.rs b/dev-tools/reconfigurator-sp-updater/src/main.rs index f0712d3deb5..4f13caad1e2 100644 --- a/dev-tools/reconfigurator-sp-updater/src/main.rs +++ b/dev-tools/reconfigurator-sp-updater/src/main.rs @@ -213,13 +213,10 @@ impl Inventory { }), ) .then(async move |sp_id| { - let sp_slot = u16::try_from(sp_id.slot).with_context(|| { - format!("sp slot number is out of range: {sp_id:?}") - })?; c.sp_get(sp_id.type_, sp_id.slot) .await .with_context(|| format!("fetching info about SP {:?}", sp_id)) - .map(|s| (sp_id.type_, sp_slot, s)) + .map(|s| (sp_id.type_, sp_id.slot, s)) }) .collect::>>() .await diff --git a/gateway-test-utils/src/setup.rs b/gateway-test-utils/src/setup.rs index 5937d7e13b1..dea606ab77c 100644 --- a/gateway-test-utils/src/setup.rs +++ b/gateway-test-utils/src/setup.rs @@ -151,11 +151,11 @@ pub async fn test_setup_with_config( port_description.location.get(&expected_location).unwrap(); let (sp_addr, sp_ereport_addr) = match target_sp.typ { SpType::Switch => { - let switch = &simrack.sidecars[target_sp.slot]; + let switch = &simrack.sidecars[usize::from(target_sp.slot)]; (switch.local_addr(sp_port), switch.local_ereport_addr(sp_port)) } SpType::Sled => { - let sled = &simrack.gimlets[target_sp.slot]; + let sled = &simrack.gimlets[usize::from(target_sp.slot)]; (sled.local_addr(sp_port), sled.local_ereport_addr(sp_port)) } SpType::Power => todo!(), diff --git a/gateway-types/src/component.rs b/gateway-types/src/component.rs index f0ca730b495..a1242e28846 100644 --- a/gateway-types/src/component.rs +++ b/gateway-types/src/component.rs @@ -43,8 +43,8 @@ pub enum SpType { pub struct SpIdentifier { #[serde(rename = "type")] pub typ: SpType, - #[serde(deserialize_with = "deserializer_u32_from_string")] - pub slot: u32, + #[serde(deserialize_with = "deserializer_u16_from_string")] + pub slot: u16, } impl fmt::Display for SpIdentifier { @@ -59,12 +59,12 @@ impl fmt::Display for SpIdentifier { // trying to deserialize the flattened struct as a map of strings to strings, // which breaks on `slot` (but not on `typ` for reasons I don't entirely // understand). We can work around by using an enum that allows either `String` -// or `u32` (which gets us past the serde map of strings), and then parsing the -// string into a u32 ourselves (which gets us to the `slot` we want). More +// or `u16` (which gets us past the serde map of strings), and then parsing the +// string into a u16 ourselves (which gets us to the `slot` we want). More // background: https://github.com/serde-rs/serde/issues/1346 -fn deserializer_u32_from_string<'de, D>( +fn deserializer_u16_from_string<'de, D>( deserializer: D, -) -> Result +) -> Result where D: serde::Deserializer<'de>, { @@ -72,16 +72,16 @@ where #[derive(Debug, Deserialize)] #[serde(untagged)] - enum StringOrU32 { + enum StringOrU16 { String(String), - U32(u32), + U16(u16), } - match StringOrU32::deserialize(deserializer)? { - StringOrU32::String(s) => s + match StringOrU16::deserialize(deserializer)? { + StringOrU16::String(s) => s .parse() - .map_err(|_| de::Error::invalid_type(Unexpected::Str(&s), &"u32")), - StringOrU32::U32(n) => Ok(n), + .map_err(|_| de::Error::invalid_type(Unexpected::Str(&s), &"u16")), + StringOrU16::U16(n) => Ok(n), } } diff --git a/gateway/src/management_switch.rs b/gateway/src/management_switch.rs index 15ce15adbb6..fbb4a0ce8ed 100644 --- a/gateway/src/management_switch.rs +++ b/gateway/src/management_switch.rs @@ -89,34 +89,24 @@ fn default_ereport_listen_port() -> u16 { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)] pub struct SpIdentifier { pub typ: SpType, - pub slot: usize, + pub slot: u16, } impl SpIdentifier { - pub fn new(typ: SpType, slot: usize) -> Self { + pub fn new(typ: SpType, slot: u16) -> Self { Self { typ, slot } } } impl From for SpIdentifier { fn from(id: gateway_types::component::SpIdentifier) -> Self { - Self { - typ: id.typ.into(), - // id.slot may come from an untrusted source, but usize >= 32 bits - // on any platform that will run this code, so unwrap is fine - slot: usize::try_from(id.slot).unwrap(), - } + Self { typ: id.typ.into(), slot: id.slot } } } impl From for gateway_types::component::SpIdentifier { fn from(id: SpIdentifier) -> Self { - Self { - typ: id.typ.into(), - // id.slot comes from a trusted source (crate::management_switch) - // and will not exceed u32::MAX - slot: u32::try_from(id.slot).unwrap(), - } + Self { typ: id.typ.into(), slot: id.slot } } } diff --git a/gateway/src/metrics.rs b/gateway/src/metrics.rs index cf7b8a1f3a8..e234d11c494 100644 --- a/gateway/src/metrics.rs +++ b/gateway/src/metrics.rs @@ -648,7 +648,7 @@ impl SpPoller { hubris_archive_id: Cow::Owned( hubris_archive_id.clone(), ), - slot: self.spid.slot as u32, + slot: u32::from(self.spid.slot), component_kind: Cow::Owned(dev.device), component_id, description: Cow::Owned(dev.description), diff --git a/nexus/inventory/src/builder.rs b/nexus/inventory/src/builder.rs index 5b5a577bdb0..26381473c95 100644 --- a/nexus/inventory/src/builder.rs +++ b/nexus/inventory/src/builder.rs @@ -188,26 +188,9 @@ impl CollectionBuilder { &mut self, source: &str, sp_type: SpType, - slot: u32, + sp_slot: u16, sp_state: SpState, ) -> Option> { - // Much ado about very little: MGS reports that "slot" is a u32, though - // in practice this seems very unlikely to be bigger than a u8. (How - // many slots can there be within one rack?) The database only supports - // signed integers, so if we assumed this really could span the range of - // a u32, we'd need to store it in an i64. Instead, assume here that we - // can stick it into a u16 (which still seems generous). This will - // allow us to store it into an Int32 in the database. - let Ok(sp_slot) = u16::try_from(slot) else { - self.found_error(InventoryError::from(anyhow!( - "MGS {:?}: SP {:?} slot {}: slot number did not fit into u16", - source, - sp_type, - slot - ))); - return None; - }; - // Normalize the baseboard id: i.e., if we've seen this baseboard // before, use the same baseboard id record. Otherwise, make a new one. let baseboard = Self::normalize_item( @@ -580,7 +563,6 @@ mod test { use super::now_db_precision; use crate::examples::Representative; use crate::examples::representative; - use crate::examples::sp_state; use base64::Engine; use base64::engine::general_purpose::STANDARD as BASE64_STANDARD; use gateway_client::types::PowerState; @@ -1089,15 +1071,6 @@ mod test { .unwrap(); assert_eq!(sled1_bb, sled1_bb_dup); - // report an SP with an impossible slot number - let sled2_sp = builder.found_sp_state( - "fake MGS 1", - SpType::Sled, - u32::from(u16::MAX) + 1, - sp_state("1"), - ); - assert_eq!(sled2_sp, None); - // report SP caboose for an unknown baseboard let bogus_baseboard = BaseboardId { part_number: String::from("p1"), @@ -1309,17 +1282,7 @@ mod test { .is_none() ); - // We should see an error. - assert_eq!( - collection - .errors - .iter() - .map(|e| format!("{:#}", e)) - .collect::>(), - vec![ - "MGS \"fake MGS 1\": SP Sled slot 65536: \ - slot number did not fit into u16" - ] - ); + // We should see no errors. + assert!(collection.errors.is_empty()); } } diff --git a/nexus/mgs-updates/src/common_sp_update.rs b/nexus/mgs-updates/src/common_sp_update.rs index f7f959f2431..7d74496d163 100644 --- a/nexus/mgs-updates/src/common_sp_update.rs +++ b/nexus/mgs-updates/src/common_sp_update.rs @@ -69,7 +69,7 @@ pub trait SpComponentUpdater { fn target_sp_type(&self) -> SpType; /// The slot number of the target SP. - fn target_sp_slot(&self) -> u32; + fn target_sp_slot(&self) -> u16; /// The target firmware slot for the component. fn firmware_slot(&self) -> u16; diff --git a/nexus/mgs-updates/src/driver_update.rs b/nexus/mgs-updates/src/driver_update.rs index b464aa05fbd..05099532b06 100644 --- a/nexus/mgs-updates/src/driver_update.rs +++ b/nexus/mgs-updates/src/driver_update.rs @@ -242,7 +242,7 @@ pub(crate) async fn apply_update( client .sp_component_update( sp_type, - u32::from(sp_slot), + sp_slot, component, sp_update.firmware_slot, &sp_update.update_id.as_untyped_uuid(), @@ -450,11 +450,7 @@ async fn wait_for_delivery( let status = mgs_clients .try_all_serially(log, |client| async move { let update_status = client - .sp_component_update_status( - sp_type, - u32::from(sp_slot), - component, - ) + .sp_component_update_status(sp_type, sp_slot, component) .await?; debug!( @@ -553,12 +549,7 @@ async fn abort_update( .try_all_serially(log, |mgs_client| async move { let arg = UpdateAbortBody { id: update_id }; mgs_client - .sp_component_update_abort( - sp_type, - u32::from(sp_slot), - component, - &arg, - ) + .sp_component_update_abort(sp_type, sp_slot, component, &arg) .await }) .await diff --git a/nexus/mgs-updates/src/host_phase1_updater.rs b/nexus/mgs-updates/src/host_phase1_updater.rs index 90201ebd761..9cfe5d6551d 100644 --- a/nexus/mgs-updates/src/host_phase1_updater.rs +++ b/nexus/mgs-updates/src/host_phase1_updater.rs @@ -23,7 +23,7 @@ pub struct HostPhase1Updater { log: Logger, progress: watch::Sender>, sp_type: SpType, - sp_slot: u32, + sp_slot: u16, target_host_slot: u16, update_id: Uuid, // TODO-clarity maybe a newtype for this? TBD how we get this from @@ -34,7 +34,7 @@ pub struct HostPhase1Updater { impl HostPhase1Updater { pub fn new( sp_type: SpType, - sp_slot: u32, + sp_slot: u16, target_host_slot: u16, update_id: Uuid, phase1_data: Vec, @@ -152,7 +152,7 @@ impl SpComponentUpdater for HostPhase1Updater { self.sp_type } - fn target_sp_slot(&self) -> u32 { + fn target_sp_slot(&self) -> u16 { self.sp_slot } diff --git a/nexus/mgs-updates/src/rot_updater.rs b/nexus/mgs-updates/src/rot_updater.rs index 6e9993e0ff5..00a768f3e0d 100644 --- a/nexus/mgs-updates/src/rot_updater.rs +++ b/nexus/mgs-updates/src/rot_updater.rs @@ -35,7 +35,7 @@ pub struct RotUpdater { log: Logger, progress: watch::Sender>, sp_type: SpType, - sp_slot: u32, + sp_slot: u16, target_rot_slot: RotSlot, update_id: Uuid, // TODO-clarity maybe a newtype for this? TBD how we get this from @@ -46,7 +46,7 @@ pub struct RotUpdater { impl RotUpdater { pub fn new( sp_type: SpType, - sp_slot: u32, + sp_slot: u16, target_rot_slot: RotSlot, update_id: Uuid, rot_hubris_archive: Vec, @@ -176,7 +176,7 @@ impl SpComponentUpdater for RotUpdater { self.sp_type } - fn target_sp_slot(&self) -> u32 { + fn target_sp_slot(&self) -> u16 { self.sp_slot } @@ -217,7 +217,7 @@ impl SpComponentUpdateHelper for ReconfiguratorRotUpdater { // Verify that the device is the one we think it is. let state = mgs_clients .try_all_serially(log, move |mgs_client| async move { - mgs_client.sp_get(update.sp_type, u32::from(update.slot_id)).await + mgs_client.sp_get(update.sp_type, update.slot_id).await }) .await? .into_inner(); @@ -276,7 +276,7 @@ impl SpComponentUpdateHelper for ReconfiguratorRotUpdater { mgs_client .sp_component_caboose_get( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::ROT.to_string(), active.to_u16(), ) @@ -326,7 +326,7 @@ impl SpComponentUpdateHelper for ReconfiguratorRotUpdater { mgs_client .sp_component_caboose_get( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::ROT.to_string(), expected_active_slot.slot().toggled().to_u16(), ) @@ -415,7 +415,7 @@ impl SpComponentUpdateHelper for ReconfiguratorRotUpdater { mgs_client .sp_component_active_slot_set( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::ROT.to_string(), persist, &SpComponentFirmwareSlot { slot: inactive_slot } @@ -426,7 +426,7 @@ impl SpComponentUpdateHelper for ReconfiguratorRotUpdater { mgs_client .sp_component_reset( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::ROT.to_string(), ) .await?; diff --git a/nexus/mgs-updates/src/sp_updater.rs b/nexus/mgs-updates/src/sp_updater.rs index 42e1a4918fb..7809bc2f090 100644 --- a/nexus/mgs-updates/src/sp_updater.rs +++ b/nexus/mgs-updates/src/sp_updater.rs @@ -32,7 +32,7 @@ pub struct SpUpdater { log: Logger, progress: watch::Sender>, sp_type: SpType, - sp_slot: u32, + sp_slot: u16, update_id: Uuid, // TODO-clarity maybe a newtype for this? TBD how we get this from // wherever it's stored, which might give us a stronger type already. @@ -42,7 +42,7 @@ pub struct SpUpdater { impl SpUpdater { pub fn new( sp_type: SpType, - sp_slot: u32, + sp_slot: u16, update_id: Uuid, sp_hubris_archive: Vec, log: &Logger, @@ -123,7 +123,7 @@ impl SpComponentUpdater for SpUpdater { self.sp_type } - fn target_sp_slot(&self) -> u32 { + fn target_sp_slot(&self) -> u16 { self.sp_slot } @@ -164,9 +164,7 @@ impl SpComponentUpdateHelper for ReconfiguratorSpUpdater { // Verify that the device is the one we think it is. let state = mgs_clients .try_all_serially(log, move |mgs_client| async move { - mgs_client - .sp_get(update.sp_type, u32::from(update.slot_id)) - .await + mgs_client.sp_get(update.sp_type, update.slot_id).await }) .await? .into_inner(); @@ -190,7 +188,7 @@ impl SpComponentUpdateHelper for ReconfiguratorSpUpdater { mgs_client .sp_component_caboose_get( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::SP_ITSELF.to_string(), 0, ) @@ -242,7 +240,7 @@ impl SpComponentUpdateHelper for ReconfiguratorSpUpdater { mgs_client .sp_component_caboose_get( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::SP_ITSELF.to_string(), 1, ) @@ -302,7 +300,7 @@ impl SpComponentUpdateHelper for ReconfiguratorSpUpdater { mgs_client .sp_component_reset( update.sp_type, - u32::from(update.slot_id), + update.slot_id, &SpComponent::SP_ITSELF.to_string(), ) .await?; diff --git a/nexus/mgs-updates/src/test_util/sp_test_state.rs b/nexus/mgs-updates/src/test_util/sp_test_state.rs index 56932ea04e7..abdead68b5f 100644 --- a/nexus/mgs-updates/src/test_util/sp_test_state.rs +++ b/nexus/mgs-updates/src/test_util/sp_test_state.rs @@ -58,7 +58,6 @@ impl SpTestState { sp_type: SpType, sp_slot: u16, ) -> Result { - let sp_slot = u32::from(sp_slot); let caboose_sp_active = mgs_client .sp_component_caboose_get( sp_type, diff --git a/nexus/reconfigurator/planning/src/mgs_updates/mod.rs b/nexus/reconfigurator/planning/src/mgs_updates/mod.rs index 12835fb49be..3c3192c2071 100644 --- a/nexus/reconfigurator/planning/src/mgs_updates/mod.rs +++ b/nexus/reconfigurator/planning/src/mgs_updates/mod.rs @@ -711,7 +711,7 @@ mod test { }; let baseboard_id = builder - .found_sp_state("test", sp_type, u32::from(sp_slot), sp_state) + .found_sp_state("test", sp_type, sp_slot, sp_state) .unwrap(); let active_version = active_version_exceptions .get(&(sp_type, sp_slot)) diff --git a/nexus/reconfigurator/planning/src/system.rs b/nexus/reconfigurator/planning/src/system.rs index f47975820e9..dfee1ea981d 100644 --- a/nexus/reconfigurator/planning/src/system.rs +++ b/nexus/reconfigurator/planning/src/system.rs @@ -517,7 +517,7 @@ impl SystemDescription { .found_sp_state( "fake MGS 1", SpType::Sled, - u32::from(*slot), + *slot, sp_state.clone(), ) .context("recording SP state")?; diff --git a/nexus/src/app/background/tasks/ereport_ingester.rs b/nexus/src/app/background/tasks/ereport_ingester.rs index 504149c06d4..35f88701b81 100644 --- a/nexus/src/app/background/tasks/ereport_ingester.rs +++ b/nexus/src/app/background/tasks/ereport_ingester.rs @@ -136,12 +136,6 @@ impl SpEreportIngester { let mut tasks = ParallelTaskSet::new(); for gateway_client::types::SpIdentifier { type_, slot } in sps { - let Ok(slot) = u16::try_from(slot) else { - const MSG: &str = "invalid slot number received from MGS"; - error!(opctx.log, "{MSG}"; "sp_type" => %type_, "slot" => %slot); - status.errors.push(format!("{MSG}: {type_} {slot}")); - continue; - }; let sp_result = tasks .spawn({ let opctx = opctx.child(BTreeMap::from([ @@ -359,7 +353,7 @@ impl Ingester { let res = client .sp_ereports_ingest( sp_type, - u32::from(slot), + slot, committed_ena.as_ref(), LIMIT, &restart_id, diff --git a/openapi/gateway.json b/openapi/gateway.json index b103bad4101..89ece0a0e73 100644 --- a/openapi/gateway.json +++ b/openapi/gateway.json @@ -51,7 +51,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -105,7 +105,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -232,7 +232,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -277,7 +277,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -331,7 +331,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -389,7 +389,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -441,7 +441,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -507,7 +507,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -572,7 +572,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -636,7 +636,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -683,7 +683,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -736,7 +736,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -783,7 +783,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -847,7 +847,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -894,7 +894,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -941,7 +941,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1020,7 +1020,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1077,7 +1077,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1122,7 +1122,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1203,7 +1203,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1245,7 +1245,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1283,7 +1283,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1328,7 +1328,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1366,7 +1366,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1409,7 +1409,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1468,7 +1468,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1513,7 +1513,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1556,7 +1556,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1603,7 +1603,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -1650,7 +1650,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -3124,7 +3124,7 @@ "properties": { "slot": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 }, "type": { diff --git a/openapi/wicketd.json b/openapi/wicketd.json index 0183c25d168..d2aa583d096 100644 --- a/openapi/wicketd.json +++ b/openapi/wicketd.json @@ -22,7 +22,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -186,7 +186,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -721,7 +721,7 @@ "required": true, "schema": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 } }, @@ -3296,7 +3296,7 @@ "type": "array", "items": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 }, "uniqueItems": true @@ -4320,12 +4320,12 @@ ] }, "SpIdentifier": { - "description": "`SpIdentifier`\n\n
JSON schema\n\n```json { \"type\": \"object\", \"required\": [ \"slot\", \"type\" ], \"properties\": { \"slot\": { \"type\": \"integer\", \"format\": \"uint32\", \"minimum\": 0.0 }, \"type\": { \"$ref\": \"#/components/schemas/SpType\" } } } ```
", + "description": "`SpIdentifier`\n\n
JSON schema\n\n```json { \"type\": \"object\", \"required\": [ \"slot\", \"type\" ], \"properties\": { \"slot\": { \"type\": \"integer\", \"format\": \"uint16\", \"minimum\": 0.0 }, \"type\": { \"$ref\": \"#/components/schemas/SpType\" } } } ```
", "type": "object", "properties": { "slot": { "type": "integer", - "format": "uint32", + "format": "uint16", "minimum": 0 }, "type": { diff --git a/wicket-common/src/rack_setup.rs b/wicket-common/src/rack_setup.rs index 73abf990e01..bbccad0811f 100644 --- a/wicket-common/src/rack_setup.rs +++ b/wicket-common/src/rack_setup.rs @@ -65,7 +65,7 @@ pub struct PutRssUserConfigInsensitive { /// `wicketd` will map this back to sleds with the correct `SpIdentifier` /// based on the `bootstrap_sleds` it provides in /// `CurrentRssUserConfigInsensitive`. - pub bootstrap_sleds: BTreeSet, + pub bootstrap_sleds: BTreeSet, pub ntp_servers: Vec, pub dns_servers: Vec, pub internal_services_ip_pool_ranges: Vec, diff --git a/wicket/src/state/inventory.rs b/wicket/src/state/inventory.rs index 073c6ab32e2..a558dbdf33c 100644 --- a/wicket/src/state/inventory.rs +++ b/wicket/src/state/inventory.rs @@ -280,7 +280,7 @@ impl ComponentId { Ok(Self::Psc(slot)) } - pub fn from_sp_type_and_slot(sp_type: SpType, slot: u32) -> Result { + pub fn from_sp_type_and_slot(sp_type: SpType, slot: u16) -> Result { let slot = slot.try_into().map_err(|_| { anyhow::anyhow!("invalid slot (must fit in a u8): {}", slot) })?; diff --git a/wicket/src/state/mod.rs b/wicket/src/state/mod.rs index 8cfc422bb02..1b7678025dd 100644 --- a/wicket/src/state/mod.rs +++ b/wicket/src/state/mod.rs @@ -72,7 +72,7 @@ impl State { // Do we know the wicketd sled ID? If so, we can compare // directly. (We will almost always know this.) if let Some(wicketd_sled_id) = self.wicketd_location.sled_id { - wicketd_sled_id.slot == u32::from(i) + wicketd_sled_id.slot == u16::from(i) } else { // We _could_ check and see if wicketd knows its sled's // baseboard (even though it didn't know the sled) and then @@ -88,7 +88,7 @@ impl State { // thing here for the switch. if let Some(wicketd_switch_id) = self.wicketd_location.switch_id { - wicketd_switch_id.slot == u32::from(i) + wicketd_switch_id.slot == u16::from(i) } else { false } diff --git a/wicket/src/wicketd.rs b/wicket/src/wicketd.rs index a708cc0a90a..0228b875d30 100644 --- a/wicket/src/wicketd.rs +++ b/wicket/src/wicketd.rs @@ -28,13 +28,13 @@ impl From for SpIdentifier { fn from(id: ComponentId) -> Self { match id { ComponentId::Sled(i) => { - SpIdentifier { type_: SpType::Sled, slot: u32::from(i) } + SpIdentifier { type_: SpType::Sled, slot: u16::from(i) } } ComponentId::Psc(i) => { - SpIdentifier { type_: SpType::Power, slot: u32::from(i) } + SpIdentifier { type_: SpType::Power, slot: u16::from(i) } } ComponentId::Switch(i) => { - SpIdentifier { type_: SpType::Switch, slot: u32::from(i) } + SpIdentifier { type_: SpType::Switch, slot: u16::from(i) } } } } diff --git a/wicketd-api/src/lib.rs b/wicketd-api/src/lib.rs index 03e7e798f81..467922aad86 100644 --- a/wicketd-api/src/lib.rs +++ b/wicketd-api/src/lib.rs @@ -487,7 +487,7 @@ pub struct GetArtifactsAndEventReportsResponse { /// instead. pub artifacts: Vec, - pub event_reports: BTreeMap>, + pub event_reports: BTreeMap>, } #[derive(Clone, Debug, JsonSchema, Deserialize)] @@ -535,7 +535,7 @@ pub struct GetLocationResponse { pub struct PathSpIgnitionCommand { #[serde(rename = "type")] pub type_: SpType, - pub slot: u32, + pub slot: u16, pub command: IgnitionCommand, }