From c4dc50c1d05aa580e76b44c192c2abf2406d03e0 Mon Sep 17 00:00:00 2001 From: karencfv Date: Tue, 21 Nov 2023 15:53:59 +1300 Subject: [PATCH] Self assembling Oximeter zone --- package-manifest.toml | 3 +- sled-agent/src/services.rs | 56 ++++++++++++++++++++++++++++++-------- smf/oximeter/manifest.xml | 22 +++++++++------ 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/package-manifest.toml b/package-manifest.toml index ca96341f2a..78b4141a56 100644 --- a/package-manifest.toml +++ b/package-manifest.toml @@ -110,7 +110,8 @@ source.type = "local" source.rust.binary_names = ["oximeter", "clickhouse-schema-updater"] source.rust.release = true source.paths = [ - { from = "smf/oximeter", to = "/var/svc/manifest/site/oximeter" }, + { from = "smf/oximeter/manifest.xml", to = "/var/svc/manifest/site/oximeter/manifest.xml" }, + { from = "smf/oximeter/method_script.sh", to = "/opt/oxide/lib/svc/manifest/oximeter.sh" }, { from = "oximeter/db/schema", to = "/opt/oxide/oximeter/schema" }, ] output.type = "zone" diff --git a/sled-agent/src/services.rs b/sled-agent/src/services.rs index b87c91768b..0aad13d1a9 100644 --- a/sled-agent/src/services.rs +++ b/sled-agent/src/services.rs @@ -61,7 +61,6 @@ use illumos_utils::zone::Zones; use illumos_utils::{execute, PFEXEC}; use internal_dns::resolver::Resolver; use itertools::Itertools; -use omicron_common::address::AZ_PREFIX; use omicron_common::address::BOOTSTRAP_ARTIFACT_PORT; use omicron_common::address::CLICKHOUSE_KEEPER_PORT; use omicron_common::address::CLICKHOUSE_PORT; @@ -75,6 +74,7 @@ use omicron_common::address::SLED_PREFIX; use omicron_common::address::WICKETD_NEXUS_PROXY_PORT; use omicron_common::address::WICKETD_PORT; use omicron_common::address::{Ipv6Subnet, NEXUS_TECHPORT_EXTERNAL_PORT}; +use omicron_common::address::{AZ_PREFIX, OXIMETER_PORT}; use omicron_common::api::external::Generation; use omicron_common::api::internal::shared::{ HostPortConfig, RackNetworkConfig, @@ -1312,6 +1312,45 @@ impl ServiceManager { let running_zone = RunningZone::boot(installed_zone).await?; return Ok(running_zone); } + ZoneType::Oximeter => { + let Some(info) = self.inner.sled_info.get() else { + return Err(Error::SledAgentNotReady); + }; + + // Configure the Oximeter service. + let datalink = installed_zone.get_control_vnic_name(); + let gateway = &info.underlay_address.to_string(); + assert_eq!(request.zone.addresses.len(), 1); + let address = SocketAddr::new( + IpAddr::V6(request.zone.addresses[0]), + OXIMETER_PORT, + ); + let listen_addr = &address.ip().to_string(); + let listen_port = &address.port().to_string(); + let id = &request.zone.id.to_string(); + + let oximeter_config = PropertyGroupBuilder::new("config") + .add_property("datalink", "astring", datalink) + .add_property("gateway", "astring", gateway) + .add_property("listen_addr", "astring", listen_addr) + .add_property("listen_port", "astring", listen_port) + .add_property("id", "astring", id); + let oximeter_service = ServiceBuilder::new("oxide/oximeter") + .add_instance( + ServiceInstanceBuilder::new("default") + .add_property_group(oximeter_config), + ); + + let profile = ProfileBuilder::new("omicron") + .add_service(oximeter_service); + profile + .add_to_zone(&self.inner.log, &installed_zone) + .await + .map_err(|err| { + Error::io("Failed to setup Oximeter profile", err) + })?; + return Ok(RunningZone::boot(installed_zone).await?); + } _ => {} } @@ -1635,12 +1674,6 @@ impl ServiceManager { // enabled. smfh.refresh()?; } - ServiceType::Oximeter { address } => { - info!(self.inner.log, "Setting up oximeter service"); - smfh.setprop("config/id", request.zone.id)?; - smfh.setprop("config/address", address.to_string())?; - smfh.refresh()?; - } ServiceType::ManagementGatewayService => { info!(self.inner.log, "Setting up MGS service"); smfh.setprop("config/id", request.zone.id)?; @@ -2053,11 +2086,12 @@ impl ServiceManager { smfh.refresh()?; } - ServiceType::Crucible { .. } - | ServiceType::CruciblePantry { .. } + ServiceType::Clickhouse { .. } + | ServiceType::ClickhouseKeeper { .. } | ServiceType::CockroachDb { .. } - | ServiceType::Clickhouse { .. } - | ServiceType::ClickhouseKeeper { .. } => { + | ServiceType::Crucible { .. } + | ServiceType::CruciblePantry { .. } + | ServiceType::Oximeter { .. } => { panic!( "{} is a service which exists as part of a self-assembling zone", service.details, diff --git a/smf/oximeter/manifest.xml b/smf/oximeter/manifest.xml index 9c8b30f1f4..17d646d25a 100644 --- a/smf/oximeter/manifest.xml +++ b/smf/oximeter/manifest.xml @@ -4,26 +4,30 @@ - + - - - - - + exec='/opt/oxide/lib/svc/manifest/oximeter.sh' + timeout_seconds='0'> + + + + + + + + + + -