From 342fca65242b09f038b3a87af934761208ad3952 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 21 Jul 2025 13:49:03 -0700 Subject: [PATCH] [inventory] Add display implementation for NTP timesync --- .../tests/output/cmds-example-stdout | 3 ++ .../output/cmds-mupdate-update-flow-stdout | 3 ++ nexus/types/src/inventory/display.rs | 31 ++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout b/dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout index b17680451a..1569e085c2 100644 --- a/dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout +++ b/dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout @@ -1189,6 +1189,7 @@ LEDGERED SLED CONFIG slot A details UNAVAILABLE: constructed via debug_assume_success() slot B details UNAVAILABLE: constructed via debug_assume_success() last reconciled config: matches ledgered config + no information from NTP for this sled no mupdate override to clear no orphaned datasets all disks reconciled successfully @@ -1297,6 +1298,7 @@ LEDGERED SLED CONFIG slot A details UNAVAILABLE: constructed via debug_assume_success() slot B details UNAVAILABLE: constructed via debug_assume_success() last reconciled config: matches ledgered config + no information from NTP for this sled no mupdate override to clear no orphaned datasets all disks reconciled successfully @@ -1498,6 +1500,7 @@ LEDGERED SLED CONFIG slot A details UNAVAILABLE: constructed via debug_assume_success() slot B details UNAVAILABLE: constructed via debug_assume_success() last reconciled config: matches ledgered config + no information from NTP for this sled no mupdate override to clear no orphaned datasets all disks reconciled successfully diff --git a/dev-tools/reconfigurator-cli/tests/output/cmds-mupdate-update-flow-stdout b/dev-tools/reconfigurator-cli/tests/output/cmds-mupdate-update-flow-stdout index 1721ff728f..a5f54fa7d3 100644 --- a/dev-tools/reconfigurator-cli/tests/output/cmds-mupdate-update-flow-stdout +++ b/dev-tools/reconfigurator-cli/tests/output/cmds-mupdate-update-flow-stdout @@ -184,6 +184,7 @@ LEDGERED SLED CONFIG slot A details UNAVAILABLE: constructed via debug_assume_success() slot B details UNAVAILABLE: constructed via debug_assume_success() last reconciled config: matches ledgered config + no information from NTP for this sled error reading mupdate override, so sled agent didn't attempt to clear it no orphaned datasets all disks reconciled successfully @@ -291,6 +292,7 @@ LEDGERED SLED CONFIG slot A details UNAVAILABLE: constructed via debug_assume_success() slot B details UNAVAILABLE: constructed via debug_assume_success() last reconciled config: matches ledgered config + no information from NTP for this sled mupdate override present, but sled agent was not instructed to clear it no orphaned datasets all disks reconciled successfully @@ -387,6 +389,7 @@ LEDGERED SLED CONFIG slot A details UNAVAILABLE: constructed via debug_assume_success() slot B details UNAVAILABLE: constructed via debug_assume_success() last reconciled config: matches ledgered config + no information from NTP for this sled mupdate override present, but sled agent was not instructed to clear it no orphaned datasets all disks reconciled successfully diff --git a/nexus/types/src/inventory/display.rs b/nexus/types/src/inventory/display.rs index 73f67d49ee..d14129b92e 100644 --- a/nexus/types/src/inventory/display.rs +++ b/nexus/types/src/inventory/display.rs @@ -36,7 +36,7 @@ use uuid::Uuid; use crate::inventory::{ CabooseWhich, Collection, Dataset, PhysicalDisk, RotPageWhich, SledAgent, - Zpool, + TimeSync, Zpool, }; /// Code to display inventory collections. @@ -695,6 +695,14 @@ fn display_sleds( indented = IndentWriter::new(" ", f); } + if let Some(config) = ledgered_sled_config.as_ref() { + display_ntp_status( + config, + &collection.ntp_timesync, + &mut indented, + )?; + } + { let mut indent2 = IndentWriter::new(" ", &mut indented); @@ -841,6 +849,27 @@ fn display_sleds( Ok(()) } +fn display_ntp_status( + ledgered_sled_config: &OmicronSledConfig, + ntp_timesync: &IdOrdMap, + f: &mut dyn fmt::Write, +) -> fmt::Result { + let timesync = ledgered_sled_config + .zones + .keys() + .find_map(|zone_id| ntp_timesync.get(zone_id)); + + match timesync { + None => writeln!(f, "no information from NTP for this sled")?, + Some(ts) if ts.synced => { + writeln!(f, "NTP reports that time is synced")? + } + Some(_) => writeln!(f, "NTP reports that time is NOT synced")?, + }; + + Ok(()) +} + fn display_boot_partition_contents( boot_partitions: &BootPartitionContents, f: &mut dyn fmt::Write,