Skip to content

Commit 0bc4570

Browse files
authored
[reconfigurator-cli] Add blueprint-blippy subcommand (#7368)
Also added a backcompat note to confirm #7229 on deployed systems.
1 parent de6a440 commit 0bc4570

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-tools/reconfigurator-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ indent_write.workspace = true
2222
internal-dns-types.workspace = true
2323
itertools.workspace = true
2424
nexus-inventory.workspace = true
25+
nexus-reconfigurator-blippy.workspace = true
2526
nexus-reconfigurator-planning.workspace = true
2627
nexus-reconfigurator-simulation.workspace = true
2728
nexus-sled-agent-shared.workspace = true

dev-tools/reconfigurator-cli/src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use internal_dns_types::diff::DnsDiff;
1515
use itertools::Itertools;
1616
use log_capture::LogCapture;
1717
use nexus_inventory::CollectionBuilder;
18+
use nexus_reconfigurator_blippy::Blippy;
19+
use nexus_reconfigurator_blippy::BlippyReportSortKey;
1820
use nexus_reconfigurator_planning::blueprint_builder::BlueprintBuilder;
1921
use nexus_reconfigurator_planning::example::ExampleSystemBuilder;
2022
use nexus_reconfigurator_planning::planner::Planner;
@@ -276,6 +278,7 @@ fn process_entry(
276278
Commands::InventoryList => cmd_inventory_list(sim),
277279
Commands::InventoryGenerate => cmd_inventory_generate(sim),
278280
Commands::BlueprintList => cmd_blueprint_list(sim),
281+
Commands::BlueprintBlippy(args) => cmd_blueprint_blippy(sim, args),
279282
Commands::BlueprintEdit(args) => cmd_blueprint_edit(sim, args),
280283
Commands::BlueprintPlan(args) => cmd_blueprint_plan(sim, args),
281284
Commands::BlueprintShow(args) => cmd_blueprint_show(sim, args),
@@ -339,6 +342,8 @@ enum Commands {
339342

340343
/// list all blueprints
341344
BlueprintList,
345+
/// run blippy on a blueprint
346+
BlueprintBlippy(BlueprintArgs),
342347
/// run planner to generate a new blueprint
343348
BlueprintPlan(BlueprintPlanArgs),
344349
/// edit contents of a blueprint directly
@@ -755,6 +760,17 @@ fn cmd_blueprint_list(
755760
Ok(Some(table))
756761
}
757762

763+
fn cmd_blueprint_blippy(
764+
sim: &mut ReconfiguratorSim,
765+
args: BlueprintArgs,
766+
) -> anyhow::Result<Option<String>> {
767+
let state = sim.current_state();
768+
let blueprint = state.system().get_blueprint(args.blueprint_id)?;
769+
let report =
770+
Blippy::new(&blueprint).into_report(BlippyReportSortKey::Severity);
771+
Ok(Some(format!("{}", report.display())))
772+
}
773+
758774
fn cmd_blueprint_plan(
759775
sim: &mut ReconfiguratorSim,
760776
args: BlueprintPlanArgs,

nexus/reconfigurator/blippy/src/blippy.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ pub struct Note {
2929

3030
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
3131
pub enum Severity {
32-
/// Indicator of a serious problem that means the blueprint is invalid.
32+
/// Indicates an issue with a blueprint that should be corrected by a future
33+
/// planning run.
34+
BackwardsCompatibility,
35+
/// Indicates a serious problem that means the blueprint is invalid.
3336
Fatal,
3437
}
3538

3639
impl fmt::Display for Severity {
3740
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3841
match self {
42+
Severity::BackwardsCompatibility => write!(f, "BACKCOMPAT"),
3943
Severity::Fatal => write!(f, "FATAL"),
4044
}
4145
}
@@ -149,6 +153,8 @@ pub enum SledKind {
149153
ZpoolMissingZoneRootDataset { zpool: ZpoolUuid },
150154
/// A zone's filesystem dataset is missing from `blueprint_datasets`.
151155
ZoneMissingFilesystemDataset { zone: BlueprintZoneConfig },
156+
/// A zone's filesystem pool value is missing from `blueprint_datasets`.
157+
ZoneMissingFilesystemPool { zone: BlueprintZoneConfig },
152158
/// A zone's durable dataset is missing from `blueprint_datasets`.
153159
ZoneMissingDurableDataset { zone: BlueprintZoneConfig },
154160
/// A zone's durable dataset and transient root dataset are on different
@@ -309,6 +315,15 @@ impl fmt::Display for SledKind {
309315
zone.id,
310316
)
311317
}
318+
SledKind::ZoneMissingFilesystemPool { zone } => {
319+
write!(
320+
f,
321+
"in-service zone's filesytem pool property is missing: \
322+
{:?} {}",
323+
zone.zone_type.kind(),
324+
zone.id,
325+
)
326+
}
312327
SledKind::ZoneMissingDurableDataset { zone } => {
313328
write!(
314329
f,

nexus/reconfigurator/blippy/src/checks.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,13 @@ fn check_datasets(blippy: &mut Blippy<'_>) {
454454
}
455455
}
456456
None => {
457-
// TODO-john Add a Severity::BackwardsCompatibility and note the
458-
// missing filesystem pool
457+
blippy.push_sled_note(
458+
sled_id,
459+
Severity::BackwardsCompatibility,
460+
SledKind::ZoneMissingFilesystemPool {
461+
zone: zone_config.clone(),
462+
},
463+
);
459464
}
460465
}
461466

0 commit comments

Comments
 (0)