From b72210624111c277c86d0e89cafcc60b60de19d6 Mon Sep 17 00:00:00 2001 From: karencfv Date: Thu, 21 Dec 2023 14:05:35 +1300 Subject: [PATCH] Enable zone network setup service --- Cargo.lock | 2 +- Cargo.toml | 4 +- package-manifest.toml | 42 +++------- sled-agent/src/services.rs | 81 +++++++++---------- smf/cockroachdb/manifest.xml | 7 +- smf/cockroachdb/method_script.sh | 5 -- .../manifest.xml | 17 ++-- .../method_script.sh | 2 +- .../Cargo.toml | 2 +- .../src/bin/zone-networking.rs | 0 10 files changed, 72 insertions(+), 90 deletions(-) rename smf/{zone_network_setup => zone-network-setup}/manifest.xml (69%) rename smf/{zone_network_setup => zone-network-setup}/method_script.sh (75%) rename {zone-networking-cli => zone-network-setup}/Cargo.toml (91%) rename {zone-networking-cli => zone-network-setup}/src/bin/zone-networking.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 61c43f808f..5853a71ffe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10080,7 +10080,7 @@ dependencies = [ ] [[package]] -name = "zone-networking-cli" +name = "zone-network-setup" version = "0.1.0" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 33d6bef914..e3d77f5e4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ members = [ "wicket", "wicketd", "workspace-hack", - "zone-networking-cli", + "zone-network-setup", ] default-members = [ @@ -136,7 +136,7 @@ default-members = [ "wicket-dbg", "wicket", "wicketd", - "zone-networking-cli", + "zone-network-setup", ] resolver = "2" diff --git a/package-manifest.toml b/package-manifest.toml index 92165364e9..a5c253154e 100644 --- a/package-manifest.toml +++ b/package-manifest.toml @@ -161,9 +161,7 @@ setup_hint = "Run `./tools/ci_download_clickhouse` to download the necessary bin service_name = "cockroachdb" only_for_targets.image = "standard" source.type = "composite" -# TODO: Removeme once the zone networking setup service is functional -> "zone-networking-cli.tar.gz" -# TODO: Once service is ready add "zone_network_setup.tar.gz", -source.packages = [ "cockroachdb-service.tar.gz", "internal-dns-cli.tar.gz", "zone-networking-cli.tar.gz" ] +source.packages = [ "cockroachdb-service.tar.gz", "internal-dns-cli.tar.gz", "zone-network-setup.tar.gz" ] output.type = "zone" [package.cockroachdb-service] @@ -604,29 +602,15 @@ source.packages = [ ] output.type = "zone" -# TODO: Removeme once the zone networking setup service is functional - [package.zone-networking-cli] - service_name = "zone-networking-cli" - only_for_targets.image = "standard" - source.type = "local" - source.rust.binary_names = ["zone-networking"] - source.rust.release = true - source.paths = [] - output.type = "zone" - output.intermediate_only = true - -# Commented out as packages can't have the same name but also must match -# the rust package name when `source.rust.release = true` -# -# [package.zone-networking-cli] -# service_name = "zone_network_setup" -# only_for_targets.image = "standard" -# source.type = "local" -# source.rust.binary_names = ["zone-networking"] -# source.rust.release = true -# source.paths = [ -# { from = "smf/zone_network_setup/manifest.xml", to = "/var/svc/manifest/site/zone_network_setup/manifest.xml" }, -# { from = "smf/zone_network_setup/method_script.sh", to = "/opt/oxide/lib/svc/manifest/zone_network_setup.sh" }, -# ] -# output.type = "zone" -# output.intermediate_only = true +[package.zone-network-setup] +service_name = "zone-network-setup" +only_for_targets.image = "standard" +source.type = "local" +source.rust.binary_names = ["zone-networking"] +source.rust.release = true +source.paths = [ + { from = "smf/zone-network-setup/manifest.xml", to = "/var/svc/manifest/site/zone-network-setup/manifest.xml" }, + { from = "smf/zone-network-setup/method_script.sh", to = "/opt/oxide/lib/svc/manifest/zone-network-setup.sh" }, +] +output.type = "zone" +output.intermediate_only = true diff --git a/sled-agent/src/services.rs b/sled-agent/src/services.rs index 1b0ee3ca35..98ee214aa5 100644 --- a/sled-agent/src/services.rs +++ b/sled-agent/src/services.rs @@ -1479,45 +1479,44 @@ impl ServiceManager { // NB: Only adding cockroach for now as it's just to test it out #[allow(clippy::match_single_binding)] match &request { - // TODO: Uncomment once I have removed all previous zone networking from the Cockroach db zone - // ZoneArgs::Omicron(OmicronZoneConfigLocal { - // zone: - // OmicronZoneConfig { - // zone_type: OmicronZoneType::CockroachDb { .. }, - // underlay_address, - // .. - // }, - // .. - // }) => { - // let Some(info) = self.inner.sled_info.get() else { - // return Err(Error::SledAgentNotReady); - // }; - // - // let datalink = installed_zone.get_control_vnic_name(); - // let gateway = &info.underlay_address.to_string(); - // let listen_addr = &underlay_address.to_string(); - // - // let mut config_builder = PropertyGroupBuilder::new("config"); - // config_builder = config_builder - // .add_property("datalink", "astring", datalink) - // .add_property("gateway", "astring", gateway) - // .add_property("listen_addr", "astring", listen_addr); - // let nw_setup = ServiceBuilder::new("oxide/zone_network_setup") - // .add_property_group(config_builder) - // .add_instance(ServiceInstanceBuilder::new("default")); - // // TODO: I'm unsure about the name here, should it be something other than "omicron"? - // let profile = - // ProfileBuilder::new("omicron").add_service(nw_setup); - // profile - // .add_to_zone(&self.inner.log, &installed_zone) - // .await - // .map_err(|err| { - // Error::io( - // "Failed to setup zone_network_setup profile", - // err, - // ) - // })?; - // } + ZoneArgs::Omicron(OmicronZoneConfigLocal { + zone: + OmicronZoneConfig { + zone_type: OmicronZoneType::CockroachDb { .. }, + underlay_address, + .. + }, + .. + }) => { + let Some(info) = self.inner.sled_info.get() else { + return Err(Error::SledAgentNotReady); + }; + + let datalink = installed_zone.get_control_vnic_name(); + let gateway = &info.underlay_address.to_string(); + let listen_addr = &underlay_address.to_string(); + + let mut config_builder = PropertyGroupBuilder::new("config"); + config_builder = config_builder + .add_property("datalink", "astring", datalink) + .add_property("gateway", "astring", gateway) + .add_property("listen_addr", "astring", listen_addr); + let nw_setup = ServiceBuilder::new("oxide/zone-network-setup") + .add_property_group(config_builder) + .add_instance(ServiceInstanceBuilder::new("default")); + // TODO: I'm unsure about the name here, should it be something other than "omicron"? + let profile = + ProfileBuilder::new("omicron").add_service(nw_setup); + profile + .add_to_zone(&self.inner.log, &installed_zone) + .await + .map_err(|err| { + Error::io( + "Failed to setup zone-network-setup profile", + err, + ) + })?; + } _ => {} } @@ -1635,8 +1634,6 @@ impl ServiceManager { let dns_service = Self::dns_install(info).await?; // Configure the CockroachDB service. - let datalink = installed_zone.get_control_vnic_name(); - let gateway = &info.underlay_address.to_string(); let address = SocketAddr::new( IpAddr::V6(*underlay_address), COCKROACH_PORT, @@ -1645,8 +1642,6 @@ impl ServiceManager { let listen_port = &address.port().to_string(); let cockroachdb_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("store", "astring", "/data"); diff --git a/smf/cockroachdb/manifest.xml b/smf/cockroachdb/manifest.xml index b4e69f6376..3a9b1a7cb8 100644 --- a/smf/cockroachdb/manifest.xml +++ b/smf/cockroachdb/manifest.xml @@ -11,6 +11,11 @@ + + + + @@ -23,8 +28,6 @@ - - diff --git a/smf/cockroachdb/method_script.sh b/smf/cockroachdb/method_script.sh index 0566a6d5f7..e8b02eb1eb 100755 --- a/smf/cockroachdb/method_script.sh +++ b/smf/cockroachdb/method_script.sh @@ -9,11 +9,6 @@ set -o pipefail LISTEN_ADDR="$(svcprop -c -p config/listen_addr "${SMF_FMRI}")" LISTEN_PORT="$(svcprop -c -p config/listen_port "${SMF_FMRI}")" DATASTORE="$(svcprop -c -p config/store "${SMF_FMRI}")" -DATALINK="$(svcprop -c -p config/datalink "${SMF_FMRI}")" -GATEWAY="$(svcprop -c -p config/gateway "${SMF_FMRI}")" - -# TODO: Removeme once the zone networking setup service is functional -/opt/oxide/zone-networking-cli/bin/zone-networking -d $DATALINK -l $LISTEN_ADDR -g $GATEWAY # We need to tell CockroachDB the DNS names or IP addresses of the other nodes # in the cluster. Look these up in internal DNS. Per the recommendations in diff --git a/smf/zone_network_setup/manifest.xml b/smf/zone-network-setup/manifest.xml similarity index 69% rename from smf/zone_network_setup/manifest.xml rename to smf/zone-network-setup/manifest.xml index 849688980e..84de8b6652 100644 --- a/smf/zone_network_setup/manifest.xml +++ b/smf/zone-network-setup/manifest.xml @@ -1,22 +1,27 @@ - + - + - - + - + + + + +