Skip to content
Open
26 changes: 23 additions & 3 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ impl std::fmt::Display for IpVersion {
///
/// The first address in the range is guaranteed to be no greater than the last
/// address.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, Ord, PartialOrd,
)]
#[serde(untagged)]
pub enum IpRange {
V4(Ipv4Range),
Expand Down Expand Up @@ -548,7 +550,16 @@ impl From<Ipv6Range> for IpRange {
///
/// The first address must be less than or equal to the last address.
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema,
Clone,
Copy,
Debug,
PartialEq,
Eq,
Deserialize,
Serialize,
JsonSchema,
PartialOrd,
Ord,
)]
#[serde(try_from = "AnyIpv4Range")]
pub struct Ipv4Range {
Expand Down Expand Up @@ -612,7 +623,16 @@ impl TryFrom<AnyIpv4Range> for Ipv4Range {
///
/// The first address must be less than or equal to the last address.
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema,
PartialOrd,
Ord,
Clone,
Copy,
Debug,
PartialEq,
Eq,
Deserialize,
Serialize,
JsonSchema,
)]
#[serde(try_from = "AnyIpv6Range")]
pub struct Ipv6Range {
Expand Down
12 changes: 9 additions & 3 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5016,7 +5016,7 @@ async fn cmd_db_dns_diff(
// Load the added and removed items.
use nexus_db_schema::schema::dns_name::dsl;

let added = dsl::dns_name
let mut added = dsl::dns_name
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The changes in this file are so that omdb output doesn't change as a result of unspecified sort order (in this case, of DNS records). This became a problem after I added the "second" Nexus zone to the blueprint (see other comment).

.filter(dsl::dns_zone_id.eq(zone.id))
.filter(dsl::version_added.eq(version.version))
.limit(i64::from(u32::from(limit)))
Expand All @@ -5026,7 +5026,7 @@ async fn cmd_db_dns_diff(
.context("loading added names")?;
check_limit(&added, limit, || "loading added names");

let removed = dsl::dns_name
let mut removed = dsl::dns_name
.filter(dsl::dns_zone_id.eq(zone.id))
.filter(dsl::version_removed.eq(version.version))
.limit(i64::from(u32::from(limit)))
Expand All @@ -5042,6 +5042,11 @@ async fn cmd_db_dns_diff(
);
println!("");

// This is kind of stupid-expensive, but there aren't a lot of records
// here and it's helpful for this output to be stable.
added.sort_by_cached_key(|k| format!("{} {:?}", k.name, k.records()));
removed.sort_by_cached_key(|k| format!("{} {:?}", k.name, k.records()));

for a in added {
print_name("+", &a.name, a.records().context("parsing records"));
}
Expand Down Expand Up @@ -5097,7 +5102,8 @@ async fn cmd_db_dns_names(
}
});

for (name, records) in names {
for (name, mut records) in names {
records.sort();
print_name("", &name, Ok(records));
}
}
Expand Down
44 changes: 36 additions & 8 deletions dev-tools/omdb/src/bin/omdb/nexus/quiesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,23 @@ async fn quiesce_show(
.context("fetching quiesce state")?
.into_inner();
match quiesce.state {
QuiesceState::Undetermined => {
println!("has not yet determined if it is quiescing");
}
QuiesceState::Running => {
println!("running normally (not quiesced, not quiescing)");
}
QuiesceState::WaitingForSagas { time_requested } => {
QuiesceState::DrainingSagas { time_requested } => {
println!(
"quiescing since {} ({} ago)",
humantime::format_rfc3339_millis(time_requested.into()),
format_time_delta(now - time_requested),
);
println!("details: waiting for running sagas to finish");
}
QuiesceState::WaitingForDb {
QuiesceState::DrainingDb {
time_requested,
duration_waiting_for_sagas,
duration_draining_sagas,
..
} => {
println!(
Expand All @@ -87,13 +90,34 @@ async fn quiesce_show(
);
println!(
" previously: waiting for sagas took {}",
format_duration_ms(duration_waiting_for_sagas.into()),
format_duration_ms(duration_draining_sagas.into()),
);
}
QuiesceState::RecordingQuiesce {
time_requested,
duration_draining_sagas,
duration_draining_db,
..
} => {
println!(
"quiescing since {} ({} ago)",
humantime::format_rfc3339_millis(time_requested.into()),
format_time_delta(now - time_requested),
);
println!(
" waiting for sagas took {}",
format_duration_ms(duration_draining_sagas.into()),
);
println!(
" waiting for db quiesce took {}",
format_duration_ms(duration_draining_db.into()),
);
}
QuiesceState::Quiesced {
time_quiesced,
duration_waiting_for_sagas,
duration_waiting_for_db,
duration_draining_sagas,
duration_draining_db,
duration_recording_quiesce,
duration_total,
..
} => {
Expand All @@ -104,11 +128,15 @@ async fn quiesce_show(
);
println!(
" waiting for sagas took {}",
format_duration_ms(duration_waiting_for_sagas.into()),
format_duration_ms(duration_draining_sagas.into()),
);
println!(
" waiting for db quiesce took {}",
format_duration_ms(duration_waiting_for_db.into()),
format_duration_ms(duration_draining_db.into()),
);
println!(
" recording quiesce took {}",
format_duration_ms(duration_recording_quiesce.into()),
);
println!(
" total quiesce time: {}",
Expand Down
Loading
Loading