Skip to content

Commit

Permalink
Enable zone network setup service
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Dec 21, 2023
1 parent f53bd68 commit b722106
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ members = [
"wicket",
"wicketd",
"workspace-hack",
"zone-networking-cli",
"zone-network-setup",
]

default-members = [
Expand Down Expand Up @@ -136,7 +136,7 @@ default-members = [
"wicket-dbg",
"wicket",
"wicketd",
"zone-networking-cli",
"zone-network-setup",
]
resolver = "2"

Expand Down
42 changes: 13 additions & 29 deletions package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
81 changes: 38 additions & 43 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
})?;
}
_ => {}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions smf/cockroachdb/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<service_fmri value='svc:/milestone/multi-user:default' />
</dependency>

<dependency name='zone_network_setup' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/oxide/zone-network-setup:default' />
</dependency>

<exec_method type='method' name='start'
exec='/opt/oxide/lib/svc/manifest/cockroachdb.sh'
timeout_seconds='0'>
Expand All @@ -23,8 +28,6 @@
<exec_method type='method' name='stop' exec=':kill' timeout_seconds='0' />

<property_group name='config' type='application'>
<propval name='datalink' type='astring' value='unknown' />
<propval name='gateway' type='astring' value='unknown' />
<propval name='listen_addr' type='astring' value='unknown' />
<propval name='listen_port' type='astring' value='unknown' />
<propval name='store' type='astring' value='unknown' />
Expand Down
5 changes: 0 additions & 5 deletions smf/cockroachdb/method_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='zone_network_setup'>
<service_bundle type='manifest' name='zone-network-setup'>

<service name='oxide/zone_network_setup' type='service' version='1'>
<service name='oxide/zone-network-setup' type='service' version='1'>
<create_default_instance enabled='true' />

<!-- Run after the operating system's svc:/network/physical service is done. -->
<dependency name='network' grouping='require_all' restart_on='none'
<dependency name='physical' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/network/physical' />
<service_fmri value='svc:/network/physical:default' />
</dependency>

<!-- TODO: Make svc:/milestone/network depend on this service -->
<dependency name='multi_user' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/milestone/multi-user:default' />
</dependency>

<!-- TODO: Make svc:/milestone/network depend on this service? -->

<!--TODO: Do the actual thing we want to do-->
<exec_method type='method' name='start'
exec='/opt/oxide/lib/svc/manifest/zone_network_setup.sh'
exec='/opt/oxide/lib/svc/manifest/zone-network-setup.sh'
timeout_seconds='0' />

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ LISTEN_ADDR="$(svcprop -c -p config/listen_addr "${SMF_FMRI}")"
DATALINK="$(svcprop -c -p config/datalink "${SMF_FMRI}")"
GATEWAY="$(svcprop -c -p config/gateway "${SMF_FMRI}")"

/opt/oxide/zone-networking-cli/bin/zone-networking -d $DATALINK -l $LISTEN_ADDR -g $GATEWAY
/opt/oxide/zone-network-setup/bin/zone-networking -d $DATALINK -l $LISTEN_ADDR -g $GATEWAY

exit $SMF_EXIT_OK
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "zone-networking-cli"
name = "zone-network-setup"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
Expand Down

0 comments on commit b722106

Please sign in to comment.