Skip to content

Commit

Permalink
Log whether step is part of the switch initialisation process
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Jul 31, 2024
1 parent 42507eb commit bbf84ae
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 35 deletions.
9 changes: 7 additions & 2 deletions illumos-utils/src/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::dladm::Etherstub;
use crate::link::{Link, VnicAllocator};
use crate::opte::{Port, PortTicket};
use crate::svc::wait_for_service;
use crate::zone::{AddressRequest, ZONE_PREFIX};
use crate::zone::{AddressRequest, ZONE_PREFIX, SWITCH_ZONE_NAME};
use crate::zpool::{PathInPool, ZpoolName};
use camino::{Utf8Path, Utf8PathBuf};
use camino_tempfile::Utf8TempDir;
Expand Down Expand Up @@ -469,7 +469,12 @@ impl RunningZone {
/// Note that the zone must already be configured to be booted.
pub async fn boot(zone: InstalledZone) -> Result<Self, BootError> {
// Boot the zone.
info!(zone.log, "Booting {} zone", zone.name);
let boot_zone_log = format!("Booting {} zone", zone.name);
if zone.name == SWITCH_ZONE_NAME {
info!(zone.log, "{boot_zone_log}"; "stage" => "switch zone initialization");
} else {
info!(zone.log, "{boot_zone_log}");
}

Zones::boot(&zone.name).await?;

Expand Down
5 changes: 3 additions & 2 deletions illumos-utils/src/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub const ROUTE: &str = "/usr/sbin/route";
// TODO: These could become enums
pub const ZONE_PREFIX: &str = "oxz_";
pub const PROPOLIS_ZONE_PREFIX: &str = "oxz_propolis-server_";
pub const SWITCH_ZONE_NAME: &str = "oxz_switch";

#[derive(thiserror::Error, Debug)]
enum Error {
Expand Down Expand Up @@ -477,9 +478,9 @@ impl Zones {
}
});

if zone == "oxz_switch" && vnic.is_none() {
if zone == SWITCH_ZONE_NAME && vnic.is_none() {
Err(GetBootstrapInterfaceError::NotFound { zone: zone.to_string() })
} else if zone != "oxz_switch" && vnic.is_some() {
} else if zone != SWITCH_ZONE_NAME && vnic.is_some() {
Err(GetBootstrapInterfaceError::Unexpected {
zone: zone.to_string(),
})
Expand Down
4 changes: 2 additions & 2 deletions sled-agent/src/bootstrap/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use futures::StreamExt;
use illumos_utils::dladm;
use illumos_utils::zfs;
use illumos_utils::zone;
use illumos_utils::zone::Zones;
use illumos_utils::zone::{Zones, SWITCH_ZONE_NAME};
use internal_dns::resolver::Resolver;
use omicron_common::address::{Ipv6Subnet, AZ_PREFIX};
use omicron_common::ledger;
Expand Down Expand Up @@ -625,7 +625,7 @@ impl Inner {
// We only return one error though -- hopefully that's enough to
// signal to the caller that this failed.
.for_each_concurrent_then_try(CONCURRENCY_CAP, |zone| async move {
if zone.name() != "oxz_switch" {
if zone.name() != SWITCH_ZONE_NAME {
Zones::halt_and_remove(zone.name()).await?;
}
Ok(())
Expand Down
9 changes: 7 additions & 2 deletions sled-agent/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! Utilities to build SMF profiles.
use illumos_utils::running_zone::InstalledZone;
use illumos_utils::zone::SWITCH_ZONE_NAME;
use slog::Logger;
use std::{
collections::BTreeMap,
Expand All @@ -31,8 +32,12 @@ impl ProfileBuilder {
log: &Logger,
installed_zone: &InstalledZone,
) -> Result<(), std::io::Error> {
info!(log, "Profile for {}:\n{}", installed_zone.name(), self);

let profile_info = format!("Profile for {}:\n{}", installed_zone.name(), self);
if installed_zone.name() == SWITCH_ZONE_NAME {
info!(log, "{profile_info}"; "stage" => "switch zone initialization");
} else {
info!(log, "{profile_info}");
}
let profile_path = installed_zone.site_profile_xml_path();

tokio::fs::write(&profile_path, format!("{self}").as_bytes()).await?;
Expand Down
77 changes: 50 additions & 27 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ impl OmicronZone {
fn name(&self) -> &str {
self.runtime.name()
}

fn zone_type(&self) -> &str {
self.config.zone.zone_type.kind().zone_prefix()
}
}

type ZoneMap = BTreeMap<String, OmicronZone>;
Expand Down Expand Up @@ -3058,7 +3062,10 @@ impl ServiceManager {
for result in results {
match result {
Ok(zone) => {
info!(self.inner.log, "Zone started"; "zone" => zone.name());
info!(
self.inner.log, "Omicron zone (type {}) started", zone.zone_type();
"zone" => zone.name()
);
new_zones.push(zone);
}
Err((name, error)) => {
Expand Down Expand Up @@ -3661,7 +3668,12 @@ impl ServiceManager {
underlay_info: Option<(Ipv6Addr, Option<&RackNetworkConfig>)>,
baseboard: Baseboard,
) -> Result<(), Error> {
info!(self.inner.log, "Ensuring scrimlet services (enabling services)");
let log =
self.inner.log.new(o!("stage" => "switch zone initialization"));
info!(
log,
"Enabling switch zone services on scrimlet"
);
let mut filesystems: Vec<zone::Fs> = vec![];
let mut data_links: Vec<String> = vec![];

Expand Down Expand Up @@ -3781,7 +3793,8 @@ impl ServiceManager {
switch_zone_ip: Ipv6Addr,
rack_network_config: &RackNetworkConfig,
) -> Result<(), Error> {
let log = &self.inner.log;
let log =
&self.inner.log.new(o!("stage" => "switch zone initialization"));

// Configure uplinks via DPD in our switch zone.
let our_ports = EarlyNetworkSetup::new(log)
Expand All @@ -3798,6 +3811,9 @@ impl ServiceManager {
&self,
our_ports: Vec<HostPortConfig>,
) -> Result<(), Error> {
let log =
&self.inner.log.new(o!("stage" => "switch zone initialization"));

// We expect the switch zone to be running, as we're called immediately
// after `ensure_zone()` above and we just successfully configured
// uplinks via DPD running in our switch zone. If somehow we're in any
Expand All @@ -3820,7 +3836,7 @@ impl ServiceManager {
}
};

info!(self.inner.log, "Setting up uplinkd service");
info!(log, "Setting up uplinkd service");
let smfh = SmfHelper::new(&zone, &SwitchService::Uplink);

// We want to delete all the properties in the `uplinks` group, but we
Expand All @@ -3831,9 +3847,13 @@ impl ServiceManager {

for port_config in &our_ports {
for addr in &port_config.addrs {
info!(self.inner.log, "configuring port: {port_config:?}");
let prop_name = format!("uplinks/{}_0", port_config.port);
info!(
log,
"Adding new property to uplinkd service. Name: {prop_name} Value: {}", addr.to_string(),
);
smfh.addpropvalue_type(
&format!("uplinks/{}_0", port_config.port,),
&prop_name,
&addr.to_string(),
"astring",
)?;
Expand Down Expand Up @@ -3888,7 +3908,8 @@ impl ServiceManager {
filesystems: Vec<zone::Fs>,
data_links: Vec<String>,
) -> Result<(), Error> {
let log = &self.inner.log;
let log =
self.inner.log.new(o!("stage" => "switch zone initialization"));

let mut sled_zone = self.inner.switch_zone.lock().await;
let zone_typestr = "switch";
Expand Down Expand Up @@ -3936,15 +3957,15 @@ impl ServiceManager {
continue;
}
info!(
self.inner.log,
log,
"Ensuring address {} exists",
addr.to_string()
);
let addr_request =
AddressRequest::new_static(IpAddr::V6(*addr), None);
zone.ensure_address(addr_request).await?;
info!(
self.inner.log,
log,
"Ensuring address {} exists - OK",
addr.to_string()
);
Expand All @@ -3954,7 +3975,7 @@ impl ServiceManager {
// available now as well.
if let Some(info) = self.inner.sled_info.get() {
info!(
self.inner.log,
log,
"Ensuring there is a default route";
"gateway" => ?info.underlay_address,
);
Expand All @@ -3968,7 +3989,7 @@ impl ServiceManager {
Err(e) => {
if e.to_string().contains("entry exists") {
info!(
self.inner.log,
log,
"Default route already exists";
"gateway" => ?info.underlay_address,
)
Expand All @@ -3984,7 +4005,7 @@ impl ServiceManager {

match service {
SwitchService::ManagementGatewayService => {
info!(self.inner.log, "configuring MGS service");
info!(log, "configuring MGS service");
// Remove any existing `config/address` values
// without deleting the property itself.
smfh.delpropvalue_default_instance(
Expand Down Expand Up @@ -4017,7 +4038,7 @@ impl ServiceManager {
)?;
} else {
error!(
self.inner.log,
log,
concat!(
"rack_id not present,",
" even though underlay address exists"
Expand All @@ -4027,13 +4048,13 @@ impl ServiceManager {

smfh.refresh()?;
info!(
self.inner.log,
log,
"refreshed MGS service with new configuration"
)
}
SwitchService::Dendrite { .. } => {
info!(
self.inner.log,
log,
"configuring dendrite service"
);
if let Some(info) = self.inner.sled_info.get() {
Expand All @@ -4047,7 +4068,7 @@ impl ServiceManager {
)?;
} else {
info!(
self.inner.log,
log,
"no rack_id/sled_id available yet"
);
}
Expand Down Expand Up @@ -4080,15 +4101,15 @@ impl ServiceManager {
}
}
smfh.refresh()?;
info!(self.inner.log, "refreshed dendrite service with new configuration")
info!(log, "refreshed dendrite service with new configuration")
}
SwitchService::Wicketd { .. } => {
if let Some(&address) = first_address {
let rack_subnet =
Ipv6Subnet::<AZ_PREFIX>::new(address);

info!(
self.inner.log, "configuring wicketd";
log, "configuring wicketd";
"rack_subnet" => %rack_subnet.net().addr(),
);

Expand All @@ -4098,16 +4119,16 @@ impl ServiceManager {
)?;

smfh.refresh()?;
info!(self.inner.log, "refreshed wicketd service with new configuration")
info!(log, "refreshed wicketd service with new configuration")
} else {
error!(
self.inner.log,
log,
"underlay address unexpectedly missing",
);
}
}
SwitchService::Lldpd { .. } => {
info!(self.inner.log, "configuring lldp service");
info!(log, "configuring lldp service");
smfh.delpropvalue_default_instance(
"config/address",
"*",
Expand All @@ -4120,7 +4141,7 @@ impl ServiceManager {
)?;
}
smfh.refresh()?;
info!(self.inner.log, "refreshed lldpd service with new configuration")
info!(log, "refreshed lldpd service with new configuration")
}
SwitchService::Tfport { .. } => {
// Since tfport and dpd communicate using localhost,
Expand All @@ -4140,7 +4161,7 @@ impl ServiceManager {
// nothing to configure
}
SwitchService::Mgd => {
info!(self.inner.log, "configuring mgd service");
info!(log, "configuring mgd service");
smfh.delpropvalue_default_instance(
"config/dns_servers",
"*",
Expand Down Expand Up @@ -4173,12 +4194,12 @@ impl ServiceManager {
}
smfh.refresh()?;
info!(
self.inner.log,
log,
"refreshed mgd service with new configuration"
)
}
SwitchService::MgDdm { mode } => {
info!(self.inner.log, "configuring mg-ddm service");
info!(log, "configuring mg-ddm service");
smfh.delpropvalue_default_instance(
"config/mode",
"*",
Expand Down Expand Up @@ -4219,7 +4240,7 @@ impl ServiceManager {
}
}
smfh.refresh()?;
info!(self.inner.log, "refreshed mg-ddm service with new configuration")
info!(log, "refreshed mg-ddm service with new configuration")
}
}
}
Expand Down Expand Up @@ -4258,6 +4279,8 @@ impl ServiceManager {
return Ok(());
};

let log =
self.inner.log.new(o!("stage" => "switch zone initialization"));
// The switch zone must use the ramdisk in order to receive requests
// from RSS to initialize the rack. This enables the initialization of
// trust quorum to derive disk encryption keys for U.2 devices. If the
Expand All @@ -4268,7 +4291,7 @@ impl ServiceManager {
let zone_request =
SwitchZoneConfigLocal { root, zone: request.clone() };
let zone_args = ZoneArgs::Switch(&zone_request);
info!(self.inner.log, "Starting switch zone",);
info!(log, "Starting switch zone",);
let zone = self
.initialize_zone(zone_args, filesystems, data_links, None)
.await?;
Expand Down

0 comments on commit bbf84ae

Please sign in to comment.