Skip to content

[26/n] [reconfigurator-cli] add a way to temporarily hide a sled from inventory #8500

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

Merged
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
51 changes: 50 additions & 1 deletion dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use nexus_reconfigurator_blippy::BlippyReportSortKey;
use nexus_reconfigurator_planning::blueprint_builder::BlueprintBuilder;
use nexus_reconfigurator_planning::example::ExampleSystemBuilder;
use nexus_reconfigurator_planning::planner::Planner;
use nexus_reconfigurator_planning::system::{SledBuilder, SystemDescription};
use nexus_reconfigurator_planning::system::{
SledBuilder, SledInventoryVisibility, SystemDescription,
};
use nexus_reconfigurator_simulation::{BlueprintId, SimState};
use nexus_reconfigurator_simulation::{SimStateBuilder, SimTufRepoSource};
use nexus_reconfigurator_simulation::{SimTufRepoDescription, Simulator};
Expand Down Expand Up @@ -374,6 +376,8 @@ struct SledSetArgs {
enum SledSetCommand {
/// set the policy for this sled
Policy(SledSetPolicyArgs),
#[clap(flatten)]
Visibility(SledSetVisibilityCommand),
}

#[derive(Debug, Args)]
Expand All @@ -383,6 +387,27 @@ struct SledSetPolicyArgs {
policy: SledPolicyOpt,
}

#[derive(Debug, Subcommand)]
enum SledSetVisibilityCommand {
/// mark a sled hidden from inventory
InventoryHidden,
/// mark a sled visible in inventory
InventoryVisible,
}

impl SledSetVisibilityCommand {
fn to_visibility(&self) -> SledInventoryVisibility {
match self {
SledSetVisibilityCommand::InventoryHidden => {
SledInventoryVisibility::Hidden
}
SledSetVisibilityCommand::InventoryVisible => {
SledInventoryVisibility::Visible
}
}
}
}

#[derive(Clone, Copy, Debug, ValueEnum)]
enum SledPolicyOpt {
InService,
Expand Down Expand Up @@ -1227,6 +1252,30 @@ fn cmd_sled_set(
);
Ok(Some(format!("set sled {sled_id} policy to {policy}")))
}
SledSetCommand::Visibility(command) => {
let new = command.to_visibility();
let prev = system
.description_mut()
.sled_set_inventory_visibility(sled_id, new)?;
if prev == new {
Ok(Some(format!(
"sled {sled_id} inventory visibility was already set to \
{new}, so no changes were performed",
)))
} else {
sim.commit_and_bump(
format!(
"reconfigurator-cli sled-set inventory visibility: {} \
from {} to {}",
sled_id, prev, new,
),
state,
);
Ok(Some(format!(
"set sled {sled_id} inventory visibility: {prev} -> {new}"
)))
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# so that discretionary zones don't make their way onto it. (We're going to
# expunge it below to test that we don't try and update zone image sources
# on expunged sleds.)
load-example --nsleds 6 --ndisks-per-sled 1 --sled-policy 5:non-provisionable
load-example --nsleds 7 --ndisks-per-sled 1 --sled-policy 5:non-provisionable

sled-list

Expand Down Expand Up @@ -42,9 +42,25 @@ sled-update-install-dataset serial4 --from-repo repo-2.0.0.zip
sled-update-install-dataset serial5 --to-target-release
sled-set serial5 policy expunged

# On the seventh sled, update to the target release but hide the sled
# from inventory. This should prevent changes to the blueprint for
# this sled.
sled-update-install-dataset serial6 --to-target-release
sled-set serial6 inventory-hidden

# Generate an inventory and run a blueprint planning step.
inventory-generate
blueprint-plan latest eb0796d5-ab8a-4f7b-a884-b4aeacb8ab51

# This diff should show expected changes to the blueprint.
blueprint-diff 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1 latest

# Bring the hidden sled back.
sled-set serial6 inventory-visible

# Run another inventory and blueprint planning step.
inventory-generate
blueprint-plan latest 61f451b3-2121-4ed6-91c7-a550054f6c21

# This diff should show changes to the sled that's back in inventory.
blueprint-diff 58d5e830-0884-47d8-a7cd-b2b3751adeb4 latest
Loading
Loading