diff --git a/common/src/sql/dbinit.sql b/common/src/sql/dbinit.sql index 3a48ae7709..6d8dd9054d 100644 --- a/common/src/sql/dbinit.sql +++ b/common/src/sql/dbinit.sql @@ -168,6 +168,8 @@ CREATE TABLE omicron.public.service ( /* FK into the Sled table */ sled_id UUID NOT NULL, + /* For services in illumos zones, the zone's unique id (for debugging) */ + zone_id UUID, /* The IP address of the service. */ ip INET NOT NULL, /* The UDP or TCP port on which the service listens. */ diff --git a/nexus/db-model/src/schema.rs b/nexus/db-model/src/schema.rs index 24ce104ce3..d9de507c62 100644 --- a/nexus/db-model/src/schema.rs +++ b/nexus/db-model/src/schema.rs @@ -488,6 +488,7 @@ table! { time_modified -> Timestamptz, sled_id -> Uuid, + zone_id -> Nullable, ip -> Inet, port -> Int4, kind -> crate::ServiceKindEnum, diff --git a/nexus/db-model/src/service.rs b/nexus/db-model/src/service.rs index 97efc11a38..45d3ca5a16 100644 --- a/nexus/db-model/src/service.rs +++ b/nexus/db-model/src/service.rs @@ -18,6 +18,7 @@ pub struct Service { identity: ServiceIdentity, pub sled_id: Uuid, + pub zone_id: Option, pub ip: ipv6::Ipv6Addr, pub port: SqlU16, pub kind: ServiceKind, @@ -27,12 +28,14 @@ impl Service { pub fn new( id: Uuid, sled_id: Uuid, + zone_id: Option, addr: SocketAddrV6, kind: ServiceKind, ) -> Self { Self { identity: ServiceIdentity::new(id), sled_id, + zone_id, ip: addr.ip().into(), port: addr.port().into(), kind, diff --git a/nexus/db-queries/src/db/datastore/mod.rs b/nexus/db-queries/src/db/datastore/mod.rs index 10e7080bcb..b202958789 100644 --- a/nexus/db-queries/src/db/datastore/mod.rs +++ b/nexus/db-queries/src/db/datastore/mod.rs @@ -1099,7 +1099,8 @@ mod test { let addr = SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0); let kind = ServiceKind::Nexus; - let service1 = Service::new(service1_id, sled_id, addr, kind); + let service1 = + Service::new(service1_id, sled_id, Some(service1_id), addr, kind); let result = datastore.service_upsert(&opctx, service1.clone()).await.unwrap(); assert_eq!(service1.id(), result.id()); @@ -1108,7 +1109,7 @@ mod test { let service2_id = "fe5b6e3d-dfee-47b4-8719-c54f78912c0b".parse().unwrap(); - let service2 = Service::new(service2_id, sled_id, addr, kind); + let service2 = Service::new(service2_id, sled_id, None, addr, kind); let result = datastore.service_upsert(&opctx, service2.clone()).await.unwrap(); assert_eq!(service2.id(), result.id()); @@ -1117,7 +1118,13 @@ mod test { let service3_id = Uuid::new_v4(); let kind = ServiceKind::Oximeter; - let service3 = Service::new(service3_id, sled_id, addr, kind); + let service3 = Service::new( + service3_id, + sled_id, + Some(Uuid::new_v4()), + addr, + kind, + ); let result = datastore.service_upsert(&opctx, service3.clone()).await.unwrap(); assert_eq!(service3.id(), result.id()); @@ -1139,9 +1146,11 @@ mod test { .unwrap(); assert_eq!(services[0].id(), service1.id()); assert_eq!(services[0].sled_id, service1.sled_id); + assert_eq!(services[0].zone_id, service1.zone_id); assert_eq!(services[0].kind, service1.kind); assert_eq!(services[1].id(), service2.id()); assert_eq!(services[1].sled_id, service2.sled_id); + assert_eq!(services[1].zone_id, service2.zone_id); assert_eq!(services[1].kind, service2.kind); assert_eq!(services.len(), 2); @@ -1160,6 +1169,7 @@ mod test { .unwrap(); assert_eq!(services[0].id(), service3.id()); assert_eq!(services[0].sled_id, service3.sled_id); + assert_eq!(services[0].zone_id, service3.zone_id); assert_eq!(services[0].kind, service3.kind); assert_eq!(services.len(), 1); diff --git a/nexus/db-queries/src/db/datastore/rack.rs b/nexus/db-queries/src/db/datastore/rack.rs index e727f992bf..0d408da53c 100644 --- a/nexus/db-queries/src/db/datastore/rack.rs +++ b/nexus/db-queries/src/db/datastore/rack.rs @@ -175,6 +175,7 @@ impl DataStore { let service_db = db::model::Service::new( service.service_id, service.sled_id, + service.zone_id, service.address, service.kind.into(), ); @@ -624,9 +625,11 @@ mod test { let sled = create_test_sled(&datastore).await; let nexus_ip = IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)); + let nexus_id = Uuid::new_v4(); let services = vec![internal_params::ServicePutRequest { - service_id: Uuid::new_v4(), + service_id: nexus_id, sled_id: sled.id(), + zone_id: Some(nexus_id), address: SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0), kind: internal_params::ServiceKind::Nexus { external_address: nexus_ip, @@ -718,18 +721,22 @@ mod test { // Ask for two Nexus services, with different external IPs. let nexus_ip_start = Ipv4Addr::new(1, 2, 3, 4); let nexus_ip_end = Ipv4Addr::new(1, 2, 3, 5); + let nexus_id1 = Uuid::new_v4(); + let nexus_id2 = Uuid::new_v4(); let mut services = vec![ internal_params::ServicePutRequest { - service_id: Uuid::new_v4(), + service_id: nexus_id1, sled_id: sled.id(), + zone_id: Some(nexus_id1), address: SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0), kind: internal_params::ServiceKind::Nexus { external_address: IpAddr::V4(nexus_ip_start), }, }, internal_params::ServicePutRequest { - service_id: Uuid::new_v4(), + service_id: nexus_id2, sled_id: sled.id(), + zone_id: Some(nexus_id2), address: SocketAddrV6::new(Ipv6Addr::LOCALHOST, 456, 0, 0), kind: internal_params::ServiceKind::Nexus { external_address: IpAddr::V4(nexus_ip_end), @@ -904,9 +911,11 @@ mod test { let sled = create_test_sled(&datastore).await; let nexus_ip = IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)); + let nexus_id = Uuid::new_v4(); let services = vec![internal_params::ServicePutRequest { - service_id: Uuid::new_v4(), + service_id: nexus_id, sled_id: sled.id(), + zone_id: Some(nexus_id), address: SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0), kind: internal_params::ServiceKind::Nexus { external_address: nexus_ip, @@ -957,19 +966,23 @@ mod test { // Request two services which happen to be using the same IP address. let nexus_ip = IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)); + let nexus_id1 = Uuid::new_v4(); + let nexus_id2 = Uuid::new_v4(); let services = vec![ internal_params::ServicePutRequest { - service_id: Uuid::new_v4(), + service_id: nexus_id1, sled_id: sled.id(), + zone_id: Some(nexus_id1), address: SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0), kind: internal_params::ServiceKind::Nexus { external_address: nexus_ip, }, }, internal_params::ServicePutRequest { - service_id: Uuid::new_v4(), + service_id: nexus_id2, sled_id: sled.id(), + zone_id: Some(nexus_id2), address: SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0), kind: internal_params::ServiceKind::Nexus { external_address: nexus_ip, diff --git a/nexus/src/app/background/dns_servers.rs b/nexus/src/app/background/dns_servers.rs index 488e2a340f..157260cfd8 100644 --- a/nexus/src/app/background/dns_servers.rs +++ b/nexus/src/app/background/dns_servers.rs @@ -233,6 +233,7 @@ mod test { .values(Service::new( Uuid::new_v4(), Uuid::new_v4(), + Some(Uuid::new_v4()), SocketAddrV6::new(Ipv6Addr::LOCALHOST, 1, 0, 0), ServiceKind::InternalDnsConfig, )) @@ -255,6 +256,7 @@ mod test { Service::new( Uuid::new_v4(), Uuid::new_v4(), + Some(Uuid::new_v4()), SocketAddrV6::new(Ipv6Addr::LOCALHOST, i + 2, 0, 0), ServiceKind::InternalDnsConfig, ) diff --git a/nexus/src/app/background/init.rs b/nexus/src/app/background/init.rs index bdac089b70..1d66259c53 100644 --- a/nexus/src/app/background/init.rs +++ b/nexus/src/app/background/init.rs @@ -238,6 +238,7 @@ pub mod test { &opctx, Uuid::new_v4(), cptestctx.sled_agent.sled_agent.id, + Some(Uuid::new_v4()), new_dns_addr, ServiceKind::InternalDnsConfig.into(), ) diff --git a/nexus/src/app/sled.rs b/nexus/src/app/sled.rs index 28499b5d18..3ba687fc91 100644 --- a/nexus/src/app/sled.rs +++ b/nexus/src/app/sled.rs @@ -260,6 +260,7 @@ impl super::Nexus { opctx: &OpContext, id: Uuid, sled_id: Uuid, + zone_id: Option, address: SocketAddrV6, kind: ServiceKind, ) -> Result<(), Error> { @@ -270,7 +271,8 @@ impl super::Nexus { "service_id" => id.to_string(), "address" => address.to_string(), ); - let service = db::model::Service::new(id, sled_id, address, kind); + let service = + db::model::Service::new(id, sled_id, zone_id, address, kind); self.db_datastore.service_upsert(opctx, service).await?; if kind == ServiceKind::ExternalDnsConfig { diff --git a/nexus/test-utils/src/lib.rs b/nexus/test-utils/src/lib.rs index 0563de61e9..590d10e504 100644 --- a/nexus/test-utils/src/lib.rs +++ b/nexus/test-utils/src/lib.rs @@ -220,12 +220,28 @@ pub async fn test_setup_with_config( SocketAddr::V4(_) => panic!("expected DNS server to have IPv6 address"), SocketAddr::V6(addr) => addr, }; - let dns_service_internal = ServicePutRequest { + let dns_server_dns_address_internal = match sled_agent + .dns_server + .local_address() + { + SocketAddr::V4(_) => panic!("expected DNS server to have IPv6 address"), + SocketAddr::V6(addr) => *addr, + }; + let dns_server_zone = Uuid::new_v4(); + let dns_service_config = ServicePutRequest { service_id: Uuid::new_v4(), sled_id: sa_id, + zone_id: Some(dns_server_zone), address: dns_server_address_internal, kind: ServiceKind::InternalDnsConfig, }; + let dns_service_dns = ServicePutRequest { + service_id: Uuid::new_v4(), + sled_id: sa_id, + zone_id: Some(dns_server_zone), + address: dns_server_dns_address_internal, + kind: ServiceKind::InternalDns, + }; let dns_server_address_external = match external_dns_config_server .local_addr() { @@ -235,12 +251,14 @@ pub async fn test_setup_with_config( let dns_service_external = ServicePutRequest { service_id: Uuid::new_v4(), sled_id: sa_id, + zone_id: Some(Uuid::new_v4()), address: dns_server_address_external, kind: ServiceKind::ExternalDnsConfig, }; let nexus_service = ServicePutRequest { service_id: Uuid::new_v4(), sled_id: sa_id, + zone_id: Some(Uuid::new_v4()), address: SocketAddrV6::new( match nexus_internal_addr.ip() { IpAddr::V4(addr) => addr.to_ipv6_mapped(), @@ -260,10 +278,16 @@ pub async fn test_setup_with_config( }; let external_dns_zone_name = internal_dns::names::DNS_ZONE_EXTERNAL_TESTING.to_string(); + let server = N::start( nexus_internal, &config, - vec![dns_service_internal, dns_service_external, nexus_service], + vec![ + dns_service_config, + dns_service_dns, + dns_service_external, + nexus_service, + ], &external_dns_zone_name, ) .await; diff --git a/nexus/types/src/internal_api/params.rs b/nexus/types/src/internal_api/params.rs index 0dd4b95a54..01358c3502 100644 --- a/nexus/types/src/internal_api/params.rs +++ b/nexus/types/src/internal_api/params.rs @@ -197,6 +197,7 @@ impl fmt::Display for ServiceKind { pub struct ServicePutRequest { pub service_id: Uuid, pub sled_id: Uuid, + pub zone_id: Option, /// Address on which a service is responding to requests. pub address: SocketAddrV6, diff --git a/openapi/nexus-internal.json b/openapi/nexus-internal.json index 8db51e3d17..13d43af51b 100644 --- a/openapi/nexus-internal.json +++ b/openapi/nexus-internal.json @@ -2733,6 +2733,11 @@ "sled_id": { "type": "string", "format": "uuid" + }, + "zone_id": { + "nullable": true, + "type": "string", + "format": "uuid" } }, "required": [ diff --git a/openapi/sled-agent.json b/openapi/sled-agent.json index 9b074f7f41..a268eb0095 100644 --- a/openapi/sled-agent.json +++ b/openapi/sled-agent.json @@ -2065,7 +2065,7 @@ "services": { "type": "array", "items": { - "$ref": "#/components/schemas/ServiceType" + "$ref": "#/components/schemas/ServiceZoneService" } }, "zone_type": { @@ -2079,6 +2079,22 @@ "zone_type" ] }, + "ServiceZoneService": { + "type": "object", + "properties": { + "details": { + "$ref": "#/components/schemas/ServiceType" + }, + "id": { + "type": "string", + "format": "uuid" + } + }, + "required": [ + "details", + "id" + ] + }, "SetVirtualNetworkInterfaceHost": { "description": "A mapping from a virtual NIC to a physical host", "type": "object", diff --git a/sled-agent/src/params.rs b/sled-agent/src/params.rs index 104c1922eb..5f3107d19a 100644 --- a/sled-agent/src/params.rs +++ b/sled-agent/src/params.rs @@ -497,7 +497,7 @@ pub struct ServiceZoneRequest { #[serde(default)] pub gz_addresses: Vec, // Services that should be run in the zone - pub services: Vec, + pub services: Vec, } impl From for sled_agent_client::types::ServiceZoneRequest { @@ -517,6 +517,20 @@ impl From for sled_agent_client::types::ServiceZoneRequest { } } +#[derive( + Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash, +)] +pub struct ServiceZoneService { + pub id: Uuid, + pub details: ServiceType, +} + +impl From for sled_agent_client::types::ServiceZoneService { + fn from(s: ServiceZoneService) -> Self { + Self { id: s.id, details: s.details.into() } + } +} + /// Used to request that the Sled initialize certain services on initialization. /// /// This may be used to record that certain sleds are responsible for diff --git a/sled-agent/src/rack_setup/plan/service.rs b/sled-agent/src/rack_setup/plan/service.rs index 3f2f4af54e..008ae9d3f4 100644 --- a/sled-agent/src/rack_setup/plan/service.rs +++ b/sled-agent/src/rack_setup/plan/service.rs @@ -6,7 +6,8 @@ use crate::bootstrap::params::SledAgentRequest; use crate::params::{ - DatasetEnsureBody, ServiceType, ServiceZoneRequest, ZoneType, + DatasetEnsureBody, ServiceType, ServiceZoneRequest, ServiceZoneService, + ZoneType, }; use crate::rack_setup::config::SetupServiceConfig as Config; use dns_service_client::types::DnsConfigParams; @@ -297,15 +298,18 @@ impl Plan { zone_type: ZoneType::ExternalDns, addresses: vec![internal_ip], gz_addresses: vec![], - services: vec![ServiceType::ExternalDns { - http_address: SocketAddrV6::new( - internal_ip, - http_port, - 0, - 0, - ), - dns_address: SocketAddr::new(external_ip, dns_port), - nic, + services: vec![ServiceZoneService { + id, + details: ServiceType::ExternalDns { + http_address: SocketAddrV6::new( + internal_ip, + http_port, + 0, + 0, + ), + dns_address: SocketAddr::new(external_ip, dns_port), + nic, + }, }], }) } @@ -330,10 +334,13 @@ impl Plan { zone_type: ZoneType::Nexus, addresses: vec![address], gz_addresses: vec![], - services: vec![ServiceType::Nexus { - internal_ip: address, - external_ip, - nic, + services: vec![ServiceZoneService { + id, + details: ServiceType::Nexus { + internal_ip: address, + external_ip, + nic, + }, }], }) } @@ -355,7 +362,10 @@ impl Plan { zone_type: ZoneType::Oximeter, addresses: vec![address], gz_addresses: vec![], - services: vec![ServiceType::Oximeter], + services: vec![ServiceZoneService { + id, + details: ServiceType::Oximeter, + }], }) } @@ -445,16 +455,19 @@ impl Plan { zone_type: ZoneType::InternalDns, addresses: vec![dns_addr], gz_addresses: vec![dns_subnet.gz_address().ip()], - services: vec![ServiceType::InternalDns { - http_address: SocketAddrV6::new( - dns_addr, - DNS_HTTP_PORT, - 0, - 0, - ), - dns_address: SocketAddrV6::new( - dns_addr, DNS_PORT, 0, 0, - ), + services: vec![ServiceZoneService { + id, + details: ServiceType::InternalDns { + http_address: SocketAddrV6::new( + dns_addr, + DNS_HTTP_PORT, + 0, + 0, + ), + dns_address: SocketAddrV6::new( + dns_addr, DNS_PORT, 0, 0, + ), + }, }], }); } @@ -477,7 +490,10 @@ impl Plan { zone_type: ZoneType::CruciblePantry, addresses: vec![address], gz_addresses: vec![], - services: vec![ServiceType::CruciblePantry], + services: vec![ServiceZoneService { + id, + details: ServiceType::CruciblePantry, + }], }) } @@ -495,21 +511,27 @@ impl Plan { let (nic, snat_cfg) = svc_port_builder .next_snat(id, &mut services_ip_pool)?; ( - vec![ServiceType::BoundaryNtp { - ntp_servers: config.ntp_servers.clone(), - dns_servers: config.dns_servers.clone(), - domain: None, - nic, - snat_cfg, + vec![ServiceZoneService { + id, + details: ServiceType::BoundaryNtp { + ntp_servers: config.ntp_servers.clone(), + dns_servers: config.dns_servers.clone(), + domain: None, + nic, + snat_cfg, + }, }], ServiceName::BoundaryNtp, ) } else { ( - vec![ServiceType::InternalNtp { - ntp_servers: boundary_ntp_servers.clone(), - dns_servers: rack_dns_servers.clone(), - domain: None, + vec![ServiceZoneService { + id, + details: ServiceType::InternalNtp { + ntp_servers: boundary_ntp_servers.clone(), + dns_servers: rack_dns_servers.clone(), + domain: None, + }, }], ServiceName::InternalNtp, ) diff --git a/sled-agent/src/rack_setup/service.rs b/sled-agent/src/rack_setup/service.rs index 299dad6f5b..1586cfb5de 100644 --- a/sled-agent/src/rack_setup/service.rs +++ b/sled-agent/src/rack_setup/service.rs @@ -381,7 +381,7 @@ impl ServiceInner { // and port that have been assigned to it. // There should be exactly one. let addrs = svc.services.iter().filter_map(|s| { - if let ServiceType::InternalDns { http_address, .. } = s { + if let ServiceType::InternalDns { http_address, .. } = &s.details { Some(*http_address) } else { None @@ -666,14 +666,17 @@ impl ServiceInner { // the port assumption into multiple places and we can also // more easily support things running on different ports // (which is useful in dev/test situations). - match svc { + let service_id = svc.id; + let zone_id = Some(zone.id); + match &svc.details { ServiceType::Nexus { external_ip, internal_ip: _, .. } => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: SocketAddrV6::new( zone.addresses[0], @@ -689,7 +692,8 @@ impl ServiceInner { } ServiceType::Dendrite { .. } => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: SocketAddrV6::new( zone.addresses[0], @@ -703,7 +707,8 @@ impl ServiceInner { } ServiceType::ExternalDns { http_address, .. } => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: http_address.to_string(), kind: @@ -715,14 +720,16 @@ impl ServiceInner { dns_address, } => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: http_address.to_string(), kind: NexusTypes::ServiceKind::InternalDnsConfig, }); services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: dns_address.to_string(), kind: NexusTypes::ServiceKind::InternalDns, @@ -730,7 +737,8 @@ impl ServiceInner { } ServiceType::Oximeter => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: SocketAddrV6::new( zone.addresses[0], @@ -744,7 +752,8 @@ impl ServiceInner { } ServiceType::CruciblePantry => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: SocketAddrV6::new( zone.addresses[0], @@ -759,7 +768,8 @@ impl ServiceInner { ServiceType::BoundaryNtp { .. } | ServiceType::InternalNtp { .. } => { services.push(NexusTypes::ServicePutRequest { - service_id: zone.id, + service_id, + zone_id, sled_id, address: SocketAddrV6::new( zone.addresses[0], @@ -771,10 +781,10 @@ impl ServiceInner { kind: NexusTypes::ServiceKind::Ntp, }); } - _ => { + details => { return Err(SetupServiceError::BadConfig(format!( "RSS should not request service of type: {}", - svc + details ))); } } diff --git a/sled-agent/src/services.rs b/sled-agent/src/services.rs index 8d0043b93c..e155872723 100644 --- a/sled-agent/src/services.rs +++ b/sled-agent/src/services.rs @@ -26,8 +26,8 @@ //! or disable (via [ServiceManager::deactivate_switch]) the switch zone. use crate::params::{ - DendriteAsic, ServiceEnsureBody, ServiceType, ServiceZoneRequest, TimeSync, - ZoneType, + DendriteAsic, ServiceEnsureBody, ServiceType, ServiceZoneRequest, + ServiceZoneService, TimeSync, ZoneType, }; use crate::profile::*; use crate::smf_helper::Service; @@ -541,7 +541,7 @@ impl ServiceManager { fn devices_needed(req: &ServiceZoneRequest) -> Result, Error> { let mut devices = vec![]; for svc in &req.services { - match svc { + match &svc.details { ServiceType::Dendrite { asic: DendriteAsic::TofinoAsic } => { if let Ok(Some(n)) = tofino::get_tofino() { if let Ok(device_path) = n.device_path() { @@ -598,7 +598,7 @@ impl ServiceManager { let mut links: Vec<(Link, bool)> = Vec::new(); for svc in &req.services { - match svc { + match &svc.details { ServiceType::Tfport { pkt_source } => { // The tfport service requires a MAC device to/from which sidecar // packets may be multiplexed. If the link isn't present, don't @@ -676,7 +676,7 @@ impl ServiceManager { let mut ports = vec![]; for svc in &req.services { let external_ip; - let (nic, snat, external_ips) = match svc { + let (nic, snat, external_ips) = match &svc.details { ServiceType::Nexus { external_ip, nic, .. } => { (nic, None, std::slice::from_ref(external_ip)) } @@ -698,7 +698,7 @@ impl ServiceManager { let port = port_manager .create_port(nic, snat, external_ips, &[]) .map_err(|err| Error::ServicePortCreation { - service: svc.to_string(), + service: svc.details.to_string(), err: Box::new(err), })?; @@ -773,7 +773,7 @@ impl ServiceManager { fn privs_needed(req: &ServiceZoneRequest) -> Vec { let mut needed = Vec::new(); for svc in &req.services { - match svc { + match &svc.details { ServiceType::Tfport { .. } => { needed.push("default".to_string()); needed.push("sys_dl_config".to_string()); @@ -1058,10 +1058,10 @@ impl ServiceManager { // avoid importing this manifest? debug!(self.inner.log, "importing manifest"); - let smfh = SmfHelper::new(&running_zone, service); + let smfh = SmfHelper::new(&running_zone, &service.details); smfh.import_manifest()?; - match &service { + match &service.details { ServiceType::Nexus { internal_ip, .. } => { info!(self.inner.log, "Setting up Nexus service"); @@ -1364,8 +1364,10 @@ impl ServiceManager { dns_servers, domain, } => { - let boundary = - matches!(service, ServiceType::BoundaryNtp { .. }); + let boundary = matches!( + service.details, + ServiceType::BoundaryNtp { .. } + ); info!( self.inner.log, "Set up NTP service boundary={}, Servers={:?}", @@ -1772,7 +1774,10 @@ impl ServiceManager { zone_type: ZoneType::Switch, addresses, gz_addresses: vec![], - services, + services: services + .into_iter() + .map(|s| ServiceZoneService { id: Uuid::new_v4(), details: s }) + .collect(), }; self.ensure_zone( @@ -1901,9 +1906,9 @@ impl ServiceManager { } for service in &request.services { - let smfh = SmfHelper::new(&zone, service); + let smfh = SmfHelper::new(&zone, &service.details); - match service { + match &service.details { ServiceType::ManagementGatewayService => { // Remove any existing `config/address` values // without deleting the property itself. @@ -2049,7 +2054,7 @@ impl ServiceManager { #[cfg(test)] mod test { use super::*; - use crate::params::ZoneType; + use crate::params::{ServiceZoneService, ZoneType}; use illumos_utils::{ dladm::{ Etherstub, MockDladm, BOOTSTRAP_ETHERSTUB_NAME, @@ -2132,7 +2137,10 @@ mod test { zone_type: ZoneType::Oximeter, addresses: vec![Ipv6Addr::LOCALHOST], gz_addresses: vec![], - services: vec![ServiceType::Oximeter], + services: vec![ServiceZoneService { + id, + details: ServiceType::Oximeter, + }], }], }) .await @@ -2148,7 +2156,10 @@ mod test { zone_type: ZoneType::Oximeter, addresses: vec![Ipv6Addr::LOCALHOST], gz_addresses: vec![], - services: vec![ServiceType::Oximeter], + services: vec![ServiceZoneService { + id, + details: ServiceType::Oximeter, + }], }], }) .await diff --git a/sled-agent/src/sim/server.rs b/sled-agent/src/sim/server.rs index 13c1eb4447..53e5d0d69e 100644 --- a/sled-agent/src/sim/server.rs +++ b/sled-agent/src/sim/server.rs @@ -255,12 +255,14 @@ impl Server { kind: NexusTypes::ServiceKind::InternalDns, service_id: Uuid::new_v4(), sled_id: config.id, + zone_id: Some(Uuid::new_v4()), }, NexusTypes::ServicePutRequest { address: http_bound.to_string(), kind: NexusTypes::ServiceKind::InternalDnsConfig, service_id: Uuid::new_v4(), sled_id: config.id, + zone_id: Some(Uuid::new_v4()), }, ]; @@ -273,6 +275,7 @@ impl Server { kind: NexusTypes::ServiceKind::Nexus { external_address: ip }, service_id: Uuid::new_v4(), sled_id: config.id, + zone_id: Some(Uuid::new_v4()), }); internal_services_ip_pool_ranges.push(match ip { @@ -293,6 +296,7 @@ impl Server { kind: NexusTypes::ServiceKind::ExternalDnsConfig, service_id: Uuid::new_v4(), sled_id: config.id, + zone_id: Some(Uuid::new_v4()), }); }