Skip to content

Commit 999169f

Browse files
committed
Report wait conditions in blueprint planner status
1 parent 3aa4aba commit 999169f

File tree

4 files changed

+59
-9
lines changed

4 files changed

+59
-9
lines changed

dev-tools/omdb/src/bin/omdb/nexus.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use nexus_types::deployment::ClickhouseMode;
4545
use nexus_types::deployment::ClickhousePolicy;
4646
use nexus_types::deployment::OximeterReadMode;
4747
use nexus_types::deployment::OximeterReadPolicy;
48+
use nexus_types::deployment::WaitCondition;
4849
use nexus_types::internal_api::background::AbandonedVmmReaperStatus;
4950
use nexus_types::internal_api::background::BlueprintPlannerStatus;
5051
use nexus_types::internal_api::background::BlueprintRendezvousStatus;
@@ -1218,6 +1219,13 @@ fn print_task_abandoned_vmm_reaper(details: &serde_json::Value) {
12181219
}
12191220

12201221
fn print_task_blueprint_planner(details: &serde_json::Value) {
1222+
fn print_waiting_on(waiting_on: &[WaitCondition]) {
1223+
let n = waiting_on.len();
1224+
if n > 0 {
1225+
println!(" waiting on {n} events: {waiting_on:?}");
1226+
}
1227+
}
1228+
12211229
let status =
12221230
match serde_json::from_value::<BlueprintPlannerStatus>(details.clone())
12231231
{
@@ -1237,20 +1245,32 @@ fn print_task_blueprint_planner(details: &serde_json::Value) {
12371245
BlueprintPlannerStatus::Error(error) => {
12381246
println!(" task did not complete successfully: {error}");
12391247
}
1240-
BlueprintPlannerStatus::Unchanged { parent_blueprint_id } => {
1248+
BlueprintPlannerStatus::Unchanged {
1249+
parent_blueprint_id,
1250+
waiting_on,
1251+
} => {
12411252
println!(" plan unchanged from parent {parent_blueprint_id}");
1253+
print_waiting_on(&waiting_on);
12421254
}
1243-
BlueprintPlannerStatus::Planned { parent_blueprint_id, error } => {
1255+
BlueprintPlannerStatus::Planned {
1256+
parent_blueprint_id,
1257+
error,
1258+
waiting_on,
1259+
} => {
12441260
println!(
12451261
" planned new blueprint from parent {parent_blueprint_id}, \
12461262
but could not make it the target: {error}"
12471263
);
1264+
print_waiting_on(&waiting_on);
12481265
}
1249-
BlueprintPlannerStatus::Targeted { blueprint_id, .. } => {
1266+
BlueprintPlannerStatus::Targeted {
1267+
blueprint_id, waiting_on, ..
1268+
} => {
12501269
println!(
12511270
" planned new blueprint {blueprint_id}, \
12521271
and made it the current target"
12531272
);
1273+
print_waiting_on(&waiting_on);
12541274
}
12551275
}
12561276
}

nexus/reconfigurator/planning/src/planner.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ impl<'a> Planner<'a> {
184184
Ok(self.blueprint.build())
185185
}
186186

187+
pub fn plan_and_wait_conditions(
188+
mut self,
189+
) -> Result<(Blueprint, Vec<WaitCondition>), Error> {
190+
let conditions = self.waiting_on.drain(..).collect();
191+
Ok((self.plan()?, conditions))
192+
}
193+
187194
fn check_input_validity(&self) -> Result<(), Error> {
188195
if self.input.target_internal_dns_zone_count() > INTERNAL_DNS_REDUNDANCY
189196
{

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl BlueprintPlanner {
142142
));
143143
}
144144
};
145-
let blueprint = match planner.plan() {
145+
let (blueprint, waiting_on) = match planner.plan_and_wait_conditions() {
146146
Ok(blueprint) => blueprint,
147147
Err(error) => {
148148
error!(&opctx.log, "can't plan: {error}");
@@ -161,7 +161,10 @@ impl BlueprintPlanner {
161161
"blueprint unchanged from current target";
162162
"parent_blueprint_id" => %parent_blueprint_id,
163163
);
164-
return BlueprintPlannerStatus::Unchanged { parent_blueprint_id };
164+
return BlueprintPlannerStatus::Unchanged {
165+
parent_blueprint_id,
166+
waiting_on,
167+
};
165168
}
166169

167170
// We have a fresh blueprint; save it.
@@ -227,13 +230,18 @@ impl BlueprintPlanner {
227230
return BlueprintPlannerStatus::Planned {
228231
parent_blueprint_id,
229232
error: format!("{error}"),
233+
waiting_on,
230234
};
231235
}
232236
}
233237

234238
// We have a new target!
235239
self.tx_blueprint.send_replace(Some(Arc::new((target, blueprint))));
236-
BlueprintPlannerStatus::Targeted { parent_blueprint_id, blueprint_id }
240+
BlueprintPlannerStatus::Targeted {
241+
parent_blueprint_id,
242+
blueprint_id,
243+
waiting_on,
244+
}
237245
}
238246
}
239247

@@ -314,6 +322,7 @@ mod test {
314322
BlueprintPlannerStatus::Targeted {
315323
parent_blueprint_id,
316324
blueprint_id,
325+
waiting_on: _,
317326
} if parent_blueprint_id == initial_blueprint.id
318327
&& blueprint_id != initial_blueprint.id =>
319328
{
@@ -343,6 +352,7 @@ mod test {
343352
status,
344353
BlueprintPlannerStatus::Unchanged {
345354
parent_blueprint_id: blueprint_id,
355+
waiting_on: vec![],
346356
}
347357
);
348358

@@ -405,6 +415,7 @@ mod test {
405415
status,
406416
BlueprintPlannerStatus::Unchanged {
407417
parent_blueprint_id: blueprint_id,
418+
waiting_on: vec![],
408419
}
409420
);
410421
}

nexus/types/src/internal_api/background.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5+
use crate::deployment::WaitCondition;
56
use crate::external_api::views;
67
use chrono::DateTime;
78
use chrono::Utc;
@@ -471,15 +472,26 @@ pub enum BlueprintPlannerStatus {
471472

472473
/// Planning produced a blueprint identital to the current target,
473474
/// so we threw it away and did nothing.
474-
Unchanged { parent_blueprint_id: BlueprintUuid },
475+
Unchanged {
476+
parent_blueprint_id: BlueprintUuid,
477+
waiting_on: Vec<WaitCondition>,
478+
},
475479

476480
/// Planning produced a new blueprint, but we failed to make it
477481
/// the current target and so deleted it.
478-
Planned { parent_blueprint_id: BlueprintUuid, error: String },
482+
Planned {
483+
parent_blueprint_id: BlueprintUuid,
484+
error: String,
485+
waiting_on: Vec<WaitCondition>,
486+
},
479487

480488
/// Planing succeeded, and we saved and made the new blueprint the
481489
/// current target.
482-
Targeted { parent_blueprint_id: BlueprintUuid, blueprint_id: BlueprintUuid },
490+
Targeted {
491+
parent_blueprint_id: BlueprintUuid,
492+
blueprint_id: BlueprintUuid,
493+
waiting_on: Vec<WaitCondition>,
494+
},
483495
}
484496

485497
/// The status of a `alert_dispatcher` background task activation.

0 commit comments

Comments
 (0)