Skip to content

Commit c7673aa

Browse files
jgallagheriliana
andauthored
PlanningReport: Use JSON-safe map keys (#9080)
(This also includes #9077 to avoid failing CI.) --------- Co-authored-by: iliana etaoin <iliana@oxide.computer>
1 parent 04d108e commit c7673aa

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

dev-tools/reconfigurator-cli/tests/output/cmds-target-release-stdout

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7944,9 +7944,9 @@ planning report:
79447944
* skipping noop zone image source check on sled d81c6a84-79b8-4958-ae41-ea46c9b19763: all 9 zones are already from artifacts
79457945
* 3 remaining out-of-date zones
79467946
* 3 zones waiting to be expunged:
7947-
* zone 0c71b3b2-6ceb-4e8f-b020-b08675e83038 (nexus): image out-of-date, but zone's nexus_generation 1 is still active
7948-
* zone 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6 (nexus): image out-of-date, but zone's nexus_generation 1 is still active
7949-
* zone 466a9f29-62bf-4e63-924a-b9efdb86afec (nexus): image out-of-date, but zone's nexus_generation 1 is still active
7947+
* zone 0c71b3b2-6ceb-4e8f-b020-b08675e83038: nexus image out-of-date, but nexus_generation 1 is still active
7948+
* zone 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6: nexus image out-of-date, but nexus_generation 1 is still active
7949+
* zone 466a9f29-62bf-4e63-924a-b9efdb86afec: nexus image out-of-date, but nexus_generation 1 is still active
79507950
* updating top-level nexus_generation to: 2
79517951

79527952

@@ -8035,9 +8035,9 @@ planning report:
80358035
* skipping noop zone image source check on sled d81c6a84-79b8-4958-ae41-ea46c9b19763: all 9 zones are already from artifacts
80368036
* 3 remaining out-of-date zones
80378037
* 3 zones waiting to be expunged:
8038-
* zone 0c71b3b2-6ceb-4e8f-b020-b08675e83038 (nexus): image out-of-date, but zone's nexus_generation 1 is still active
8039-
* zone 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6 (nexus): image out-of-date, but zone's nexus_generation 1 is still active
8040-
* zone 466a9f29-62bf-4e63-924a-b9efdb86afec (nexus): image out-of-date, but zone's nexus_generation 1 is still active
8038+
* zone 0c71b3b2-6ceb-4e8f-b020-b08675e83038: nexus image out-of-date, but nexus_generation 1 is still active
8039+
* zone 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6: nexus image out-of-date, but nexus_generation 1 is still active
8040+
* zone 466a9f29-62bf-4e63-924a-b9efdb86afec: nexus image out-of-date, but nexus_generation 1 is still active
80418041

80428042

80438043

nexus/src/app/background/tasks/blueprint_planner.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use omicron_common::api::external::LookupType;
2222
use omicron_uuid_kinds::CollectionUuid;
2323
use omicron_uuid_kinds::GenericUuid as _;
2424
use serde_json::json;
25+
use slog_error_chain::InlineErrorChain;
2526
use std::sync::Arc;
2627
use tokio::sync::watch::{self, Receiver, Sender};
2728

@@ -292,7 +293,16 @@ impl BackgroundTask for BlueprintPlanner {
292293
&'a mut self,
293294
opctx: &'a OpContext,
294295
) -> BoxFuture<'a, serde_json::Value> {
295-
Box::pin(async move { json!(self.plan(opctx).await) })
296+
Box::pin(async move {
297+
let status = self.plan(opctx).await;
298+
match serde_json::to_value(status) {
299+
Ok(val) => val,
300+
Err(err) => json!({
301+
"error": format!("could not serialize task status: {}",
302+
InlineErrorChain::new(&err)),
303+
}),
304+
}
305+
})
296306
}
297307
}
298308

nexus/types/src/deployment/planning_report.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,8 @@ pub struct PlanningZoneUpdatesStepReport {
848848
pub out_of_date_zones: BTreeMap<SledUuid, Vec<PlanningOutOfDateZone>>,
849849
pub expunged_zones: BTreeMap<SledUuid, Vec<BlueprintZoneConfig>>,
850850
pub updated_zones: BTreeMap<SledUuid, Vec<BlueprintZoneConfig>>,
851-
pub unsafe_zones: BTreeMap<BlueprintZoneConfig, ZoneUnsafeToShutdown>,
852-
pub waiting_zones: BTreeMap<BlueprintZoneConfig, ZoneWaitingToExpunge>,
851+
pub unsafe_zones: BTreeMap<OmicronZoneUuid, ZoneUnsafeToShutdown>,
852+
pub waiting_zones: BTreeMap<OmicronZoneUuid, ZoneWaitingToExpunge>,
853853
}
854854

855855
impl PlanningZoneUpdatesStepReport {
@@ -934,15 +934,15 @@ impl PlanningZoneUpdatesStepReport {
934934
zone: &BlueprintZoneConfig,
935935
reason: ZoneUnsafeToShutdown,
936936
) {
937-
self.unsafe_zones.insert(zone.clone(), reason);
937+
self.unsafe_zones.insert(zone.id, reason);
938938
}
939939

940940
pub fn waiting_zone(
941941
&mut self,
942942
zone: &BlueprintZoneConfig,
943943
reason: ZoneWaitingToExpunge,
944944
) {
945-
self.waiting_zones.insert(zone.clone(), reason);
945+
self.waiting_zones.insert(zone.id, reason);
946946
}
947947
}
948948

@@ -1001,28 +1001,16 @@ impl fmt::Display for PlanningZoneUpdatesStepReport {
10011001
if !unsafe_zones.is_empty() {
10021002
let (n, s) = plural_map(unsafe_zones);
10031003
writeln!(f, "* {n} zone{s} not ready to shut down safely:")?;
1004-
for (zone, reason) in unsafe_zones.iter() {
1005-
writeln!(
1006-
f,
1007-
" * zone {} ({}): {}",
1008-
zone.id,
1009-
zone.zone_type.kind().report_str(),
1010-
reason,
1011-
)?;
1004+
for (zone_id, reason) in unsafe_zones.iter() {
1005+
writeln!(f, " * zone {zone_id}: {reason}")?;
10121006
}
10131007
}
10141008

10151009
if !waiting_zones.is_empty() {
10161010
let (n, s) = plural_map(waiting_zones);
10171011
writeln!(f, "* {n} zone{s} waiting to be expunged:")?;
1018-
for (zone, reason) in waiting_zones.iter() {
1019-
writeln!(
1020-
f,
1021-
" * zone {} ({}): {}",
1022-
zone.id,
1023-
zone.zone_type.kind().report_str(),
1024-
reason,
1025-
)?;
1012+
for (zone_id, reason) in waiting_zones.iter() {
1013+
writeln!(f, " * zone {zone_id}: {reason}")?;
10261014
}
10271015
}
10281016

@@ -1076,7 +1064,9 @@ pub enum ZoneUnsafeToShutdown {
10761064
impl fmt::Display for ZoneUnsafeToShutdown {
10771065
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10781066
match self {
1079-
Self::Cockroachdb { reason } => write!(f, "{reason}"),
1067+
Self::Cockroachdb { reason } => {
1068+
write!(f, "cockroach unsafe to shut down: {reason}")
1069+
}
10801070
Self::BoundaryNtp {
10811071
total_boundary_ntp_zones: t,
10821072
synchronized_count: s,
@@ -1107,7 +1097,7 @@ impl fmt::Display for ZoneWaitingToExpunge {
11071097
Self::Nexus { zone_generation } => {
11081098
write!(
11091099
f,
1110-
"image out-of-date, but zone's nexus_generation \
1100+
"nexus image out-of-date, but nexus_generation \
11111101
{zone_generation} is still active"
11121102
)
11131103
}

0 commit comments

Comments
 (0)