Skip to content

Commit

Permalink
Set switch zone initialization stage for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Aug 1, 2024
1 parent e7c73d3 commit 085a4a4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
23 changes: 15 additions & 8 deletions sled-agent/src/bootstrap/early_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,19 @@ impl<'a> EarlyNetworkSetup<'a> {
rack_network_config: &RackNetworkConfig,
switch_zone_underlay_ip: Ipv6Addr,
) -> Result<Vec<PortConfig>, EarlyNetworkSetupError> {
let log = self.log.new(o!("stage" => "switch zone initialization"));
// First, we have to know which switch we are: ask MGS.
info!(
self.log,
log,
"Determining physical location of our switch zone at \
{switch_zone_underlay_ip}",
);
let mgs_client = MgsClient::new(
&format!("http://[{}]:{}", switch_zone_underlay_ip, MGS_PORT),
self.log.new(o!("component" => "MgsClient")),
self.log.new(o!(
"component" => "MgsClient",
"stage" => "switch zone initialization",
)),
);
let switch_slot = retry_notify(
retry_policy_local(),
Expand All @@ -381,7 +385,7 @@ impl<'a> EarlyNetworkSetup<'a> {
},
|error, delay| {
warn!(
self.log,
log,
"Failed to get switch ID from MGS (retrying in {delay:?})";
"error" => ?error,
);
Expand Down Expand Up @@ -410,7 +414,7 @@ impl<'a> EarlyNetworkSetup<'a> {
.collect::<Vec<_>>();

info!(
self.log,
log,
"Initializing {} Uplinks on {switch_location:?} at \
{switch_zone_underlay_ip}",
our_ports.len(),
Expand All @@ -419,7 +423,10 @@ impl<'a> EarlyNetworkSetup<'a> {
&format!("http://[{}]:{}", switch_zone_underlay_ip, DENDRITE_PORT),
dpd_client::ClientState {
tag: OMICRON_DPD_TAG.into(),
log: self.log.new(o!("component" => "DpdClient")),
log: self.log.new(o!(
"component" => "DpdClient",
"stage" => "switch zone initialization",
)),
},
);

Expand All @@ -432,9 +439,9 @@ impl<'a> EarlyNetworkSetup<'a> {
self.wait_for_dendrite(&dpd).await;

info!(
self.log,
log,
"Configuring default uplink on switch";
"config" => #?dpd_port_settings
"config" => ?dpd_port_settings
);
dpd.port_settings_apply(
&port_id,
Expand All @@ -454,7 +461,7 @@ impl<'a> EarlyNetworkSetup<'a> {
"http://{}",
&SocketAddrV6::new(switch_zone_underlay_ip, MGD_PORT, 0, 0)
),
self.log.clone(),
log.clone(),
);

let mut config: Option<BgpConfig> = None;
Expand Down
5 changes: 4 additions & 1 deletion sled-agent/src/bootstrap/pre_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ impl BootstrapAgentStartup {
// exist before entering any zones.
illumos_utils::running_zone::ensure_contract_reaper(&base_log);

let log = base_log.new(o!("component" => "BootstrapAgentStartup"));
let log = base_log.new(o!(
"component" => "BootstrapAgentStartup",
"stage" => "switch zone initialization",
));

// Perform several blocking startup tasks first; we move `config` and
// `log` into this task, and on success, it gives them back to us.
Expand Down
11 changes: 10 additions & 1 deletion sled-agent/src/hardware_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ impl HardwareMonitor {
let tofino_loaded =
self.tofino_manager.become_ready(service_manager);
if tofino_loaded {
info!(
self.log,
"Tofino ASIC is loaded. Activating switch zone on scrimlet";
"stage" => "switch zone initialization"
);
self.activate_switch().await;
}
}
Expand Down Expand Up @@ -234,7 +239,11 @@ impl HardwareMonitor {
)
.await
{
error!(self.log, "Failed to activate switch"; e);
error!(
self.log,
"Failed to activate switch"; e,
"stage" => "switch zone initialization"
);
}
}
TofinoManager::NotReady { tofino_loaded } => {
Expand Down
7 changes: 5 additions & 2 deletions sled-agent/src/long_running_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub struct LongRunningTaskHandles {
pub zone_bundler: ZoneBundler,
}

// TODO: SOme logging here
/// Spawn all long running tasks
pub async fn spawn_all_longrunning_tasks(
log: &Logger,
Expand Down Expand Up @@ -183,7 +184,7 @@ fn spawn_hardware_monitor(
hardware_manager: &HardwareManager,
storage_handle: &StorageHandle,
) -> (oneshot::Sender<SledAgent>, oneshot::Sender<ServiceManager>) {
info!(log, "Starting HardwareMonitor");
info!(log, "Starting HardwareMonitor"; "stage" => "switch zone initialization");
let (mut monitor, sled_agent_started_tx, service_manager_ready_tx) =
HardwareMonitor::new(log, hardware_manager, storage_handle);
tokio::spawn(async move {
Expand All @@ -206,9 +207,11 @@ async fn spawn_bootstore_tasks(
)
.unwrap();

// let log = log.new(o!("stage" => "switch zone initialization"));
// TODO: Add some logging here?
// Create and spawn the bootstore
info!(log, "Starting Bootstore");
let (mut node, node_handle) = bootstore::Node::new(config, log).await;
let (mut node, node_handle) = bootstore::Node::new(config, &log).await;
tokio::spawn(async move { node.run().await });

// Spawn a task for polling DDMD and updating bootstore with peer addresses
Expand Down
7 changes: 6 additions & 1 deletion sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3670,7 +3670,12 @@ impl ServiceManager {
) -> Result<(), Error> {
let log =
self.inner.log.new(o!("stage" => "switch zone initialization"));
info!(log, "Enabling switch zone services on scrimlet");
info!(
log,
"Enabling switch zone services on scrimlet";
"underlay info" => ?underlay_info,
"baseboard" => ?baseboard
);
let mut filesystems: Vec<zone::Fs> = vec![];
let mut data_links: Vec<String> = vec![];

Expand Down

0 comments on commit 085a4a4

Please sign in to comment.