Skip to content

[inventory] Add display implementation for NTP timesync #8652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -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 orphaned datasets
all disks reconciled successfully
all datasets reconciled successfully
Expand Down Expand Up @@ -1296,6 +1297,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 orphaned datasets
all disks reconciled successfully
all datasets reconciled successfully
Expand Down Expand Up @@ -1496,6 +1498,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 orphaned datasets
all disks reconciled successfully
all datasets reconciled successfully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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 orphaned datasets
all disks reconciled successfully
all datasets reconciled successfully
Expand Down Expand Up @@ -288,6 +289,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 orphaned datasets
all disks reconciled successfully
all datasets reconciled successfully
Expand Down Expand Up @@ -383,6 +385,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 orphaned datasets
all disks reconciled successfully
all datasets reconciled successfully
Expand Down
31 changes: 30 additions & 1 deletion nexus/types/src/inventory/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use uuid::Uuid;

use crate::inventory::{
CabooseWhich, Collection, Dataset, PhysicalDisk, RotPageWhich, SledAgent,
Zpool,
TimeSync, Zpool,
};

/// Code to display inventory collections.
Expand Down Expand Up @@ -693,6 +693,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);
if orphaned_datasets.is_empty() {
Expand Down Expand Up @@ -780,6 +788,27 @@ fn display_sleds(
Ok(())
}

fn display_ntp_status(
ledgered_sled_config: &OmicronSledConfig,
ntp_timesync: &IdOrdMap<TimeSync>,
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")?,
};
Comment on lines +803 to +807
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh also should we report something here about how time isn't synced? maybe some kind of delta?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be reasonable to do this - but I think it would require a change in the inventory collection / schema representation. currently, we're basically just storing a boolean to identify "is this sync'd or not".


Ok(())
}

fn display_boot_partition_contents(
boot_partitions: &BootPartitionContents,
f: &mut dyn fmt::Write,
Expand Down
Loading