Skip to content

Commit

Permalink
Self assembling Oximeter zone
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Nov 21, 2023
1 parent 08041d6 commit c4dc50c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 21 deletions.
3 changes: 2 additions & 1 deletion package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
56 changes: 45 additions & 11 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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?);
}
_ => {}
}

Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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,
Expand Down
22 changes: 13 additions & 9 deletions smf/oximeter/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@
<service_bundle type='manifest' name='oximeter'>

<service name='oxide/oximeter' type='service' version='1'>
<create_default_instance enabled='false' />
<create_default_instance enabled='true' />

<dependency name='multi_user' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/milestone/multi-user:default' />
</dependency>

<method_context>
<method_environment>
<envvar name="LD_LIBRARY_PATH" value="/opt/ooce/pgsql-13/lib/amd64" />
</method_environment>
</method_context>
<exec_method type='method' name='start'
exec='ctrun -l child -o noorphan,regent /opt/oxide/oximeter/bin/oximeter run /var/svc/manifest/site/oximeter/config.toml --address %{config/address} --id %{config/id} &amp;'
timeout_seconds='0' />
exec='/opt/oxide/lib/svc/manifest/oximeter.sh'
timeout_seconds='0'>
<method_context>
<method_environment>
<envvar name="LD_LIBRARY_PATH" value="/opt/ooce/pgsql-13/lib/amd64" />
</method_environment>
</method_context>
</exec_method>
<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='id' type='astring' value='unknown' />
<propval name='address' type='astring' value='unknown' />
</property_group>

<property_group name='startd' type='framework'>
Expand Down

0 comments on commit c4dc50c

Please sign in to comment.