diff --git a/dev-tools/omdb/src/bin/omdb/db.rs b/dev-tools/omdb/src/bin/omdb/db.rs index 0e8a37e31df..10f71565b7c 100644 --- a/dev-tools/omdb/src/bin/omdb/db.rs +++ b/dev-tools/omdb/src/bin/omdb/db.rs @@ -1643,7 +1643,7 @@ struct CrucibleDatasetRow { // dataset fields id: DatasetUuid, time_deleted: String, - pool_id: Uuid, + pool_id: ZpoolUuid, address: String, size_used: i64, no_provision: bool, @@ -1679,20 +1679,19 @@ async fn get_crucible_dataset_rows( bail!("no latest inventory found!"); }; - let mut zpool_total_size: HashMap = HashMap::new(); + let mut zpool_total_size: HashMap = HashMap::new(); for sled_agent in latest_collection.sled_agents { for zpool in sled_agent.zpools { - zpool_total_size - .insert(zpool.id.into_untyped_uuid(), zpool.total_size.into()); + zpool_total_size.insert(zpool.id, zpool.total_size.into()); } } - let zpools: HashMap = datastore + let zpools: HashMap = datastore .zpool_list_all_external_batched(opctx) .await? .into_iter() - .map(|(zpool, _)| (zpool.id().into_untyped_uuid(), zpool)) + .map(|(zpool, _)| (zpool.id(), zpool)) .collect(); let mut result: Vec = @@ -1700,13 +1699,13 @@ async fn get_crucible_dataset_rows( for d in crucible_datasets { let control_plane_storage_buffer: Option = match zpools - .get(&d.pool_id) + .get(&d.pool_id()) { Some(zpool) => Some(zpool.control_plane_storage_buffer().into()), None => None, }; - let pool_total_size = zpool_total_size.get(&d.pool_id); + let pool_total_size = zpool_total_size.get(&d.pool_id()); result.push(CrucibleDatasetRow { // dataset fields @@ -1715,7 +1714,7 @@ async fn get_crucible_dataset_rows( Some(t) => t.to_string(), None => String::from(""), }, - pool_id: d.pool_id, + pool_id: d.pool_id(), address: d.address().to_string(), size_used: d.size_used, no_provision: d.no_provision(), @@ -2200,7 +2199,7 @@ async fn cmd_db_disk_info( let mut rows = Vec::with_capacity(3); for (dataset, region) in regions { - let my_pool_id = dataset.pool_id; + let my_pool_id = dataset.pool_id(); let (_, my_zpool) = LookupPath::new(opctx, datastore) .zpool_id(my_pool_id) .fetch() @@ -2219,7 +2218,7 @@ async fn cmd_db_disk_info( host_serial: my_sled.serial_number().to_string(), region: region.id().to_string(), dataset: dataset.id().to_string(), - physical_disk: my_zpool.physical_disk_id.to_string(), + physical_disk: my_zpool.physical_disk_id().to_string(), }); } @@ -2311,7 +2310,7 @@ async fn cmd_db_disk_physical( } let datasets = query - .filter(dataset_dsl::pool_id.eq(zp.id())) + .filter(dataset_dsl::pool_id.eq(to_db_typed_uuid(zp.id()))) .select(CrucibleDataset::as_select()) .load_async(&*conn) .await @@ -2739,7 +2738,7 @@ async fn cmd_db_snapshot_info( } else { let mut rows = Vec::with_capacity(3); for (dataset, region) in regions { - let my_pool_id = dataset.pool_id; + let my_pool_id = dataset.pool_id(); let (_, my_zpool) = LookupPath::new(opctx, datastore) .zpool_id(my_pool_id) .fetch() @@ -2758,7 +2757,7 @@ async fn cmd_db_snapshot_info( host_serial: my_sled.serial_number().to_string(), region: region.id().to_string(), dataset: dataset.id().to_string(), - physical_disk: my_zpool.physical_disk_id.to_string(), + physical_disk: my_zpool.physical_disk_id().to_string(), }); } @@ -2779,7 +2778,7 @@ async fn cmd_db_snapshot_info( let mut rows = Vec::with_capacity(3); for (dataset, region) in regions { - let my_pool_id = dataset.pool_id; + let my_pool_id = dataset.pool_id(); let (_, my_zpool) = LookupPath::new(opctx, datastore) .zpool_id(my_pool_id) .fetch() @@ -2798,7 +2797,7 @@ async fn cmd_db_snapshot_info( host_serial: my_sled.serial_number().to_string(), region: region.id().to_string(), dataset: dataset.id().to_string(), - physical_disk: my_zpool.physical_disk_id.to_string(), + physical_disk: my_zpool.physical_disk_id().to_string(), }); } @@ -3832,7 +3831,7 @@ async fn cmd_db_dry_run_region_allocation( pub dataset_id: DatasetUuid, pub size_used: i64, - pub pool_id: Uuid, + pub pool_id: ZpoolUuid, #[tabled(display_with = "option_impl_display")] pub total_size: Option, @@ -3852,17 +3851,16 @@ async fn cmd_db_dry_run_region_allocation( ); }; - let mut zpool_total_size: HashMap = HashMap::new(); + let mut zpool_total_size: HashMap = HashMap::new(); for sled_agent in latest_collection.sled_agents { for zpool in sled_agent.zpools { - zpool_total_size - .insert(zpool.id.into_untyped_uuid(), zpool.total_size.into()); + zpool_total_size.insert(zpool.id, zpool.total_size.into()); } } for (dataset, region) in datasets_and_regions { - let pool_id = dataset.pool_id.into_untyped_uuid(); + let pool_id = dataset.pool_id(); let total_size = zpool_total_size.get(&pool_id); rows.push(Row { region_id: region.id(), @@ -7700,19 +7698,18 @@ async fn cmd_db_zpool_list( bail!("no latest inventory found!"); }; - let mut zpool_total_size: HashMap = HashMap::new(); + let mut zpool_total_size: HashMap = HashMap::new(); for sled_agent in latest_collection.sled_agents { for zpool in sled_agent.zpools { - zpool_total_size - .insert(zpool.id.into_untyped_uuid(), zpool.total_size.into()); + zpool_total_size.insert(zpool.id, zpool.total_size.into()); } } #[derive(Tabled)] #[tabled(rename_all = "SCREAMING_SNAKE_CASE")] struct ZpoolRow { - id: Uuid, + id: ZpoolUuid, time_deleted: String, sled_id: SledUuid, physical_disk_id: PhysicalDiskUuid, @@ -7724,7 +7721,7 @@ async fn cmd_db_zpool_list( let rows: Vec = zpools .into_iter() .map(|(p, _)| { - let zpool_id = p.id().into_untyped_uuid(); + let zpool_id = p.id(); Ok(ZpoolRow { id: zpool_id, time_deleted: match p.time_deleted() { diff --git a/nexus/auth/src/authz/api_resources.rs b/nexus/auth/src/authz/api_resources.rs index bf6920cb3a3..94d0ee32231 100644 --- a/nexus/auth/src/authz/api_resources.rs +++ b/nexus/auth/src/authz/api_resources.rs @@ -1321,7 +1321,7 @@ authz_resource! { authz_resource! { name = "Zpool", parent = "Fleet", - primary_key = Uuid, + primary_key = { uuid_kind = ZpoolKind }, roles_allowed = false, polar_snippet = FleetChild, } diff --git a/nexus/db-lookup/src/lookup.rs b/nexus/db-lookup/src/lookup.rs index 783c0509c0d..4a949503cbd 100644 --- a/nexus/db-lookup/src/lookup.rs +++ b/nexus/db-lookup/src/lookup.rs @@ -289,7 +289,7 @@ impl<'a> LookupPath<'a> { } /// Select a resource of type Zpool, identified by its id - pub fn zpool_id(self, id: Uuid) -> Zpool<'a> { + pub fn zpool_id(self, id: ZpoolUuid) -> Zpool<'a> { Zpool::PrimaryKey(Root { lookup_root: self }, id) } @@ -782,7 +782,7 @@ lookup_resource! { ancestors = [], lookup_by_name = false, soft_deletes = true, - primary_key_columns = [ { column_name = "id", rust_type = Uuid } ] + primary_key_columns = [ { column_name = "id", uuid_kind = ZpoolKind } ] } lookup_resource! { diff --git a/nexus/db-model/src/crucible_dataset.rs b/nexus/db-model/src/crucible_dataset.rs index c4ceb38cc97..c4eb5a0da2c 100644 --- a/nexus/db-model/src/crucible_dataset.rs +++ b/nexus/db-model/src/crucible_dataset.rs @@ -5,9 +5,11 @@ use super::{Generation, Region, SqlU16}; use crate::collection::DatastoreCollectionConfig; use crate::ipv6; +use crate::typed_uuid::DbTypedUuid; use chrono::{DateTime, Utc}; use db_macros::Asset; use nexus_db_schema::schema::{crucible_dataset, region}; +use omicron_uuid_kinds::*; use serde::{Deserialize, Serialize}; use std::net::{Ipv6Addr, SocketAddrV6}; use uuid::Uuid; @@ -35,7 +37,7 @@ pub struct CrucibleDataset { time_deleted: Option>, rcgen: Generation, - pub pool_id: Uuid, + pub pool_id: DbTypedUuid, ip: ipv6::Ipv6Addr, port: SqlU16, @@ -50,14 +52,14 @@ pub struct CrucibleDataset { impl CrucibleDataset { pub fn new( id: omicron_uuid_kinds::DatasetUuid, - pool_id: Uuid, + pool_id: ZpoolUuid, addr: SocketAddrV6, ) -> Self { Self { identity: CrucibleDatasetIdentity::new(id), time_deleted: None, rcgen: Generation::new(), - pool_id, + pool_id: pool_id.into(), ip: addr.ip().into(), port: addr.port().into(), size_used: 0, @@ -80,6 +82,10 @@ impl CrucibleDataset { pub fn no_provision(&self) -> bool { self.no_provision } + + pub fn pool_id(&self) -> ZpoolUuid { + self.pool_id.into() + } } // Datasets contain regions diff --git a/nexus/db-model/src/inventory.rs b/nexus/db-model/src/inventory.rs index d05e8c0cb3a..d496deac679 100644 --- a/nexus/db-model/src/inventory.rs +++ b/nexus/db-model/src/inventory.rs @@ -80,7 +80,6 @@ use omicron_common::update::OmicronZoneManifestSource; use omicron_common::zpool_name::ZpoolName; use omicron_uuid_kinds::DatasetKind; use omicron_uuid_kinds::DatasetUuid; -use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::InternalZpoolKind; use omicron_uuid_kinds::MupdateKind; use omicron_uuid_kinds::MupdateOverrideKind; @@ -91,7 +90,6 @@ use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::SledKind; use omicron_uuid_kinds::SledUuid; use omicron_uuid_kinds::ZpoolKind; -use omicron_uuid_kinds::ZpoolUuid; use omicron_uuid_kinds::{CollectionKind, OmicronZoneKind}; use omicron_uuid_kinds::{CollectionUuid, OmicronZoneUuid}; use std::collections::BTreeSet; @@ -2036,7 +2034,7 @@ impl From pub struct InvZpool { pub inv_collection_id: DbTypedUuid, pub time_collected: DateTime, - pub id: Uuid, + pub id: DbTypedUuid, pub sled_id: DbTypedUuid, pub total_size: ByteCount, } @@ -2050,7 +2048,7 @@ impl InvZpool { Self { inv_collection_id: inv_collection_id.into(), time_collected: zpool.time_collected, - id: zpool.id.into_untyped_uuid(), + id: zpool.id.into(), sled_id: sled_id.into(), total_size: zpool.total_size.into(), } @@ -2061,7 +2059,7 @@ impl From for nexus_types::inventory::Zpool { fn from(pool: InvZpool) -> Self { Self { time_collected: pool.time_collected, - id: ZpoolUuid::from_untyped_uuid(pool.id), + id: pool.id.into(), total_size: *pool.total_size, } } diff --git a/nexus/db-model/src/zpool.rs b/nexus/db-model/src/zpool.rs index 4f69741b020..27403b6f64b 100644 --- a/nexus/db-model/src/zpool.rs +++ b/nexus/db-model/src/zpool.rs @@ -13,7 +13,8 @@ use omicron_uuid_kinds::PhysicalDiskKind; use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::SledKind; use omicron_uuid_kinds::SledUuid; -use uuid::Uuid; +use omicron_uuid_kinds::ZpoolKind; +use omicron_uuid_kinds::ZpoolUuid; /// Database representation of a Pool. /// @@ -21,6 +22,7 @@ use uuid::Uuid; /// physical sled. #[derive(Queryable, Insertable, Debug, Clone, Selectable, Asset)] #[diesel(table_name = zpool)] +#[asset(uuid_kind = ZpoolKind)] pub struct Zpool { #[diesel(embed)] identity: ZpoolIdentity, @@ -50,7 +52,7 @@ pub struct Zpool { impl Zpool { pub fn new( - id: Uuid, + id: ZpoolUuid, sled_id: SledUuid, physical_disk_id: PhysicalDiskUuid, control_plane_storage_buffer: ByteCount, @@ -83,7 +85,7 @@ impl Zpool { } impl DatastoreCollectionConfig for Zpool { - type CollectionId = Uuid; + type CollectionId = DbTypedUuid; type GenerationNumberColumn = zpool::dsl::rcgen; type CollectionTimeDeletedColumn = zpool::dsl::time_deleted; type CollectionIdColumn = crucible_dataset::dsl::pool_id; diff --git a/nexus/db-queries/src/db/datastore/crucible_dataset.rs b/nexus/db-queries/src/db/datastore/crucible_dataset.rs index 2c0bfde11da..f28bbca7bfb 100644 --- a/nexus/db-queries/src/db/datastore/crucible_dataset.rs +++ b/nexus/db-queries/src/db/datastore/crucible_dataset.rs @@ -78,9 +78,10 @@ impl DataStore { use nexus_db_schema::schema::crucible_dataset::dsl; let dataset_id = dataset.id(); - let zpool_id = dataset.pool_id; + let zpool_id = dataset.pool_id(); + Zpool::insert_resource( - zpool_id, + zpool_id.into(), diesel::insert_into(dsl::crucible_dataset) .values(dataset) .on_conflict(dsl::id) @@ -98,7 +99,7 @@ impl DataStore { AsyncInsertError::CollectionNotFound => { TransactionError::CustomError(Error::ObjectNotFound { type_name: ResourceType::Zpool, - lookup_type: LookupType::ById(zpool_id), + lookup_type: LookupType::by_id(zpool_id), }) } AsyncInsertError::DatabaseError(e) => { @@ -127,9 +128,10 @@ impl DataStore { ) -> CreateResult> { use nexus_db_schema::schema::crucible_dataset::dsl; - let zpool_id = dataset.pool_id; + let zpool_id = dataset.pool_id(); + Zpool::insert_resource( - zpool_id, + zpool_id.into(), diesel::insert_into(dsl::crucible_dataset) .values(dataset) .on_conflict(dsl::id) @@ -142,7 +144,7 @@ impl DataStore { .map_err(|e| match e { AsyncInsertError::CollectionNotFound => Error::ObjectNotFound { type_name: ResourceType::Zpool, - lookup_type: LookupType::ById(zpool_id), + lookup_type: LookupType::by_id(zpool_id), }, AsyncInsertError::DatabaseError(e) => { public_error_from_diesel(e, ErrorHandler::Server) @@ -224,7 +226,7 @@ impl DataStore { use nexus_db_schema::schema::zpool::dsl; dsl::zpool - .filter(dsl::id.eq(dataset.pool_id)) + .filter(dsl::id.eq(to_db_typed_uuid(dataset.pool_id()))) .select(Zpool::as_select()) .first_async::(&*conn) .await @@ -334,7 +336,7 @@ mod test { // Create a fake zpool that backs our fake datasets. let zpool_id = ZpoolUuid::new_v4(); let zpool = Zpool::new( - *zpool_id.as_untyped_uuid(), + zpool_id, sled_id, PhysicalDiskUuid::new_v4(), ByteCount::from(0).into(), @@ -366,7 +368,7 @@ mod test { let dataset1 = datastore .crucible_dataset_insert_if_not_exists(CrucibleDataset::new( DatasetUuid::new_v4(), - *zpool_id.as_untyped_uuid(), + zpool_id, "[::1]:0".parse().unwrap(), )) .await @@ -388,7 +390,7 @@ mod test { let insert_again_result = datastore .crucible_dataset_insert_if_not_exists(CrucibleDataset::new( dataset1.id(), - *zpool_id.as_untyped_uuid(), + zpool_id, "[::1]:12345".parse().unwrap(), )) .await @@ -403,7 +405,7 @@ mod test { let dataset2 = datastore .crucible_dataset_upsert(CrucibleDataset::new( DatasetUuid::new_v4(), - *zpool_id.as_untyped_uuid(), + zpool_id, "[::1]:0".parse().unwrap(), )) .await @@ -420,7 +422,7 @@ mod test { let insert_again_result = datastore .crucible_dataset_insert_if_not_exists(CrucibleDataset::new( dataset1.id(), - *zpool_id.as_untyped_uuid(), + zpool_id, "[::1]:12345".parse().unwrap(), )) .await diff --git a/nexus/db-queries/src/db/datastore/mod.rs b/nexus/db-queries/src/db/datastore/mod.rs index d86e44b327c..7035e9793b8 100644 --- a/nexus/db-queries/src/db/datastore/mod.rs +++ b/nexus/db-queries/src/db/datastore/mod.rs @@ -529,6 +529,7 @@ mod test { use omicron_uuid_kinds::SiloUserUuid; use omicron_uuid_kinds::SledUuid; use omicron_uuid_kinds::VolumeUuid; + use omicron_uuid_kinds::ZpoolUuid; use std::collections::HashMap; use std::collections::HashSet; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddrV6}; @@ -783,7 +784,7 @@ mod test { opctx: &OpContext, sled_id: SledUuid, physical_disk_id: PhysicalDiskUuid, - ) -> Uuid { + ) -> ZpoolUuid { let zpool_id = create_test_zpool_not_in_inventory( datastore, opctx, @@ -805,8 +806,8 @@ mod test { opctx: &OpContext, sled_id: SledUuid, physical_disk_id: PhysicalDiskUuid, - ) -> Uuid { - let zpool_id = Uuid::new_v4(); + ) -> ZpoolUuid { + let zpool_id = ZpoolUuid::new_v4(); let zpool = Zpool::new( zpool_id, sled_id, @@ -821,7 +822,7 @@ mod test { // collection UUID. async fn add_test_zpool_to_inventory( datastore: &DataStore, - zpool_id: Uuid, + zpool_id: ZpoolUuid, sled_id: SledUuid, ) { use nexus_db_schema::schema::inv_zpool::dsl; @@ -831,7 +832,7 @@ mod test { let inv_pool = nexus_db_model::InvZpool { inv_collection_id: inv_collection_id.into(), time_collected, - id: zpool_id, + id: zpool_id.into(), sled_id: to_db_typed_uuid(sled_id), total_size: test_zpool_size().into(), }; @@ -983,7 +984,7 @@ mod test { #[derive(Copy, Clone)] struct Zpool { sled_id: SledUuid, - pool_id: Uuid, + pool_id: ZpoolUuid, } // 1 pool per disk @@ -1119,7 +1120,7 @@ mod test { } // Must be 3 unique zpools - assert!(disk_zpools.insert(dataset.pool_id)); + assert!(disk_zpools.insert(dataset.pool_id())); assert_eq!(volume_id, region.volume_id()); assert_eq!(ByteCount::from(4096), region.block_size()); @@ -1201,7 +1202,7 @@ mod test { } // Must be 3 unique zpools - assert!(disk_zpools.insert(dataset.pool_id)); + assert!(disk_zpools.insert(dataset.pool_id())); // Must be 3 unique sleds let sled_id = test_datasets @@ -1368,17 +1369,18 @@ mod test { .await; // Create enough zpools for region allocation to succeed - let zpool_ids: Vec = stream::iter(0..REGION_REDUNDANCY_THRESHOLD) - .then(|_| { - create_test_zpool_not_in_inventory( - &datastore, - &opctx, - sled_id, - physical_disk_id, - ) - }) - .collect() - .await; + let zpool_ids: Vec = + stream::iter(0..REGION_REDUNDANCY_THRESHOLD) + .then(|_| { + create_test_zpool_not_in_inventory( + &datastore, + &opctx, + sled_id, + physical_disk_id, + ) + }) + .collect() + .await; let bogus_addr = SocketAddrV6::new(Ipv6Addr::LOCALHOST, 8080, 0, 0); @@ -1461,7 +1463,7 @@ mod test { .await; // 1 less than REDUNDANCY level of zpools - let zpool_ids: Vec = + let zpool_ids: Vec = stream::iter(0..REGION_REDUNDANCY_THRESHOLD - 1) .then(|_| { create_test_zpool( diff --git a/nexus/db-queries/src/db/datastore/physical_disk.rs b/nexus/db-queries/src/db/datastore/physical_disk.rs index dd12741b2a8..234575bf547 100644 --- a/nexus/db-queries/src/db/datastore/physical_disk.rs +++ b/nexus/db-queries/src/db/datastore/physical_disk.rs @@ -347,6 +347,7 @@ mod test { use omicron_common::api::external::ByteCount; use omicron_common::disk::{DiskIdentity, DiskVariant}; use omicron_test_utils::dev; + use omicron_uuid_kinds::ZpoolUuid; use std::num::NonZeroU32; async fn create_test_sled(db: &DataStore) -> Sled { @@ -769,7 +770,7 @@ mod test { ); let zpool = Zpool::new( - Uuid::new_v4(), + ZpoolUuid::new_v4(), sled_id, disk.id(), ByteCount::from(0).into(), diff --git a/nexus/db-queries/src/db/datastore/rack.rs b/nexus/db-queries/src/db/datastore/rack.rs index 79b4d01e00a..1d27453f75a 100644 --- a/nexus/db-queries/src/db/datastore/rack.rs +++ b/nexus/db-queries/src/db/datastore/rack.rs @@ -71,6 +71,7 @@ use omicron_common::bail_unless; use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::SiloUserUuid; use omicron_uuid_kinds::SledUuid; +use omicron_uuid_kinds::ZpoolUuid; use slog_error_chain::InlineErrorChain; use std::sync::{Arc, OnceLock}; use uuid::Uuid; @@ -104,7 +105,7 @@ enum RackInitError { BlueprintInsert(Error), BlueprintTargetSet(Error), NexusDatabaseAccessRecordsInsert(Error), - DatasetInsert { err: AsyncInsertError, zpool_id: Uuid }, + DatasetInsert { err: AsyncInsertError, zpool_id: ZpoolUuid }, PhysicalDiskInsert(Error), ZpoolInsert(Error), RackUpdate { err: DieselError, rack_id: Uuid }, @@ -135,7 +136,7 @@ impl From for Error { RackInitError::DatasetInsert { err, zpool_id } => match err { AsyncInsertError::CollectionNotFound => Error::ObjectNotFound { type_name: ResourceType::Zpool, - lookup_type: LookupType::ById(zpool_id), + lookup_type: LookupType::by_id(zpool_id), }, AsyncInsertError::DatabaseError(e) => { public_error_from_diesel(e, ErrorHandler::Server) @@ -861,9 +862,9 @@ impl DataStore { for dataset in datasets { use nexus_db_schema::schema::crucible_dataset::dsl; - let zpool_id = dataset.pool_id; + let zpool_id = dataset.pool_id(); Zpool::insert_resource( - zpool_id, + zpool_id.into(), diesel::insert_into(dsl::crucible_dataset) .values(dataset.clone()) .on_conflict(dsl::id) diff --git a/nexus/db-queries/src/db/datastore/support_bundle.rs b/nexus/db-queries/src/db/datastore/support_bundle.rs index 26eb7e3d32e..70894aa401d 100644 --- a/nexus/db-queries/src/db/datastore/support_bundle.rs +++ b/nexus/db-queries/src/db/datastore/support_bundle.rs @@ -628,7 +628,7 @@ mod test { // Create fake zpools that back our fake datasets. for pool in &self.pools { let zpool = Zpool::new( - *pool.pool.as_untyped_uuid(), + pool.pool, self.sled, PhysicalDiskUuid::new_v4(), ByteCount::from(0).into(), diff --git a/nexus/db-queries/src/db/datastore/zpool.rs b/nexus/db-queries/src/db/datastore/zpool.rs index c3254fa57e2..af9e716bf56 100644 --- a/nexus/db-queries/src/db/datastore/zpool.rs +++ b/nexus/db-queries/src/db/datastore/zpool.rs @@ -11,6 +11,7 @@ use crate::db::collection_insert::AsyncInsertError; use crate::db::collection_insert::DatastoreCollection; use crate::db::datastore::OpContext; use crate::db::identity::Asset; +use crate::db::model::DbTypedUuid; use crate::db::model::PhysicalDisk; use crate::db::model::PhysicalDiskPolicy; use crate::db::model::PhysicalDiskState; @@ -38,6 +39,7 @@ use omicron_common::api::external::LookupType; use omicron_common::api::external::ResourceType; use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::SledUuid; +use omicron_uuid_kinds::ZpoolKind; use omicron_uuid_kinds::ZpoolUuid; use uuid::Uuid; @@ -98,7 +100,7 @@ impl DataStore { async fn zpool_list_all_external( &self, opctx: &OpContext, - pagparams: &DataPageParams<'_, Uuid>, + pagparams: &DataPageParams<'_, DbTypedUuid>, ) -> ListResultVec<(Zpool, PhysicalDisk)> { opctx.authorize(authz::Action::ListChildren, &authz::FLEET).await?; @@ -140,7 +142,7 @@ impl DataStore { let batch = self .zpool_list_all_external(opctx, &p.current_pagparams()) .await?; - paginator = p.found_batch(&batch, &|(z, _)| z.id()); + paginator = p.found_batch(&batch, &|(z, _)| z.id().into()); zpools.extend(batch); } @@ -151,7 +153,7 @@ impl DataStore { pub async fn zpool_on_decommissioned_disk_list( &self, opctx: &OpContext, - pagparams: &DataPageParams<'_, Uuid>, + pagparams: &DataPageParams<'_, DbTypedUuid>, ) -> ListResultVec { opctx.authorize(authz::Action::Read, &authz::FLEET).await?; use nexus_db_schema::schema::physical_disk::dsl as physical_disk_dsl; diff --git a/nexus/db-queries/src/policy_test/resources.rs b/nexus/db-queries/src/policy_test/resources.rs index 6c6fa557af4..dc88e0498ba 100644 --- a/nexus/db-queries/src/policy_test/resources.rs +++ b/nexus/db-queries/src/policy_test/resources.rs @@ -105,7 +105,7 @@ pub async fn make_resources( builder.new_resource(authz::Zpool::new( authz::FLEET, zpool_id, - LookupType::ById(zpool_id), + LookupType::by_id(zpool_id), )); make_services(&mut builder).await; diff --git a/nexus/reconfigurator/execution/src/omicron_physical_disks.rs b/nexus/reconfigurator/execution/src/omicron_physical_disks.rs index 42d887b436c..7da3fd8fb19 100644 --- a/nexus/reconfigurator/execution/src/omicron_physical_disks.rs +++ b/nexus/reconfigurator/execution/src/omicron_physical_disks.rs @@ -134,7 +134,7 @@ mod test { .zpool_insert( opctx, Zpool::new( - Uuid::new_v4(), + ZpoolUuid::new_v4(), sled_id, id, ByteCount::from(0).into(), diff --git a/nexus/reconfigurator/preparation/src/lib.rs b/nexus/reconfigurator/preparation/src/lib.rs index e9defce9fbd..77670f7e1fc 100644 --- a/nexus/reconfigurator/preparation/src/lib.rs +++ b/nexus/reconfigurator/preparation/src/lib.rs @@ -53,7 +53,6 @@ use omicron_common::policy::NEXUS_REDUNDANCY; use omicron_common::policy::OXIMETER_REDUNDANCY; use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::OmicronZoneUuid; -use omicron_uuid_kinds::ZpoolUuid; use slog::Logger; use slog::error; use slog_error_chain::InlineErrorChain; @@ -264,7 +263,6 @@ impl PlanningInputFromDb<'_> { for (zpool, disk) in self.zpool_rows { let sled_zpool_names = zpools.entry(zpool.sled_id()).or_insert_with(BTreeMap::new); - let zpool_id = ZpoolUuid::from_untyped_uuid(zpool.id()); let disk = SledDisk { disk_identity: DiskIdentity { vendor: disk.vendor.clone(), @@ -275,7 +273,7 @@ impl PlanningInputFromDb<'_> { policy: disk.disk_policy.into(), state: disk.disk_state.into(), }; - sled_zpool_names.insert(zpool_id, disk); + sled_zpool_names.insert(zpool.id(), disk); } zpools }; diff --git a/nexus/reconfigurator/rendezvous/src/crucible_dataset.rs b/nexus/reconfigurator/rendezvous/src/crucible_dataset.rs index 0e36564ae27..cf828d6e1f7 100644 --- a/nexus/reconfigurator/rendezvous/src/crucible_dataset.rs +++ b/nexus/reconfigurator/rendezvous/src/crucible_dataset.rs @@ -15,7 +15,6 @@ use nexus_types::identity::Asset; use nexus_types::internal_api::background::CrucibleDatasetsRendezvousStats; use omicron_common::api::internal::shared::DatasetKind; use omicron_uuid_kinds::DatasetUuid; -use omicron_uuid_kinds::GenericUuid as _; use slog::info; use std::collections::BTreeMap; use std::collections::BTreeSet; @@ -49,11 +48,9 @@ pub(crate) async fn record_new_crucible_datasets( for bp_dataset in blueprint_datasets { // Filter down to Crucible datasets... let dataset = match (&bp_dataset.kind, bp_dataset.address) { - (DatasetKind::Crucible, Some(addr)) => CrucibleDataset::new( - bp_dataset.id, - bp_dataset.pool.id().into_untyped_uuid(), - addr, - ), + (DatasetKind::Crucible, Some(addr)) => { + CrucibleDataset::new(bp_dataset.id, bp_dataset.pool.id(), addr) + } (DatasetKind::Crucible, None) => { // This should be impossible! Ideally we'd prevent it // statically, but for now just fail at runtime. @@ -140,7 +137,7 @@ mod tests { use omicron_common::api::external::ByteCount; use omicron_common::disk::CompressionAlgorithm; use omicron_test_utils::dev; - use omicron_uuid_kinds::GenericUuid; + use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::SledUuid; use omicron_uuid_kinds::ZpoolUuid; @@ -213,7 +210,7 @@ mod tests { .zpool_insert( opctx, Zpool::new( - zpool_id.into_untyped_uuid(), + zpool_id, sled_id, disk_id, ByteCount::from(0).into(), @@ -244,7 +241,7 @@ mod tests { .crucible_dataset_insert_if_not_exists( CrucibleDataset::new( d.id, - d.pool.id().into_untyped_uuid(), + d.pool.id(), d.address.unwrap(), ), ) diff --git a/nexus/src/app/background/tasks/blueprint_execution.rs b/nexus/src/app/background/tasks/blueprint_execution.rs index 3588fc3fa42..ad3e4f18204 100644 --- a/nexus/src/app/background/tasks/blueprint_execution.rs +++ b/nexus/src/app/background/tasks/blueprint_execution.rs @@ -254,7 +254,7 @@ mod test { use omicron_common::api::external::Generation; use omicron_common::zpool_name::ZpoolName; use omicron_uuid_kinds::BlueprintUuid; - use omicron_uuid_kinds::GenericUuid; + use omicron_uuid_kinds::OmicronZoneUuid; use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::SledUuid; @@ -525,7 +525,7 @@ mod test { let pool_id = dataset.dataset.pool_name.id(); let zpool = Zpool::new( - pool_id.into_untyped_uuid(), + pool_id, sled_id, PhysicalDiskUuid::new_v4(), external::ByteCount::from(0).into(), diff --git a/nexus/src/app/background/tasks/decommissioned_disk_cleaner.rs b/nexus/src/app/background/tasks/decommissioned_disk_cleaner.rs index 559b2eefaa9..e2aca0a6d1f 100644 --- a/nexus/src/app/background/tasks/decommissioned_disk_cleaner.rs +++ b/nexus/src/app/background/tasks/decommissioned_disk_cleaner.rs @@ -20,7 +20,6 @@ use nexus_db_queries::db::DataStore; use nexus_db_queries::db::pagination::Paginator; use nexus_types::identity::Asset; use omicron_common::api::external::Error; -use omicron_uuid_kinds::{GenericUuid, ZpoolUuid}; use std::num::NonZeroU32; use std::sync::Arc; @@ -64,7 +63,7 @@ impl DecommissionedDiskCleaner { ) .await .context("failed to list zpools on decommissioned disks")?; - paginator = p.found_batch(&zpools, &|zpool| zpool.id()); + paginator = p.found_batch(&zpools, &|zpool| zpool.id().into()); self.clean_batch(results, &mut last_err, opctx, &zpools).await; } @@ -82,7 +81,7 @@ impl DecommissionedDiskCleaner { slog::debug!(opctx.log, "Found zpools on decommissioned disks"; "count" => zpools.len()); for zpool in zpools { - let zpool_id = ZpoolUuid::from_untyped_uuid(zpool.id()); + let zpool_id = zpool.id(); slog::trace!(opctx.log, "Deleting Zpool"; "zpool" => %zpool_id); match self @@ -185,10 +184,10 @@ mod tests { use nexus_test_utils_macros::nexus_test; use omicron_common::api::external::ByteCount; use omicron_uuid_kinds::{ - DatasetUuid, PhysicalDiskUuid, RegionUuid, SledUuid, VolumeUuid, + DatasetUuid, GenericUuid, PhysicalDiskUuid, RegionUuid, SledUuid, + VolumeUuid, ZpoolUuid, }; use std::str::FromStr; - use uuid::Uuid; type ControlPlaneTestContext = nexus_test_utils::ControlPlaneTestContext; @@ -225,7 +224,7 @@ mod tests { .zpool_insert( opctx, Zpool::new( - Uuid::new_v4(), + ZpoolUuid::new_v4(), sled_id, id, ByteCount::from(0).into(), @@ -271,11 +270,7 @@ mod tests { .await .unwrap(); - ( - ZpoolUuid::from_untyped_uuid(zpool.id()), - dataset.id(), - RegionUuid::from_untyped_uuid(region_id), - ) + (zpool.id(), dataset.id(), RegionUuid::from_untyped_uuid(region_id)) } struct TestFixture { diff --git a/nexus/src/app/background/tasks/physical_disk_adoption.rs b/nexus/src/app/background/tasks/physical_disk_adoption.rs index 6ae03dc685a..55ad811a717 100644 --- a/nexus/src/app/background/tasks/physical_disk_adoption.rs +++ b/nexus/src/app/background/tasks/physical_disk_adoption.rs @@ -23,6 +23,7 @@ use nexus_types::identity::Asset; use omicron_common::api::external::DataPageParams; use omicron_uuid_kinds::CollectionUuid; use omicron_uuid_kinds::PhysicalDiskUuid; +use omicron_uuid_kinds::ZpoolUuid; use serde_json::json; use std::sync::Arc; use tokio::sync::watch; @@ -136,7 +137,7 @@ impl BackgroundTask for PhysicalDiskAdoption { ); let zpool = Zpool::new( - Uuid::new_v4(), + ZpoolUuid::new_v4(), inv_disk.sled_id.into(), disk.id(), CONTROL_PLANE_STORAGE_BUFFER.into(), diff --git a/nexus/src/app/background/tasks/read_only_region_replacement_start.rs b/nexus/src/app/background/tasks/read_only_region_replacement_start.rs index fa5d983da97..1ffc4e55c43 100644 --- a/nexus/src/app/background/tasks/read_only_region_replacement_start.rs +++ b/nexus/src/app/background/tasks/read_only_region_replacement_start.rs @@ -180,7 +180,7 @@ mod test { use nexus_test_utils_macros::nexus_test; use omicron_common::api::external; use omicron_uuid_kinds::DatasetUuid; - use omicron_uuid_kinds::GenericUuid; + use omicron_uuid_kinds::VolumeUuid; use omicron_uuid_kinds::ZpoolUuid; use sled_agent_client::VolumeConstructionRequest; @@ -316,7 +316,7 @@ mod test { disk_test.zpools().next().expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(first_zpool.id.into_untyped_uuid()) + .zpool_id(first_zpool.id) .fetch() .await .unwrap(); diff --git a/nexus/src/app/background/tasks/region_snapshot_replacement_start.rs b/nexus/src/app/background/tasks/region_snapshot_replacement_start.rs index 042a8b47544..7438a5429f0 100644 --- a/nexus/src/app/background/tasks/region_snapshot_replacement_start.rs +++ b/nexus/src/app/background/tasks/region_snapshot_replacement_start.rs @@ -333,7 +333,7 @@ mod test { use nexus_test_utils_macros::nexus_test; use omicron_common::api::external; use omicron_uuid_kinds::DatasetUuid; - use omicron_uuid_kinds::GenericUuid; + use omicron_uuid_kinds::VolumeUuid; use sled_agent_client::CrucibleOpts; use sled_agent_client::VolumeConstructionRequest; @@ -537,7 +537,7 @@ mod test { disk_test.zpools().next().expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(first_zpool.id.into_untyped_uuid()) + .zpool_id(first_zpool.id) .fetch() .await .unwrap(); diff --git a/nexus/src/app/background/tasks/support_bundle_collector.rs b/nexus/src/app/background/tasks/support_bundle_collector.rs index 17b6a4cd0cf..e1ebc02e95f 100644 --- a/nexus/src/app/background/tasks/support_bundle_collector.rs +++ b/nexus/src/app/background/tasks/support_bundle_collector.rs @@ -1568,7 +1568,7 @@ mod test { .zpool_insert( opctx, Zpool::new( - Uuid::new_v4(), + ZpoolUuid::new_v4(), sled_id, id, ByteCount::from(0).into(), @@ -1576,21 +1576,20 @@ mod test { ) .await .unwrap(); - let zpool_id = ZpoolUuid::from_untyped_uuid(zpool.id()); let dataset = datastore .debug_dataset_insert_if_not_exists( opctx, RendezvousDebugDataset::new( DatasetUuid::new_v4(), - zpool_id, + zpool.id(), blueprint_id, ), ) .await .unwrap() .expect("inserted new dataset"); - (zpool_id, dataset.id()) + (zpool.id(), dataset.id()) } async fn make_disk_in_db( diff --git a/nexus/src/app/rack.rs b/nexus/src/app/rack.rs index b1b253cc3a2..471dbf585c8 100644 --- a/nexus/src/app/rack.rs +++ b/nexus/src/app/rack.rs @@ -60,7 +60,6 @@ use omicron_common::api::external::NameOrId; use omicron_common::api::external::ResourceType; use omicron_common::api::internal::shared::ExternalPortDiscovery; use omicron_common::api::internal::shared::LldpAdminStatus; -use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::SledUuid; use oxnet::IpNet; use sled_agent_client::types::AddSledRequest; @@ -145,7 +144,7 @@ impl super::Nexus { .map(|dataset| { db::model::CrucibleDataset::new( dataset.dataset_id, - dataset.zpool_id.into_untyped_uuid(), + dataset.zpool_id, dataset.address, ) }) diff --git a/nexus/src/app/sagas/region_replacement_start.rs b/nexus/src/app/sagas/region_replacement_start.rs index 2a5bdefe030..eb7701c96e5 100644 --- a/nexus/src/app/sagas/region_replacement_start.rs +++ b/nexus/src/app/sagas/region_replacement_start.rs @@ -785,6 +785,7 @@ pub(crate) mod test { use nexus_types::identity::Asset; use omicron_uuid_kinds::DatasetUuid; use omicron_uuid_kinds::VolumeUuid; + use omicron_uuid_kinds::ZpoolUuid; use sled_agent_client::VolumeConstructionRequest; use uuid::Uuid; @@ -900,22 +901,22 @@ pub(crate) mod test { let datasets = vec![ CrucibleDataset::new( DatasetUuid::new_v4(), - Uuid::new_v4(), + ZpoolUuid::new_v4(), "[fd00:1122:3344:101::1]:12345".parse().unwrap(), ), CrucibleDataset::new( DatasetUuid::new_v4(), - Uuid::new_v4(), + ZpoolUuid::new_v4(), "[fd00:1122:3344:102::1]:12345".parse().unwrap(), ), CrucibleDataset::new( DatasetUuid::new_v4(), - Uuid::new_v4(), + ZpoolUuid::new_v4(), "[fd00:1122:3344:103::1]:12345".parse().unwrap(), ), CrucibleDataset::new( DatasetUuid::new_v4(), - Uuid::new_v4(), + ZpoolUuid::new_v4(), "[fd00:1122:3344:104::1]:12345".parse().unwrap(), ), ]; diff --git a/nexus/src/app/sagas/region_snapshot_replacement_start.rs b/nexus/src/app/sagas/region_snapshot_replacement_start.rs index 760a76fbaec..c047b56479d 100644 --- a/nexus/src/app/sagas/region_snapshot_replacement_start.rs +++ b/nexus/src/app/sagas/region_snapshot_replacement_start.rs @@ -1238,7 +1238,7 @@ pub(crate) mod test { use nexus_test_utils_macros::nexus_test; use nexus_types::external_api::views; use nexus_types::identity::Asset; - use omicron_uuid_kinds::GenericUuid; + use sled_agent_client::VolumeConstructionRequest; type ControlPlaneTestContext = @@ -1883,11 +1883,11 @@ pub(crate) mod test { let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -2041,11 +2041,11 @@ pub(crate) mod test { let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); diff --git a/nexus/src/app/sled.rs b/nexus/src/app/sled.rs index 4023ad4fa00..4812c698225 100644 --- a/nexus/src/app/sled.rs +++ b/nexus/src/app/sled.rs @@ -30,6 +30,7 @@ use omicron_uuid_kinds::InstanceUuid; use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::PropolisUuid; use omicron_uuid_kinds::SledUuid; +use omicron_uuid_kinds::ZpoolUuid; use sled_agent_client::Client as SledAgentClient; use std::net::SocketAddrV6; use std::sync::Arc; @@ -359,7 +360,7 @@ impl super::Nexus { pub(crate) async fn upsert_crucible_dataset( &self, id: DatasetUuid, - zpool_id: Uuid, + zpool_id: ZpoolUuid, address: SocketAddrV6, ) -> Result<(), Error> { info!( diff --git a/nexus/src/lib.rs b/nexus/src/lib.rs index 8abfc353e32..f6e59d1a4de 100644 --- a/nexus/src/lib.rs +++ b/nexus/src/lib.rs @@ -46,8 +46,6 @@ use omicron_common::api::internal::shared::{ use omicron_common::disk::DatasetKind; use omicron_uuid_kinds::BlueprintUuid; use omicron_uuid_kinds::DatasetUuid; -use omicron_uuid_kinds::GenericUuid as _; -use omicron_uuid_kinds::ZpoolUuid; use oximeter::types::ProducerRegistry; use oximeter_producer::Server as ProducerServer; use slog::Logger; @@ -412,7 +410,7 @@ impl nexus_test_interface::NexusServer for Server { &opctx, RendezvousDebugDataset::new( dataset_id, - ZpoolUuid::from_untyped_uuid(zpool_id), + zpool_id, BlueprintUuid::new_v4(), ), ) diff --git a/nexus/test-utils/src/resource_helpers.rs b/nexus/test-utils/src/resource_helpers.rs index 4d55db45c19..96f2b79a01b 100644 --- a/nexus/test-utils/src/resource_helpers.rs +++ b/nexus/test-utils/src/resource_helpers.rs @@ -63,7 +63,6 @@ use omicron_sled_agent::sim::SledAgent; use omicron_test_utils::dev::poll::CondCheckError; use omicron_test_utils::dev::poll::wait_for_condition; use omicron_uuid_kinds::DatasetUuid; -use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::SiloUserUuid; use omicron_uuid_kinds::SledUuid; @@ -1569,7 +1568,7 @@ impl<'a, N: NexusServer> DiskTest<'a, N> { let zpool_request = nexus_types::internal_api::params::ZpoolPutRequest { - id: zpool.id.into_untyped_uuid(), + id: zpool.id, physical_disk_id, sled_id, }; @@ -1772,9 +1771,9 @@ impl<'a, N: NexusServer> DiskTest<'a, N> { /// _not_ clean up crucible resources on an expunged disk (due to the "gone" /// check that it performs), but it's useful for tests to be able to assert /// all crucible resources are cleaned up. - pub async fn remove_zpool(&mut self, zpool_id: Uuid) { + pub async fn remove_zpool(&mut self, zpool_id: ZpoolUuid) { for sled in self.sleds.values_mut() { - sled.zpools.retain(|zpool| *zpool.id.as_untyped_uuid() != zpool_id); + sled.zpools.retain(|zpool| zpool.id != zpool_id); } } } diff --git a/nexus/tests/integration_tests/crucible_replacements.rs b/nexus/tests/integration_tests/crucible_replacements.rs index 4fe8db5e361..8e17d851992 100644 --- a/nexus/tests/integration_tests/crucible_replacements.rs +++ b/nexus/tests/integration_tests/crucible_replacements.rs @@ -37,7 +37,6 @@ use nexus_types::internal_api::background::*; use omicron_common::api::external; use omicron_common::api::external::IdentityMetadataCreateParams; use omicron_test_utils::dev::poll::{CondCheckError, wait_for_condition}; -use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::VolumeUuid; use slog::Logger; use slog::info; @@ -251,11 +250,11 @@ async fn test_region_replacement_does_not_create_freed_region( let (dataset, _) = &disk_allocated_regions[0]; let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -783,11 +782,11 @@ async fn test_racing_replacements_for_soft_deleted_disk_volume( let (dataset, region) = &disk_allocated_regions[0]; let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -2016,11 +2015,11 @@ async fn test_replacement_sanity(cptestctx: &ControlPlaneTestContext) { let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -2138,11 +2137,11 @@ async fn test_region_replacement_triple_sanity( let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -2265,11 +2264,11 @@ async fn test_region_replacement_triple_sanity_2( let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -2297,11 +2296,11 @@ async fn test_region_replacement_triple_sanity_2( let zpool = disk_test .zpools() - .find(|x| *x.id.as_untyped_uuid() == dataset.pool_id) + .find(|x| x.id == dataset.pool_id()) .expect("Expected at least one zpool"); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); @@ -2556,7 +2555,7 @@ async fn test_read_only_replacement_sanity( assert!(region.read_only()); let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(dataset.pool_id.into_untyped_uuid()) + .zpool_id(dataset.pool_id()) .fetch() .await .unwrap(); diff --git a/nexus/tests/integration_tests/disks.rs b/nexus/tests/integration_tests/disks.rs index 03ee3c841b1..483b000f957 100644 --- a/nexus/tests/integration_tests/disks.rs +++ b/nexus/tests/integration_tests/disks.rs @@ -41,8 +41,10 @@ use omicron_common::api::external::NameOrId; use omicron_nexus::Nexus; use omicron_nexus::TestInterfaces as _; use omicron_nexus::app::{MAX_DISK_SIZE_BYTES, MIN_DISK_SIZE_BYTES}; +use omicron_uuid_kinds::GenericUuid; +use omicron_uuid_kinds::InstanceUuid; use omicron_uuid_kinds::VolumeUuid; -use omicron_uuid_kinds::{GenericUuid, InstanceUuid}; +use omicron_uuid_kinds::ZpoolUuid; use sled_agent_client::TestInterfaces as _; use std::collections::HashSet; use std::sync::Arc; @@ -2137,9 +2139,9 @@ async fn test_single_region_allocate_for_replace( assert_eq!(allocated_regions.len(), one_more); // Each region should be on a different pool - let pools_used: HashSet = datasets_and_regions + let pools_used: HashSet = datasets_and_regions .iter() - .map(|(dataset, _)| dataset.pool_id) + .map(|(dataset, _)| dataset.pool_id()) .collect(); assert_eq!(pools_used.len(), REGION_REDUNDANCY_THRESHOLD + 1); @@ -2291,7 +2293,7 @@ async fn test_no_halt_disk_delete_one_region_on_expunged_agent( // Expunge the physical disk let (_, db_zpool) = LookupPath::new(&opctx, datastore) - .zpool_id(zpool.id.into_untyped_uuid()) + .zpool_id(zpool.id) .fetch() .await .unwrap(); diff --git a/nexus/tests/integration_tests/volume_management.rs b/nexus/tests/integration_tests/volume_management.rs index b524e33c250..6da752f7e71 100644 --- a/nexus/tests/integration_tests/volume_management.rs +++ b/nexus/tests/integration_tests/volume_management.rs @@ -69,7 +69,6 @@ use omicron_uuid_kinds::UpstairsRepairUuid; use omicron_uuid_kinds::UpstairsSessionUuid; use omicron_uuid_kinds::UpstairsUuid; use omicron_uuid_kinds::VolumeUuid; -use omicron_uuid_kinds::ZpoolUuid; use rand::prelude::SliceRandom; use rand::{SeedableRng, rngs::StdRng}; use sled_agent_client::{CrucibleOpts, VolumeConstructionRequest}; @@ -4212,8 +4211,7 @@ async fn test_read_only_region_reference_counting( let mut region_still_state_crated = false; for sled_agent in cptestctx.all_sled_agents() { - let zpool_id = - ZpoolUuid::from_untyped_uuid(db_read_only_dataset.pool_id); + let zpool_id = db_read_only_dataset.pool_id(); if !sled_agent.sled_agent.has_zpool(zpool_id) { continue; } @@ -4296,8 +4294,7 @@ async fn test_read_only_region_reference_counting( let mut region_destroyed = false; for sled_agent in cptestctx.all_sled_agents() { - let zpool_id = - ZpoolUuid::from_untyped_uuid(db_read_only_dataset.pool_id); + let zpool_id = db_read_only_dataset.pool_id(); if !sled_agent.sled_agent.has_zpool(zpool_id) { continue; } diff --git a/nexus/types/src/internal_api/params.rs b/nexus/types/src/internal_api/params.rs index ef32e7311f7..8f39354affb 100644 --- a/nexus/types/src/internal_api/params.rs +++ b/nexus/types/src/internal_api/params.rs @@ -96,7 +96,8 @@ pub struct PhysicalDiskPutRequest { /// plane. #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct ZpoolPutRequest { - pub id: Uuid, + #[schemars(with = "Uuid")] + pub id: ZpoolUuid, #[schemars(with = "Uuid")] pub sled_id: SledUuid,