Skip to content

Commit 99e9584

Browse files
authored
[reconfigurator-cli] Fixes and improvements for RoT update testing (#8904)
Follow up to #8893
1 parent d4df3f7 commit 99e9584

File tree

6 files changed

+972
-68
lines changed

6 files changed

+972
-68
lines changed

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use chrono::{DateTime, Utc};
1010
use clap::{ArgAction, ValueEnum};
1111
use clap::{Args, Parser, Subcommand};
1212
use daft::Diffable;
13+
use gateway_types::rot::RotSlot;
1314
use iddqd::IdOrdMap;
1415
use indent_write::fmt::IndentWriter;
1516
use internal_dns_types::diff::DnsDiff;
@@ -22,7 +23,7 @@ use nexus_reconfigurator_planning::blueprint_builder::BlueprintBuilder;
2223
use nexus_reconfigurator_planning::example::ExampleSystemBuilder;
2324
use nexus_reconfigurator_planning::planner::Planner;
2425
use nexus_reconfigurator_planning::system::{
25-
SledBuilder, SledInventoryVisibility, SystemDescription,
26+
RotStateOverrides, SledBuilder, SledInventoryVisibility, SystemDescription,
2627
};
2728
use nexus_reconfigurator_simulation::{BlueprintId, CollectionId, SimState};
2829
use nexus_reconfigurator_simulation::{SimStateBuilder, SimTufRepoSource};
@@ -553,6 +554,27 @@ struct SledUpdateRotArgs {
553554
/// sets the version reported for the RoT slot b
554555
#[clap(long, required_unless_present_any = &["slot_a"])]
555556
slot_b: Option<ExpectedVersion>,
557+
558+
/// sets whether we expect the "A" or "B" slot to be active
559+
#[clap(long)]
560+
active_slot: Option<RotSlot>,
561+
562+
/// sets the persistent boot preference written into the current
563+
/// authoritative CFPA page (ping or pong).
564+
#[clap(long)]
565+
persistent_boot_preference: Option<RotSlot>,
566+
567+
/// sets the pending persistent boot preference written into the CFPA
568+
/// scratch page that will become the persistent boot preference in the
569+
/// authoritative CFPA page upon reboot, unless CFPA update of the
570+
/// authoritative page fails for some reason
571+
#[clap(long, num_args(0..=1))]
572+
pending_persistent_boot_preference: Option<Option<RotSlot>>,
573+
574+
/// sets the transient boot preference, which overrides persistent
575+
/// preference selection for a single boot (unimplemented)
576+
#[clap(long, num_args(0..=1),)]
577+
transient_boot_preference: Option<Option<RotSlot>>,
556578
}
557579

558580
#[derive(Debug, Args)]
@@ -1706,6 +1728,31 @@ fn cmd_sled_update_rot(
17061728
if let Some(slot_b) = &args.slot_b {
17071729
labels.push(format!("slot b -> {}", slot_b));
17081730
}
1731+
if let Some(active_slot) = &args.active_slot {
1732+
labels.push(format!("active slot -> {}", active_slot));
1733+
}
1734+
1735+
if let Some(persistent_boot_preference) = &args.persistent_boot_preference {
1736+
labels.push(format!(
1737+
"persistent boot preference -> {}",
1738+
persistent_boot_preference
1739+
));
1740+
}
1741+
1742+
if let Some(pending_persistent_boot_preference) =
1743+
&args.pending_persistent_boot_preference
1744+
{
1745+
labels.push(format!(
1746+
"pending persistent boot preference -> {:?}",
1747+
pending_persistent_boot_preference
1748+
));
1749+
}
1750+
if let Some(transient_boot_preference) = &args.transient_boot_preference {
1751+
labels.push(format!(
1752+
"transient boot preference -> {:?}",
1753+
transient_boot_preference
1754+
));
1755+
}
17091756

17101757
assert!(
17111758
!labels.is_empty(),
@@ -1717,8 +1764,16 @@ fn cmd_sled_update_rot(
17171764
let sled_id = args.sled_id.to_sled_id(system.description())?;
17181765
system.description_mut().sled_update_rot_versions(
17191766
sled_id,
1720-
args.slot_a,
1721-
args.slot_b,
1767+
RotStateOverrides {
1768+
active_slot_override: args.active_slot,
1769+
slot_a_version_override: args.slot_a,
1770+
slot_b_version_override: args.slot_b,
1771+
persistent_boot_preference_override: args
1772+
.persistent_boot_preference,
1773+
pending_persistent_boot_preference_override: args
1774+
.pending_persistent_boot_preference,
1775+
transient_boot_preference_override: args.transient_boot_preference,
1776+
},
17221777
)?;
17231778

17241779
sim.commit_and_bump(

dev-tools/reconfigurator-cli/tests/input/cmds-target-release.txt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ blueprint-diff latest
5252
# reflect that update has completed as well. Like before, collect inventory from
5353
# it and use that collection for the next step. This should report that the
5454
# update completed, remove that update, and add one for another sled.
55-
sled-update-rot 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 --slot-a 1.0.0
55+
sled-update-rot 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 --slot-b 1.0.0 --active-slot b --persistent-boot-preference b
5656
inventory-generate
5757
blueprint-plan latest latest
5858
blueprint-diff latest
@@ -127,7 +127,7 @@ blueprint-diff latest
127127

128128
# Now simulate the update completing successfully.
129129
# Like before, we should see a pending SP update for this sled.
130-
sled-update-rot 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --slot-a 1.0.0
130+
sled-update-rot 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c --slot-b 1.0.0 --active-slot b --persistent-boot-preference b
131131
inventory-generate
132132
blueprint-plan latest latest
133133
blueprint-diff latest
@@ -175,9 +175,38 @@ inventory-generate
175175
blueprint-plan latest latest
176176
blueprint-diff latest
177177

178-
# Update the RoT on the last sled.
178+
# Now let's simulate an RoT update that hasn't completed by setting the persistent
179+
# boot preference to a different slot than the active one. This should cause the
180+
# planner to mark it as impossible, and replace it.
181+
set ignore-impossible-mgs-updates-since now
182+
sled-update-rot d81c6a84-79b8-4958-ae41-ea46c9b19763 --slot-b 1.0.0 --active-slot a --persistent-boot-preference b
183+
inventory-generate
184+
blueprint-plan latest latest
185+
blueprint-diff latest
186+
187+
# An RoT update cannot continue if pending persistent boot preference is set.
188+
# The slot B is set to a different version so it does not appear to be active
189+
# and on the correct version, and the corresponding checks are triggered.
190+
# Like before, this should cause the planner to mark it as impossible, and
191+
# replace it.
192+
set ignore-impossible-mgs-updates-since now
193+
sled-update-rot d81c6a84-79b8-4958-ae41-ea46c9b19763 --slot-b 1.1.0 --active-slot b --persistent-boot-preference b --pending-persistent-boot-preference b
194+
inventory-generate
195+
blueprint-plan latest latest
196+
blueprint-diff latest
197+
198+
# We do the same for transient boot preference. Note that we need to set the
199+
# pending-persistent-boot-preference back to None
200+
set ignore-impossible-mgs-updates-since now
201+
sled-update-rot d81c6a84-79b8-4958-ae41-ea46c9b19763 --slot-b 1.1.0 --active-slot b --persistent-boot-preference b --transient-boot-preference b --pending-persistent-boot-preference
202+
inventory-generate
203+
blueprint-plan latest latest
204+
blueprint-diff latest
205+
206+
# Update the RoT on the last sled. Note that we need to set the
207+
# transient-boot-preference back to None
179208
# There should be one last pending SP update.
180-
sled-update-rot d81c6a84-79b8-4958-ae41-ea46c9b19763 --slot-a 1.0.0
209+
sled-update-rot d81c6a84-79b8-4958-ae41-ea46c9b19763 --slot-b 1.0.0 --active-slot b --persistent-boot-preference b --transient-boot-preference
181210
inventory-generate
182211
blueprint-plan latest latest
183212
blueprint-diff latest

dev-tools/reconfigurator-cli/tests/input/cmds.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ sled-update-rot dde1c0e2-b10d-4621-b420-f179f7a7a00a --slot-a 4.0.0 --slot-b inv
2424
sled-show dde1c0e2-b10d-4621-b420-f179f7a7a00a
2525
sled-update-rot dde1c0e2-b10d-4621-b420-f179f7a7a00a --slot-a 4.0.0 --slot-b 5.0.0
2626
sled-show dde1c0e2-b10d-4621-b420-f179f7a7a00a
27+
sled-update-rot dde1c0e2-b10d-4621-b420-f179f7a7a00a --slot-b 6.0.0 --active-slot b
28+
sled-show dde1c0e2-b10d-4621-b420-f179f7a7a00a
29+
sled-update-rot dde1c0e2-b10d-4621-b420-f179f7a7a00a --slot-b 6.0.0 --active-slot b --persistent-boot-preference b
30+
sled-show dde1c0e2-b10d-4621-b420-f179f7a7a00a
31+
sled-update-rot dde1c0e2-b10d-4621-b420-f179f7a7a00a --slot-b 6.0.0 --active-slot a --persistent-boot-preference a --pending-persistent-boot-preference b --transient-boot-preference a
32+
sled-show dde1c0e2-b10d-4621-b420-f179f7a7a00a
33+
sled-update-rot dde1c0e2-b10d-4621-b420-f179f7a7a00a --slot-a 7.0.0 --pending-persistent-boot-preference --transient-boot-preference
34+
sled-show dde1c0e2-b10d-4621-b420-f179f7a7a00a
2735

2836
sled-update-sp dde1c0e2-b10d-4621-b420-f179f7a7a00a
2937
sled-update-sp dde1c0e2-b10d-4621-b420-f179f7a7a00a --active 1.0.0

0 commit comments

Comments
 (0)