Skip to content

Commit bac635f

Browse files
authored
[nexus/sled-agent] update Uuid -> OmicronZoneUuid in more places (#6546)
Noticed this while working on nearby code.
1 parent a692ea5 commit bac635f

File tree

28 files changed

+123
-80
lines changed

28 files changed

+123
-80
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/sled-agent-client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ progenitor::generate_api!(
7272
SwitchLocation = omicron_common::api::external::SwitchLocation,
7373
TypedUuidForDatasetKind = omicron_uuid_kinds::DatasetUuid,
7474
TypedUuidForInstanceKind = omicron_uuid_kinds::InstanceUuid,
75+
TypedUuidForOmicronZoneKind = omicron_uuid_kinds::OmicronZoneUuid,
7576
TypedUuidForPropolisKind = omicron_uuid_kinds::PropolisUuid,
7677
TypedUuidForZpoolKind = omicron_uuid_kinds::ZpoolUuid,
7778
Vni = omicron_common::api::external::Vni,

nexus-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ anyhow.workspace = true
1111
camino.workspace = true
1212
dropshot.workspace = true
1313
omicron-common.workspace = true
14+
omicron-uuid-kinds.workspace = true
1415
omicron-workspace-hack.workspace = true
1516
schemars.workspace = true
1617
serde.workspace = true

nexus-config/src/nexus_config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use omicron_common::address::Ipv6Subnet;
1414
use omicron_common::address::NEXUS_TECHPORT_EXTERNAL_PORT;
1515
use omicron_common::address::RACK_PREFIX;
1616
use omicron_common::api::internal::shared::SwitchLocation;
17+
use omicron_uuid_kinds::OmicronZoneUuid;
1718
use schemars::JsonSchema;
1819
use serde::{Deserialize, Serialize};
1920
use serde_with::serde_as;
@@ -150,7 +151,7 @@ pub enum InternalDns {
150151
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
151152
pub struct DeploymentConfig {
152153
/// Uuid of the Nexus instance
153-
pub id: Uuid,
154+
pub id: OmicronZoneUuid,
154155
/// Uuid of the Rack where Nexus is executing.
155156
pub rack_id: Uuid,
156157
/// Port on which the "techport external" dropshot server should listen.

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use omicron_common::{
1414
disk::DiskVariant,
1515
zpool_name::ZpoolName,
1616
};
17-
use omicron_uuid_kinds::DatasetUuid;
1817
use omicron_uuid_kinds::ZpoolUuid;
18+
use omicron_uuid_kinds::{DatasetUuid, OmicronZoneUuid};
1919
use schemars::JsonSchema;
2020
use serde::{Deserialize, Serialize};
2121
// Export this type for convenience -- this way, dependents don't have to
@@ -142,7 +142,7 @@ impl OmicronZonesConfig {
142142
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
143143
)]
144144
pub struct OmicronZoneConfig {
145-
pub id: Uuid,
145+
pub id: OmicronZoneUuid,
146146
pub underlay_address: Ipv6Addr,
147147

148148
/// The pool on which we'll place this zone's root filesystem.

nexus/db-model/src/deployment.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ use nexus_types::deployment::{
4040
use omicron_common::api::internal::shared::NetworkInterface;
4141
use omicron_common::disk::DiskIdentity;
4242
use omicron_common::zpool_name::ZpoolName;
43-
use omicron_uuid_kinds::ZpoolUuid;
44-
use omicron_uuid_kinds::{ExternalIpKind, SledKind, ZpoolKind};
45-
use omicron_uuid_kinds::{ExternalIpUuid, GenericUuid, OmicronZoneUuid};
46-
use omicron_uuid_kinds::{OmicronZoneKind, SledUuid};
43+
use omicron_uuid_kinds::{
44+
ExternalIpKind, ExternalIpUuid, GenericUuid, OmicronZoneKind,
45+
OmicronZoneUuid, SledKind, SledUuid, ZpoolKind, ZpoolUuid,
46+
};
4747
use std::net::{IpAddr, SocketAddrV6};
4848
use uuid::Uuid;
4949

@@ -238,7 +238,7 @@ impl BpSledOmicronZones {
238238
pub struct BpOmicronZone {
239239
pub blueprint_id: Uuid,
240240
pub sled_id: DbTypedUuid<SledKind>,
241-
pub id: Uuid,
241+
pub id: DbTypedUuid<OmicronZoneKind>,
242242
pub underlay_address: ipv6::Ipv6Addr,
243243
pub zone_type: ZoneType,
244244
pub primary_service_ip: ipv6::Ipv6Addr,
@@ -281,7 +281,7 @@ impl BpOmicronZone {
281281
// `blueprint_zone.zone_type`
282282
blueprint_id,
283283
sled_id: sled_id.into(),
284-
id: blueprint_zone.id.into_untyped_uuid(),
284+
id: blueprint_zone.id.into(),
285285
underlay_address: blueprint_zone.underlay_address.into(),
286286
external_ip_id,
287287
filesystem_pool: blueprint_zone
@@ -526,7 +526,7 @@ impl BpOmicronZone {
526526
// Result) we immediately return. We check the inner result later, but
527527
// only if some code path tries to use `nic` and it's not present.
528528
let nic = omicron_zone_config::nic_row_to_network_interface(
529-
self.id,
529+
self.id.into(),
530530
self.bp_nic_id,
531531
nic_row.map(Into::into),
532532
)?;
@@ -691,7 +691,7 @@ impl BpOmicronZone {
691691

692692
Ok(BlueprintZoneConfig {
693693
disposition: self.disposition.into(),
694-
id: OmicronZoneUuid::from_untyped_uuid(self.id),
694+
id: self.id.into(),
695695
underlay_address: self.underlay_address.into(),
696696
filesystem_pool: self
697697
.filesystem_pool
@@ -768,7 +768,7 @@ impl BpOmicronZoneNic {
768768
let Some((_, nic)) = zone.zone_type.external_networking() else {
769769
return Ok(None);
770770
};
771-
let nic = OmicronZoneNic::new(zone.id.into_untyped_uuid(), nic)?;
771+
let nic = OmicronZoneNic::new(zone.id, nic)?;
772772
Ok(Some(Self {
773773
blueprint_id,
774774
id: nic.id,
@@ -784,7 +784,7 @@ impl BpOmicronZoneNic {
784784

785785
pub fn into_network_interface_for_zone(
786786
self,
787-
zone_id: Uuid,
787+
zone_id: OmicronZoneUuid,
788788
) -> Result<NetworkInterface, anyhow::Error> {
789789
let zone_nic = OmicronZoneNic::from(self);
790790
zone_nic.into_network_interface_for_zone(zone_id)

nexus/db-model/src/inventory.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ use nexus_types::inventory::{
3737
};
3838
use omicron_common::api::internal::shared::NetworkInterface;
3939
use omicron_common::zpool_name::ZpoolName;
40-
use omicron_uuid_kinds::CollectionKind;
41-
use omicron_uuid_kinds::CollectionUuid;
4240
use omicron_uuid_kinds::DatasetKind;
4341
use omicron_uuid_kinds::GenericUuid;
4442
use omicron_uuid_kinds::SledKind;
4543
use omicron_uuid_kinds::SledUuid;
4644
use omicron_uuid_kinds::ZpoolKind;
4745
use omicron_uuid_kinds::ZpoolUuid;
46+
use omicron_uuid_kinds::{CollectionKind, OmicronZoneKind};
47+
use omicron_uuid_kinds::{CollectionUuid, OmicronZoneUuid};
4848
use std::net::{IpAddr, SocketAddrV6};
4949
use uuid::Uuid;
5050

@@ -1116,7 +1116,7 @@ impl From<nexus_sled_agent_shared::inventory::ZoneKind> for ZoneType {
11161116
pub struct InvOmicronZone {
11171117
pub inv_collection_id: DbTypedUuid<CollectionKind>,
11181118
pub sled_id: DbTypedUuid<SledKind>,
1119-
pub id: Uuid,
1119+
pub id: DbTypedUuid<OmicronZoneKind>,
11201120
pub underlay_address: ipv6::Ipv6Addr,
11211121
pub zone_type: ZoneType,
11221122
pub primary_service_ip: ipv6::Ipv6Addr,
@@ -1151,7 +1151,7 @@ impl InvOmicronZone {
11511151
// `zone.zone_type`
11521152
inv_collection_id: inv_collection_id.into(),
11531153
sled_id: sled_id.into(),
1154-
id: zone.id,
1154+
id: zone.id.into(),
11551155
underlay_address: zone.underlay_address.into(),
11561156
filesystem_pool: zone
11571157
.filesystem_pool
@@ -1362,7 +1362,7 @@ impl InvOmicronZone {
13621362
// Result) we immediately return. We check the inner result later, but
13631363
// only if some code path tries to use `nic` and it's not present.
13641364
let nic = omicron_zone_config::nic_row_to_network_interface(
1365-
self.id,
1365+
self.id.into(),
13661366
self.nic_id,
13671367
nic_row.map(Into::into),
13681368
)?;
@@ -1482,7 +1482,7 @@ impl InvOmicronZone {
14821482
};
14831483

14841484
Ok(OmicronZoneConfig {
1485-
id: self.id,
1485+
id: self.id.into(),
14861486
underlay_address: self.underlay_address.into(),
14871487
filesystem_pool: self
14881488
.filesystem_pool
@@ -1545,7 +1545,7 @@ impl InvOmicronZoneNic {
15451545

15461546
pub fn into_network_interface_for_zone(
15471547
self,
1548-
zone_id: Uuid,
1548+
zone_id: OmicronZoneUuid,
15491549
) -> Result<NetworkInterface, anyhow::Error> {
15501550
let zone_nic = OmicronZoneNic::from(self);
15511551
zone_nic.into_network_interface_for_zone(zone_id)

nexus/db-model/src/omicron_zone_config.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use ipnetwork::IpNetwork;
1818
use nexus_sled_agent_shared::inventory::OmicronZoneDataset;
1919
use nexus_types::inventory::NetworkInterface;
2020
use omicron_common::api::internal::shared::NetworkInterfaceKind;
21+
use omicron_uuid_kinds::{GenericUuid, OmicronZoneUuid};
2122
use std::net::{IpAddr, SocketAddr, SocketAddrV6};
2223
use uuid::Uuid;
2324

@@ -55,7 +56,7 @@ pub fn ntp_dns_servers_to_omicron_internal(
5556
/// immediately. The inner result represents an operational error and should
5657
/// only be unwrapped when the nic is used.
5758
pub fn nic_row_to_network_interface(
58-
zone_id: Uuid,
59+
zone_id: OmicronZoneUuid,
5960
nic_id: Option<Uuid>,
6061
nic_row: Option<OmicronZoneNic>,
6162
) -> anyhow::Result<anyhow::Result<NetworkInterface>> {
@@ -133,7 +134,7 @@ pub(crate) struct OmicronZoneNic {
133134

134135
impl OmicronZoneNic {
135136
pub(crate) fn new(
136-
zone_id: Uuid,
137+
zone_id: OmicronZoneUuid,
137138
nic: &nexus_types::inventory::NetworkInterface,
138139
) -> anyhow::Result<Self> {
139140
// We do not bother storing the NIC's kind and associated id
@@ -142,7 +143,7 @@ impl OmicronZoneNic {
142143
ensure!(
143144
matches!(
144145
nic.kind,
145-
NetworkInterfaceKind::Service{ id } if id == zone_id
146+
NetworkInterfaceKind::Service { id } if id == zone_id.into_untyped_uuid()
146147
),
147148
"expected zone's NIC kind to be \"service\" and the \
148149
id to match the zone's id ({zone_id})",
@@ -162,12 +163,14 @@ impl OmicronZoneNic {
162163

163164
pub(crate) fn into_network_interface_for_zone(
164165
self,
165-
zone_id: Uuid,
166+
zone_id: OmicronZoneUuid,
166167
) -> anyhow::Result<NetworkInterface> {
167168
Ok(NetworkInterface {
168169
id: self.id,
169170
ip: self.ip.ip(),
170-
kind: NetworkInterfaceKind::Service { id: zone_id },
171+
kind: NetworkInterfaceKind::Service {
172+
id: zone_id.into_untyped_uuid(),
173+
},
171174
mac: *self.mac,
172175
name: self.name.into(),
173176
primary: self.is_primary,

nexus/db-model/src/saga_types.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use diesel::serialize::{self, ToSql};
2020
use diesel::sql_types;
2121
use omicron_common::api::external::Error;
2222
use omicron_common::api::external::Generation;
23+
use omicron_uuid_kinds::{GenericUuid, OmicronZoneUuid};
2324
use std::convert::TryFrom;
2425
use std::io::Write;
2526
use std::sync::Arc;
@@ -64,6 +65,12 @@ NewtypeDebug! { () pub struct SecId(Uuid); }
6465
NewtypeDisplay! { () pub struct SecId(Uuid); }
6566
NewtypeFrom! { () pub struct SecId(Uuid); }
6667

68+
impl From<OmicronZoneUuid> for SecId {
69+
fn from(g: OmicronZoneUuid) -> Self {
70+
g.into_untyped_uuid().into()
71+
}
72+
}
73+
6774
impl From<&SecId> for Uuid {
6875
fn from(g: &SecId) -> Self {
6976
g.0

nexus/inventory/src/collector.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ mod test {
384384
use omicron_common::api::external::Generation;
385385
use omicron_common::zpool_name::ZpoolName;
386386
use omicron_sled_agent::sim;
387+
use omicron_uuid_kinds::OmicronZoneUuid;
387388
use omicron_uuid_kinds::ZpoolUuid;
388389
use std::fmt::Write;
389390
use std::net::Ipv6Addr;
@@ -532,7 +533,7 @@ mod test {
532533
async fn sim_sled_agent(
533534
log: slog::Logger,
534535
sled_id: Uuid,
535-
zone_id: Uuid,
536+
zone_id: OmicronZoneUuid,
536537
) -> sim::Server {
537538
// Start a simulated sled agent.
538539
let config = sim::Config::for_testing(

0 commit comments

Comments
 (0)