From d80cd2926102034a3d5d4a0003e10b0f2a4eeb89 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 25 Apr 2024 19:34:47 -0400 Subject: [PATCH] Use SledUuid keys in Blueprint::blueprint_zones (#5623) --- .../db-queries/src/db/datastore/deployment.rs | 31 ++++------- nexus/db-queries/src/db/datastore/rack.rs | 14 ++--- nexus/db-queries/src/db/datastore/vpc.rs | 5 +- nexus/reconfigurator/execution/src/dns.rs | 8 ++- .../execution/src/omicron_zones.rs | 15 ++---- .../planning/src/blueprint_builder/builder.rs | 30 +++++------ nexus/reconfigurator/planning/src/example.rs | 6 +-- nexus/reconfigurator/planning/src/planner.rs | 24 +++------ .../src/app/background/blueprint_execution.rs | 17 +++--- nexus/test-utils/src/lib.rs | 3 +- nexus/types/src/deployment.rs | 53 +++++-------------- sled-agent/src/rack_setup/service.rs | 14 ++--- sled-agent/src/sim/server.rs | 6 ++- 13 files changed, 83 insertions(+), 143 deletions(-) diff --git a/nexus/db-queries/src/db/datastore/deployment.rs b/nexus/db-queries/src/db/datastore/deployment.rs index 5a17b39fdd..97f7296368 100644 --- a/nexus/db-queries/src/db/datastore/deployment.rs +++ b/nexus/db-queries/src/db/datastore/deployment.rs @@ -137,11 +137,7 @@ impl DataStore { .blueprint_zones .iter() .map(|(sled_id, zones_config)| { - BpSledOmicronZones::new( - blueprint_id, - SledUuid::from_untyped_uuid(*sled_id), - zones_config, - ) + BpSledOmicronZones::new(blueprint_id, *sled_id, zones_config) }) .collect::>(); let omicron_zones = blueprint @@ -149,12 +145,8 @@ impl DataStore { .iter() .flat_map(|(sled_id, zones_config)| { zones_config.zones.iter().map(move |zone| { - BpOmicronZone::new( - blueprint_id, - SledUuid::from_untyped_uuid(*sled_id), - zone, - ) - .map_err(|e| Error::internal_error(&format!("{:#}", e))) + BpOmicronZone::new(blueprint_id, *sled_id, zone) + .map_err(|e| Error::internal_error(&format!("{:#}", e))) }) }) .collect::, Error>>()?; @@ -302,7 +294,7 @@ impl DataStore { // the `OmicronZonesConfig` generation number for each sled that is a // part of this blueprint. Construct the BTreeMap we ultimately need, // but all the `zones` vecs will be empty until our next query below. - let mut blueprint_zones: BTreeMap = { + let mut blueprint_zones: BTreeMap = { use db::schema::bp_sled_omicron_zones::dsl; let mut blueprint_zones = BTreeMap::new(); @@ -325,7 +317,7 @@ impl DataStore { for s in batch { let old = blueprint_zones.insert( - s.sled_id.into_untyped_uuid(), + s.sled_id.into(), BlueprintZonesConfig { generation: *s.generation, zones: Vec::new(), @@ -467,24 +459,23 @@ impl DataStore { }) }) .transpose()?; - let sled_zones = blueprint_zones - .get_mut(z.sled_id.as_untyped_uuid()) - .ok_or_else(|| { + let sled_id = SledUuid::from(z.sled_id); + let zone_id = z.id; + let sled_zones = + blueprint_zones.get_mut(&sled_id).ok_or_else(|| { // This error means that we found a row in // bp_omicron_zone with no associated record in // bp_sled_omicron_zones. This should be // impossible and reflects either a bug or database // corruption. Error::internal_error(&format!( - "zone {}: unknown sled: {}", - z.id, z.sled_id + "zone {zone_id}: unknown sled: {sled_id}", )) })?; - let zone_id = z.id; let zone = z .into_blueprint_zone_config(nic_row) .with_context(|| { - format!("zone {:?}: parse from database", zone_id) + format!("zone {zone_id}: parse from database") }) .map_err(|e| { Error::internal_error(&format!( diff --git a/nexus/db-queries/src/db/datastore/rack.rs b/nexus/db-queries/src/db/datastore/rack.rs index d1e4f953f8..1e1b896d3a 100644 --- a/nexus/db-queries/src/db/datastore/rack.rs +++ b/nexus/db-queries/src/db/datastore/rack.rs @@ -977,9 +977,9 @@ mod test { }; use omicron_common::api::internal::shared::SourceNatConfig; use omicron_test_utils::dev; - use omicron_uuid_kinds::TypedUuid; use omicron_uuid_kinds::{ExternalIpUuid, OmicronZoneUuid}; use omicron_uuid_kinds::{GenericUuid, ZpoolUuid}; + use omicron_uuid_kinds::{SledUuid, TypedUuid}; use sled_agent_client::types::OmicronZoneDataset; use std::collections::{BTreeMap, HashMap}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV6}; @@ -1292,7 +1292,7 @@ mod test { let mut blueprint_zones = BTreeMap::new(); blueprint_zones.insert( - sled1.id(), + SledUuid::from_untyped_uuid(sled1.id()), BlueprintZonesConfig { generation: Generation::new().next(), zones: vec![ @@ -1367,7 +1367,7 @@ mod test { }, ); blueprint_zones.insert( - sled2.id(), + SledUuid::from_untyped_uuid(sled2.id()), BlueprintZonesConfig { generation: Generation::new().next(), zones: vec![ @@ -1443,7 +1443,7 @@ mod test { }, ); blueprint_zones.insert( - sled3.id(), + SledUuid::from_untyped_uuid(sled3.id()), BlueprintZonesConfig { generation: Generation::new().next(), zones: vec![BlueprintZoneConfig { @@ -1620,7 +1620,7 @@ mod test { let mut blueprint_zones = BTreeMap::new(); blueprint_zones.insert( - sled.id(), + SledUuid::from_untyped_uuid(sled.id()), BlueprintZonesConfig { generation: Generation::new().next(), zones: vec![ @@ -1890,7 +1890,7 @@ mod test { let mut macs = MacAddr::iter_system(); let mut blueprint_zones = BTreeMap::new(); blueprint_zones.insert( - sled.id(), + SledUuid::from_untyped_uuid(sled.id()), BlueprintZonesConfig { generation: Generation::new().next(), zones: vec![BlueprintZoneConfig { @@ -1994,7 +1994,7 @@ mod test { let mut blueprint_zones = BTreeMap::new(); blueprint_zones.insert( - sled.id(), + SledUuid::from_untyped_uuid(sled.id()), BlueprintZonesConfig { generation: Generation::new().next(), zones: vec![ diff --git a/nexus/db-queries/src/db/datastore/vpc.rs b/nexus/db-queries/src/db/datastore/vpc.rs index a2d3e7d05a..632ea501e3 100644 --- a/nexus/db-queries/src/db/datastore/vpc.rs +++ b/nexus/db-queries/src/db/datastore/vpc.rs @@ -1567,7 +1567,8 @@ mod tests { fn blueprint_zone_configs( &self, - ) -> impl Iterator + '_ { + ) -> impl Iterator + '_ + { self.nexuses.iter().zip(self.db_nics()).map(|(nexus, nic)| { let config = BlueprintZoneConfig { disposition: BlueprintZoneDisposition::InService, @@ -1597,7 +1598,7 @@ mod tests { }, ), }; - (nexus.sled_id.into_untyped_uuid(), config) + (nexus.sled_id, config) }) } } diff --git a/nexus/reconfigurator/execution/src/dns.rs b/nexus/reconfigurator/execution/src/dns.rs index dd9d249a25..e0105f1f64 100644 --- a/nexus/reconfigurator/execution/src/dns.rs +++ b/nexus/reconfigurator/execution/src/dns.rs @@ -496,7 +496,6 @@ mod test { use omicron_common::api::external::IdentityMetadataCreateParams; use omicron_test_utils::dev::test_setup_log; use omicron_uuid_kinds::ExternalIpUuid; - use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::OmicronZoneUuid; use std::collections::BTreeMap; use std::collections::BTreeSet; @@ -560,7 +559,7 @@ mod test { let mut blueprint_zones = BTreeMap::new(); for (sled_id, zones_config) in collection.omicron_zones { blueprint_zones.insert( - sled_id.into_untyped_uuid(), + sled_id, BlueprintZonesConfig { generation: zones_config.zones.generation, zones: zones_config @@ -628,9 +627,8 @@ mod test { .zip(possible_sled_subnets) .enumerate() .map(|(i, (sled_id, subnet))| { - let sled_id = SledUuid::from_untyped_uuid(*sled_id); let sled_info = Sled { - id: sled_id, + id: *sled_id, sled_agent_address: get_sled_address(Ipv6Subnet::new( subnet.network(), )), @@ -638,7 +636,7 @@ mod test { // Scrimlets. is_scrimlet: i < 2, }; - (sled_id, sled_info) + (*sled_id, sled_info) }) .collect(); diff --git a/nexus/reconfigurator/execution/src/omicron_zones.rs b/nexus/reconfigurator/execution/src/omicron_zones.rs index 7cc6fc2dba..da74023841 100644 --- a/nexus/reconfigurator/execution/src/omicron_zones.rs +++ b/nexus/reconfigurator/execution/src/omicron_zones.rs @@ -17,20 +17,17 @@ use omicron_uuid_kinds::SledUuid; use slog::info; use slog::warn; use std::collections::BTreeMap; -use uuid::Uuid; /// Idempotently ensure that the specified Omicron zones are deployed to the /// corresponding sleds pub(crate) async fn deploy_zones( opctx: &OpContext, sleds_by_id: &BTreeMap, - zones: &BTreeMap, + zones: &BTreeMap, ) -> Result<(), Vec> { let errors: Vec<_> = stream::iter(zones) .filter_map(|(sled_id, config)| async move { - let db_sled = match sleds_by_id - .get(&SledUuid::from_untyped_uuid(*sled_id)) - { + let db_sled = match sleds_by_id.get(sled_id) { Some(sled) => sled, None => { if config.are_all_zones_expunged() { @@ -41,7 +38,7 @@ pub(crate) async fn deploy_zones( ); return None; } - let err = anyhow!("sled not found in db list: {}", sled_id); + let err = anyhow!("sled not found in db list: {sled_id}"); warn!(opctx.log, "{err:#}"); return Some(err); } @@ -106,7 +103,6 @@ mod test { }; use nexus_types::inventory::OmicronZoneDataset; use omicron_common::api::external::Generation; - use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::OmicronZoneUuid; use omicron_uuid_kinds::SledUuid; use std::collections::BTreeMap; @@ -128,10 +124,7 @@ mod test { }, Blueprint { id, - blueprint_zones: blueprint_zones - .into_iter() - .map(|(typed_id, z)| (typed_id.into_untyped_uuid(), z)) - .collect(), + blueprint_zones, blueprint_disks: BTreeMap::new(), parent_blueprint_id: None, internal_dns_version: Generation::new(), diff --git a/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs b/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs index c2eabca71d..dc8b1452a7 100644 --- a/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs +++ b/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs @@ -58,7 +58,6 @@ use slog::error; use slog::info; use slog::o; use slog::Logger; -use std::borrow::Cow; use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::HashSet; @@ -70,7 +69,6 @@ use std::net::SocketAddrV6; use thiserror::Error; use typed_rng::TypedUuidRng; use typed_rng::UuidRng; -use uuid::Uuid; use super::zones::is_already_expunged; use super::zones::BuilderZoneState; @@ -198,7 +196,7 @@ impl<'a> BlueprintBuilder<'a> { generation: Generation::new(), zones: Vec::new(), }; - (sled_id.into_untyped_uuid(), config) + (sled_id, config) }) .collect::>(); let num_sleds = blueprint_zones.len(); @@ -961,17 +959,14 @@ impl BlueprintBuilderRng { /// struct makes it easy for callers iterate over the right set of zones. pub(super) struct BlueprintZonesBuilder<'a> { changed_zones: BTreeMap, - // Temporarily make a clone of the parent blueprint's zones so we can use - // typed UUIDs everywhere. Once we're done migrating, this `Cow` can be - // removed. - parent_zones: Cow<'a, BTreeMap>, + parent_zones: &'a BTreeMap, } impl<'a> BlueprintZonesBuilder<'a> { pub fn new(parent_blueprint: &'a Blueprint) -> BlueprintZonesBuilder { BlueprintZonesBuilder { changed_zones: BTreeMap::new(), - parent_zones: Cow::Owned(parent_blueprint.typed_blueprint_zones()), + parent_zones: &parent_blueprint.blueprint_zones, } } @@ -1018,25 +1013,26 @@ impl<'a> BlueprintZonesBuilder<'a> { pub fn into_zones_map( mut self, sled_ids: impl Iterator, - ) -> BTreeMap { + ) -> BTreeMap { sled_ids .map(|sled_id| { // Start with self.changed_zones, which contains entries for any // sled whose zones config is changing in this blueprint. if let Some(zones) = self.changed_zones.remove(&sled_id) { - (sled_id.into_untyped_uuid(), zones.build()) + (sled_id, zones.build()) } - // Next, check self.parent_zones, to represent an unchanged sled. + // Next, check self.parent_zones, to represent an unchanged + // sled. else if let Some(parent_zones) = self.parent_zones.get(&sled_id) { - (sled_id.into_untyped_uuid(), parent_zones.clone()) + (sled_id, parent_zones.clone()) } else { - // If the sled is not in self.parent_zones, then it must be a - // new sled and we haven't added any zones to it yet. Use the - // standard initial config. + // If the sled is not in self.parent_zones, then it must be + // a new sled and we haven't added any zones to it yet. Use + // the standard initial config. ( - sled_id.into_untyped_uuid(), + sled_id, BlueprintZonesConfig { generation: Generation::new(), zones: vec![], @@ -1465,7 +1461,7 @@ pub mod test { // Also remove this zone from the blueprint. parent .blueprint_zones - .get_mut(sled_id.as_untyped_uuid()) + .get_mut(sled_id) .expect("missing sled") .zones .retain(|z| !z.zone_type.is_nexus()); diff --git a/nexus/reconfigurator/planning/src/example.rs b/nexus/reconfigurator/planning/src/example.rs index 6a2f7d3c33..136302e7be 100644 --- a/nexus/reconfigurator/planning/src/example.rs +++ b/nexus/reconfigurator/planning/src/example.rs @@ -13,7 +13,6 @@ use nexus_types::deployment::OmicronZoneNic; use nexus_types::deployment::PlanningInput; use nexus_types::deployment::SledFilter; use nexus_types::inventory::Collection; -use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::SledKind; use typed_rng::TypedUuidRng; @@ -91,10 +90,7 @@ impl ExampleSystem { builder.set_rng_seed((test_name, "ExampleSystem collection")); for sled_id in blueprint.sleds() { - // TODO-cleanup use `TypedUuid` everywhere - let Some(zones) = - blueprint.blueprint_zones.get(sled_id.as_untyped_uuid()) - else { + let Some(zones) = blueprint.blueprint_zones.get(&sled_id) else { continue; }; for zone in zones.zones.iter() { diff --git a/nexus/reconfigurator/planning/src/planner.rs b/nexus/reconfigurator/planning/src/planner.rs index 1238692b67..211e145c3e 100644 --- a/nexus/reconfigurator/planning/src/planner.rs +++ b/nexus/reconfigurator/planning/src/planner.rs @@ -417,7 +417,6 @@ mod test { use omicron_common::api::external::Generation; use omicron_common::disk::DiskIdentity; use omicron_test_utils::dev::test_setup_log; - use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::ZpoolUuid; use std::collections::HashMap; @@ -533,7 +532,7 @@ mod test { sled_id: new_sled_id, zones: blueprint4 .blueprint_zones - .get(new_sled_id.as_untyped_uuid()) + .get(&new_sled_id) .expect("blueprint should contain zones for new sled") .to_omicron_zones_config( BlueprintZoneFilter::ShouldBeRunning @@ -628,9 +627,7 @@ mod test { assert_eq!(collection.sled_agents.len(), 1); assert_eq!(collection.omicron_zones.len(), 1); - blueprint - .blueprint_zones - .retain(|k, _v| keep_sled_id.as_untyped_uuid() == k); + blueprint.blueprint_zones.retain(|k, _v| keep_sled_id == *k); (keep_sled_id, blueprint, collection, builder.build()) }; @@ -641,7 +638,7 @@ mod test { assert_eq!( blueprint1 .blueprint_zones - .get(sled_id.as_untyped_uuid()) + .get(&sled_id) .expect("missing kept sled") .zones .iter() @@ -1015,8 +1012,7 @@ mod test { // Leave the non-provisionable sled's generation alone. let zones = &mut blueprint2a .blueprint_zones - // TODO-cleanup use `TypedUuid` everywhere - .get_mut(nonprovisionable_sled_id.as_untyped_uuid()) + .get_mut(&nonprovisionable_sled_id) .unwrap() .zones; @@ -1057,18 +1053,12 @@ mod test { } }); - let expunged_zones = blueprint2a - .blueprint_zones - // TODO-cleanup use `TypedUuid` everywhere - .get_mut(expunged_sled_id.as_untyped_uuid()) - .unwrap(); + let expunged_zones = + blueprint2a.blueprint_zones.get_mut(&expunged_sled_id).unwrap(); expunged_zones.zones.clear(); expunged_zones.generation = expunged_zones.generation.next(); - blueprint2a - .blueprint_zones - // TODO-cleanup use `TypedUuid` everywhere - .remove(decommissioned_sled_id.as_untyped_uuid()); + blueprint2a.blueprint_zones.remove(&decommissioned_sled_id); blueprint2a.external_dns_version = blueprint2a.external_dns_version.next(); diff --git a/nexus/src/app/background/blueprint_execution.rs b/nexus/src/app/background/blueprint_execution.rs index 51898b9b7b..5a92d36895 100644 --- a/nexus/src/app/background/blueprint_execution.rs +++ b/nexus/src/app/background/blueprint_execution.rs @@ -127,9 +127,9 @@ mod test { }; use nexus_types::inventory::OmicronZoneDataset; use omicron_common::api::external::Generation; + use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::OmicronZoneUuid; - use omicron_uuid_kinds::SledKind; - use omicron_uuid_kinds::TypedUuid; + use omicron_uuid_kinds::SledUuid; use serde::Deserialize; use serde_json::json; use std::collections::BTreeMap; @@ -142,11 +142,8 @@ mod test { nexus_test_utils::ControlPlaneTestContext; fn create_blueprint( - blueprint_zones: BTreeMap, - blueprint_disks: BTreeMap< - TypedUuid, - BlueprintPhysicalDisksConfig, - >, + blueprint_zones: BTreeMap, + blueprint_disks: BTreeMap, dns_version: Generation, ) -> (BlueprintTarget, Blueprint) { let id = Uuid::new_v4(); @@ -186,8 +183,8 @@ mod test { // sleds to CRDB. let mut s1 = httptest::Server::run(); let mut s2 = httptest::Server::run(); - let sled_id1 = Uuid::new_v4(); - let sled_id2 = Uuid::new_v4(); + let sled_id1 = SledUuid::new_v4(); + let sled_id2 = SledUuid::new_v4(); let rack_id = Uuid::new_v4(); for (i, (sled_id, server)) in [(sled_id1, &s1), (sled_id2, &s2)].iter().enumerate() @@ -196,7 +193,7 @@ mod test { panic!("Expected Ipv6 address. Got {}", server.addr()); }; let update = SledUpdate::new( - *sled_id, + sled_id.into_untyped_uuid(), addr, SledBaseboard { serial_number: i.to_string(), diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 992e230e4a..c2179d3d8a 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -57,6 +57,7 @@ use omicron_test_utils::dev; use omicron_uuid_kinds::ExternalIpUuid; use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::OmicronZoneUuid; +use omicron_uuid_kinds::SledUuid; use omicron_uuid_kinds::ZpoolUuid; use oximeter_collector::Oximeter; use oximeter_producer::LogConfig; @@ -758,7 +759,7 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> { ] { if let Some(sa) = maybe_sled_agent { blueprint_zones.insert( - sa.sled_agent.id, + SledUuid::from_untyped_uuid(sa.sled_agent.id), BlueprintZonesConfig { generation: Generation::new().next(), zones: zones.clone(), diff --git a/nexus/types/src/deployment.rs b/nexus/types/src/deployment.rs index 3e0b6af59b..b818b99794 100644 --- a/nexus/types/src/deployment.rs +++ b/nexus/types/src/deployment.rs @@ -110,7 +110,7 @@ pub struct Blueprint { /// /// A sled is considered part of the control plane cluster iff it has an /// entry in this map. - pub blueprint_zones: BTreeMap, + pub blueprint_zones: BTreeMap, /// A map of sled id -> disks in use on each sled. pub blueprint_disks: BTreeMap, @@ -155,11 +155,12 @@ impl Blueprint { pub fn all_omicron_zones( &self, filter: BlueprintZoneFilter, - ) -> impl Iterator { + ) -> impl Iterator { self.blueprint_zones.iter().flat_map(move |(sled_id, z)| { - z.zones.iter().filter_map(move |z| { - z.disposition.matches(filter).then_some((*sled_id, z)) - }) + z.zones + .iter() + .filter(move |z| z.disposition.matches(filter)) + .map(|z| (*sled_id, z)) }) } @@ -174,26 +175,13 @@ impl Blueprint { z.zones .iter() .filter(move |z| !z.disposition.matches(filter)) - .map(|z| (SledUuid::from_untyped_uuid(*sled_id), z)) + .map(|z| (*sled_id, z)) }) } - // Temporary method that provides the list of Omicron zones using - // `TypedUuid`. - // - // In the future, `all_omicron_zones` will return `SledUuid`, - // and this method will go away. - pub fn all_omicron_zones_typed( - &self, - filter: BlueprintZoneFilter, - ) -> impl Iterator { - self.all_omicron_zones(filter) - .map(|(sled_id, z)| (SledUuid::from_untyped_uuid(sled_id), z)) - } - /// Iterate over the ids of all sleds in the blueprint pub fn sleds(&self) -> impl Iterator + '_ { - self.blueprint_zones.keys().copied().map(SledUuid::from_untyped_uuid) + self.blueprint_zones.keys().copied() } /// Summarize the difference between sleds and zones between two @@ -209,12 +197,12 @@ impl Blueprint { BlueprintDiff::new( DiffBeforeMetadata::Blueprint(Box::new(before.metadata())), before - .typed_blueprint_zones() - .into_iter() - .map(|(sled_id, zones)| (sled_id, zones.into())) + .blueprint_zones + .iter() + .map(|(sled_id, zones)| (*sled_id, zones.clone().into())) .collect(), self.metadata(), - self.typed_blueprint_zones(), + self.blueprint_zones.clone(), ) } @@ -243,7 +231,7 @@ impl Blueprint { DiffBeforeMetadata::Collection { id: before.id }, before_zones, self.metadata(), - self.typed_blueprint_zones(), + self.blueprint_zones.clone(), ) } @@ -252,21 +240,6 @@ impl Blueprint { pub fn display(&self) -> BlueprintDisplay<'_> { BlueprintDisplay { blueprint: self } } - - /// Temporary method that returns `self.blueprint_zones`, except the keys - /// are `SledUuid`. - /// - /// TODO-cleanup use `TypedUuid` everywhere - pub fn typed_blueprint_zones( - &self, - ) -> BTreeMap { - self.blueprint_zones - .iter() - .map(|(sled_id, zones)| { - (SledUuid::from_untyped_uuid(*sled_id), zones.clone()) - }) - .collect() - } } /// Wrapper to allow a [`Blueprint`] to be displayed with information. diff --git a/sled-agent/src/rack_setup/service.rs b/sled-agent/src/rack_setup/service.rs index cf4fea351d..f590428244 100644 --- a/sled-agent/src/rack_setup/service.rs +++ b/sled-agent/src/rack_setup/service.rs @@ -812,7 +812,7 @@ impl ServiceInner { serial: config.identity.serial.clone(), model: config.identity.model.clone(), variant: NexusTypes::PhysicalDiskKind::U2, - sled_id: *sled_id, + sled_id: sled_id.into_untyped_uuid(), } }) }) @@ -825,7 +825,7 @@ impl ServiceInner { NexusTypes::ZpoolPutRequest { id: config.pool_id.into_untyped_uuid(), physical_disk_id: config.id, - sled_id: *sled_id, + sled_id: sled_id.into_untyped_uuid(), } }) }) @@ -1277,11 +1277,11 @@ impl DeployStepVersion { fn build_sled_configs_by_id( sled_plan: &SledPlan, service_plan: &ServicePlan, -) -> anyhow::Result> { +) -> anyhow::Result> { let mut sled_configs = BTreeMap::new(); for sled_request in sled_plan.sleds.values() { let sled_addr = get_sled_address(sled_request.body.subnet); - let sled_id = sled_request.body.id; + let sled_id = SledUuid::from_untyped_uuid(sled_request.body.id); let entry = match sled_configs.entry(sled_id) { btree_map::Entry::Vacant(entry) => entry, btree_map::Entry::Occupied(_) => { @@ -1314,7 +1314,7 @@ fn build_sled_configs_by_id( // Build an initial blueprint fn build_initial_blueprint_from_plan( - sled_configs_by_id: &BTreeMap, + sled_configs_by_id: &BTreeMap, service_plan: &ServicePlan, ) -> anyhow::Result { let internal_dns_version = @@ -1330,7 +1330,7 @@ fn build_initial_blueprint_from_plan( } pub(crate) fn build_initial_blueprint_from_sled_configs( - sled_configs_by_id: &BTreeMap, + sled_configs_by_id: &BTreeMap, internal_dns_version: Generation, ) -> Result { // Helper to convert an `OmicronZoneConfig` into a `BlueprintZoneConfig`. @@ -1357,7 +1357,7 @@ pub(crate) fn build_initial_blueprint_from_sled_configs( let mut blueprint_disks = BTreeMap::new(); for (sled_id, sled_config) in sled_configs_by_id { blueprint_disks.insert( - SledUuid::from_untyped_uuid(*sled_id), + *sled_id, BlueprintPhysicalDisksConfig { generation: sled_config.disks.generation, disks: sled_config diff --git a/sled-agent/src/sim/server.rs b/sled-agent/src/sim/server.rs index 7d12b3bfe0..5da887aa05 100644 --- a/sled-agent/src/sim/server.rs +++ b/sled-agent/src/sim/server.rs @@ -34,6 +34,7 @@ use omicron_common::backoff::{ use omicron_common::disk::DiskIdentity; use omicron_common::FileKv; use omicron_uuid_kinds::GenericUuid; +use omicron_uuid_kinds::SledUuid; use omicron_uuid_kinds::ZpoolUuid; use slog::{info, Drain, Logger}; use std::collections::BTreeMap; @@ -502,7 +503,10 @@ pub async fn run_standalone_server( let disks = server.sled_agent.omicron_physical_disks_list().await?; let mut sled_configs = BTreeMap::new(); - sled_configs.insert(config.id, SledConfig { disks, zones }); + sled_configs.insert( + SledUuid::from_untyped_uuid(config.id), + SledConfig { disks, zones }, + ); let rack_init_request = NexusTypes::RackInitializationRequest { blueprint: build_initial_blueprint_from_sled_configs(