Skip to content

[reconfigurator] RoT planner support #8421

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dev-tools/reconfigurator-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ iddqd.workspace = true
indent_write.workspace = true
internal-dns-types.workspace = true
itertools.workspace = true
gateway-types.workspace = true
newtype-uuid.workspace = true
nexus-inventory.workspace = true
nexus-reconfigurator-blippy.workspace = true
Expand Down
89 changes: 89 additions & 0 deletions dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fn process_command(
Commands::SledRemove(args) => cmd_sled_remove(sim, args),
Commands::SledShow(args) => cmd_sled_show(sim, args),
Commands::SledSetPolicy(args) => cmd_sled_set_policy(sim, args),
Commands::SledUpdateRot(args) => cmd_sled_update_rot(sim, args),
Commands::SledUpdateSp(args) => cmd_sled_update_sp(sim, args),
Commands::SiloList => cmd_silo_list(sim),
Commands::SiloAdd(args) => cmd_silo_add(sim, args),
Expand Down Expand Up @@ -263,6 +264,8 @@ enum Commands {
SledShow(SledArgs),
/// set a sled's policy
SledSetPolicy(SledSetPolicyArgs),
/// simulate updating the sled's RoT versions
SledUpdateRot(SledUpdateRotArgs),
/// simulate updating the sled's SP versions
SledUpdateSp(SledUpdateSpArgs),

Expand Down Expand Up @@ -390,6 +393,24 @@ struct SledUpdateSpArgs {
inactive: Option<ExpectedVersion>,
}

#[derive(Debug, Args)]
struct SledUpdateRotArgs {
/// id of the sled
sled_id: SledUuid,

/// sets the version reported for the RoT slot a
#[clap(long, required_unless_present_any = &["slot_b"])]
slot_a: Option<ExpectedVersion>,

/// sets the version reported for the RoT slot b
#[clap(long, required_unless_present_any = &["slot_a"])]
slot_b: Option<ExpectedVersion>,
// TODO: In a follow up PR we could set other fields as well.
// They would be useful to simulate failures.
// These would be: active_slot, persistent_boot_preference,
// transient_boot_preference and pending_persistent_boot_preference.
}

#[derive(Debug, Args)]
struct SledRemoveArgs {
/// id of the sled
Expand Down Expand Up @@ -914,6 +935,15 @@ fn cmd_sled_show(
let sled_id = args.sled_id;
let sp_active_version = description.sled_sp_active_version(sled_id)?;
let sp_inactive_version = description.sled_sp_inactive_version(sled_id)?;
let rot_active_slot = description.sled_rot_active_slot(sled_id)?;
let rot_slot_a_version = description.sled_rot_slot_a_version(sled_id)?;
let rot_slot_b_version = description.sled_rot_slot_b_version(sled_id)?;
let rot_persistent_boot_preference =
description.sled_rot_persistent_boot_preference(sled_id)?;
let rot_pending_persistent_boot_preference =
description.sled_rot_pending_persistent_boot_preference(sled_id)?;
let rot_transient_boot_preference =
description.sled_rot_transient_boot_preference(sled_id)?;
let planning_input = description
.to_planning_input_builder()
.context("failed to generate planning_input builder")?
Expand All @@ -926,6 +956,24 @@ fn cmd_sled_show(
swriteln!(s, "subnet {}", sled_resources.subnet.net());
swriteln!(s, "SP active version: {:?}", sp_active_version);
swriteln!(s, "SP inactive version: {:?}", sp_inactive_version);
swriteln!(s, "RoT active slot: {}", rot_active_slot);
swriteln!(s, "RoT slot A version: {:?}", rot_slot_a_version);
swriteln!(s, "RoT slot B version: {:?}", rot_slot_b_version);
swriteln!(
s,
"RoT persistent boot preference: {}",
rot_persistent_boot_preference
);
swriteln!(
s,
"RoT pending persistent boot preference: {:?}",
rot_pending_persistent_boot_preference
);
swriteln!(
s,
"RoT transient boot preference: {:?}",
rot_transient_boot_preference
);
swriteln!(s, "zpools ({}):", sled_resources.zpools.len());
for (zpool, disk) in &sled_resources.zpools {
swriteln!(s, " {:?}", zpool);
Expand Down Expand Up @@ -993,6 +1041,47 @@ fn cmd_sled_update_sp(
)))
}

fn cmd_sled_update_rot(
sim: &mut ReconfiguratorSim,
args: SledUpdateRotArgs,
) -> anyhow::Result<Option<String>> {
let mut labels = Vec::new();

if let Some(slot_a) = &args.slot_a {
labels.push(format!("slot a -> {}", slot_a));
}
if let Some(slot_b) = &args.slot_b {
labels.push(format!("slot b -> {}", slot_b));
}

assert!(
!labels.is_empty(),
"clap configuration requires that at least one argument is specified"
);

let mut state = sim.current_state().to_mut();
state.system_mut().description_mut().sled_update_rot_versions(
args.sled_id,
args.slot_a,
args.slot_b,
)?;

sim.commit_and_bump(
format!(
"reconfigurator-cli sled-update-rot: {}: {}",
args.sled_id,
labels.join(", "),
),
state,
);

Ok(Some(format!(
"set sled {} RoT settings: {}",
args.sled_id,
labels.join(", ")
)))
}

fn cmd_inventory_list(
sim: &mut ReconfiguratorSim,
) -> anyhow::Result<Option<String>> {
Expand Down
52 changes: 38 additions & 14 deletions dev-tools/reconfigurator-cli/tests/input/target-release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,65 @@ sled-list
blueprint-list
inventory-list

# First step: upgrade one SP.
# First step: upgrade one RoT.
blueprint-plan dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 f45ba181-4b56-42cc-a762-874d90184a43
blueprint-diff dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1

# If we generate another plan, there should be no change.
blueprint-plan 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1 f45ba181-4b56-42cc-a762-874d90184a43
blueprint-diff 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1 58d5e830-0884-47d8-a7cd-b2b3751adeb4

# Now, update the simulated SP to reflect that the update completed.
# Now, update the simulated RoT to reflect that the update completed.
# Collect inventory from it and use that collection for another planning step.
# This should report that the update completed, remove that update, and add one
# for another sled.
sled-update-sp 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 --active 1.0.0
# for an SP on the same sled.
sled-update-rot 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 --slot-a 1.0.0
inventory-generate
blueprint-plan 58d5e830-0884-47d8-a7cd-b2b3751adeb4 eb0796d5-ab8a-4f7b-a884-b4aeacb8ab51
blueprint-diff 58d5e830-0884-47d8-a7cd-b2b3751adeb4 af934083-59b5-4bf6-8966-6fb5292c29e1

# This time, make it more interesting. Change the inactive slot contents of
# the simulated SP. This should make the configured update impossible and cause
# the planner to fix it.
sled-update-sp 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --inactive 0.5.0
# After the RoT update has completed, we update the simulated SP to reflect that
# update has completed as well.
# Like before, collect inventory from it and use that collection for the next step.
# This should report that the update completed, remove that update, and add one
# for another sled.
sled-update-sp 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 --active 1.0.0
inventory-generate
blueprint-plan af934083-59b5-4bf6-8966-6fb5292c29e1 61f451b3-2121-4ed6-91c7-a550054f6c21
blueprint-diff af934083-59b5-4bf6-8966-6fb5292c29e1 df06bb57-ad42-4431-9206-abff322896c7

# Now simulate the update completing successfully.
# Another planning step should try to update the last sled.
sled-update-sp 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --active 1.0.0
# This time, make it more interesting. Change the inactive slot contents of
# the simulated RoT. This should make the configured update impossible and cause
# the planner to fix it.
sled-update-rot 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --slot-b 0.5.0
inventory-generate
blueprint-plan df06bb57-ad42-4431-9206-abff322896c7 b1bda47d-2c19-4fba-96e3-d9df28db7436
blueprint-diff df06bb57-ad42-4431-9206-abff322896c7 7f976e0d-d2a5-4eeb-9e82-c82bc2824aba

# Finish updating the last sled and do one more planning run.
# There should be nothing left to do.
sled-update-sp d81c6a84-79b8-4958-ae41-ea46c9b19763 --active 1.0.0
# Now simulate the update completing successfully.
# Like before, we should see a pending SP update for this sled.
sled-update-rot 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --slot-a 1.0.0
inventory-generate
blueprint-plan 7f976e0d-d2a5-4eeb-9e82-c82bc2824aba a71f7a73-35a6-45e8-acbe-f1c5925eed69
blueprint-diff 7f976e0d-d2a5-4eeb-9e82-c82bc2824aba 9034c710-3e57-45f3-99e5-4316145e87ac

# Let's simulate the successful SP update as well.
# Another couple of planning steps should try to update the last sled.
sled-update-sp 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --active 1.0.0
inventory-generate
blueprint-plan 9034c710-3e57-45f3-99e5-4316145e87ac 0b5efbb3-0b1b-4bbf-b7d8-a2d6fca074c6
blueprint-diff 9034c710-3e57-45f3-99e5-4316145e87ac d60afc57-f15d-476c-bd0f-b1071e2bb976

# Update the RoT on the last sled.
# There should be one last pending SP update.
sled-update-rot d81c6a84-79b8-4958-ae41-ea46c9b19763 --slot-a 1.0.0
inventory-generate
blueprint-plan d60afc57-f15d-476c-bd0f-b1071e2bb976 78f72e8d-46a9-40a9-8618-602f54454d80
blueprint-diff d60afc57-f15d-476c-bd0f-b1071e2bb976 a5a8f242-ffa5-473c-8efd-2acf2dc0b736

# Finish updating the last sled and do one more planning run.
# Now we should see there's nothing left to do!
sled-update-sp d81c6a84-79b8-4958-ae41-ea46c9b19763 --active 1.0.0
inventory-generate
blueprint-plan a5a8f242-ffa5-473c-8efd-2acf2dc0b736 39363465-89ae-4ac2-9be1-099068da9d45
blueprint-diff a5a8f242-ffa5-473c-8efd-2acf2dc0b736 626487fa-7139-45ec-8416-902271fc730b
12 changes: 12 additions & 0 deletions dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ serial serial1
subnet fd00:1122:3344:102::/64
SP active version: Some("0.0.1")
SP inactive version: None
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
055c4910-b641-46d9-b52d-313aae9d9cbf (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-055c4910-b641-46d9-b52d-313aae9d9cbf" }, disk_id: 6a0cb52f-5cc2-48a5-9f44-ac8dea3ac45b (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -403,6 +409,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("0.0.1")
SP inactive version: None
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (4):
0477165a-a72e-4814-b8d6-74aa02cb2040 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-0477165a-a72e-4814-b8d6-74aa02cb2040" }, disk_id: 6a5a31ab-4edc-44e0-a7a1-4190bfe582f7 (physical_disk), policy: InService, state: Active }
Expand Down
42 changes: 42 additions & 0 deletions dev-tools/reconfigurator-cli/tests/output/cmds-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("0.0.1")
SP inactive version: None
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -77,6 +83,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("1.0.0")
SP inactive version: None
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -109,6 +121,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("1.0.0")
SP inactive version: Some("2.0.0")
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -141,6 +159,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("3.0.0")
SP inactive version: Some("2.0.0")
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -173,6 +197,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("4.0.0")
SP inactive version: None
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -205,6 +235,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("4.0.0")
SP inactive version: Some("5.0.0")
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down Expand Up @@ -269,6 +305,12 @@ serial serial0
subnet fd00:1122:3344:101::/64
SP active version: Some("4.0.0")
SP inactive version: Some("5.0.0")
RoT active slot: A
RoT slot A version: Some("0.0.2")
RoT slot B version: None
RoT persistent boot preference: A
RoT pending persistent boot preference: None
RoT transient boot preference: None
zpools (10):
674c6591-11be-44f2-9df1-db3bb663ec01 (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-674c6591-11be-44f2-9df1-db3bb663ec01" }, disk_id: a52a7c57-7fd0-4139-8293-bda299523c53 (physical_disk), policy: InService, state: Active }
Expand Down
Loading
Loading