Skip to content

Commit 599481c

Browse files
authored
[Reconfigurator] Fix planner skipping RoT / bootloader updates (add TufArtifactMeta::board) (#8872)
When trying Reconfigurator-based updates on a racklette today with a real TUF repo, the planner skipped all the RoT bootloader and RoT updates because none of the artifact `name`s matched the `board`s reported in inventory. Our tests were assuming these were the same (and in prod they _are_ the same on the SP), but in real TUF repos these don't match: all the RoT and bootloaders report a `board` of `oxide-rot-1`, but the artifact names are pretty varied. This PR adds a new `board` value to the `tuf_artifact` table and the `TufArtifactMeta` struct. Outside of tests, the changes are almost identical to those from #8729 that added a `sign` field in this same spot. This allows us to stop assuming that `artifact.name` == `inventory_caboose.board`, and instead check `artifact.board` == `inventory_caboose.board`. It depends on oxidecomputer/tufaceous#40, which changes the way our fake data is generated to be more consistent with the state of production devices and artifacts. This perturbs some of the reconfiguartor-cli tests a bit, which significantly inflates the diff; the actual code changes here are pretty small.
1 parent a1d9cac commit 599481c

File tree

29 files changed

+450
-862
lines changed

29 files changed

+450
-862
lines changed

Cargo.lock

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

common/src/api/external/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,6 +3421,13 @@ pub struct TufArtifactMeta {
34213421
/// The size of the artifact in bytes.
34223422
pub size: u64,
34233423

3424+
/// Contents of the `BORD` field of a Hubris archive caboose. Only
3425+
/// applicable to artifacts that are Hubris archives.
3426+
///
3427+
/// This field should always be `Some(_)` if `sign` is `Some(_)`, but the
3428+
/// opposite is not true (SP images will have a `board` but not a `sign`).
3429+
pub board: Option<String>,
3430+
34243431
/// Contents of the `SIGN` field of a Hubris archive caboose, i.e.,
34253432
/// an identifier for the set of valid signing keys. Currently only
34263433
/// applicable to RoT image and bootloader artifacts, where it will

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ struct SledUpdateSpArgs {
544544
#[derive(Debug, Args)]
545545
struct SledUpdateRotArgs {
546546
/// id of the sled
547-
sled_id: SledUuid,
547+
sled_id: SledOpt,
548548

549549
/// sets the version reported for the RoT slot a
550550
#[clap(long, required_unless_present_any = &["slot_b"])]
@@ -1713,26 +1713,23 @@ fn cmd_sled_update_rot(
17131713
);
17141714

17151715
let mut state = sim.current_state().to_mut();
1716-
state.system_mut().description_mut().sled_update_rot_versions(
1717-
args.sled_id,
1716+
let system = state.system_mut();
1717+
let sled_id = args.sled_id.to_sled_id(system.description())?;
1718+
system.description_mut().sled_update_rot_versions(
1719+
sled_id,
17181720
args.slot_a,
17191721
args.slot_b,
17201722
)?;
17211723

17221724
sim.commit_and_bump(
17231725
format!(
1724-
"reconfigurator-cli sled-update-rot: {}: {}",
1725-
args.sled_id,
1726+
"reconfigurator-cli sled-update-rot: {sled_id}: {}",
17261727
labels.join(", "),
17271728
),
17281729
state,
17291730
);
17301731

1731-
Ok(Some(format!(
1732-
"set sled {} RoT settings: {}",
1733-
args.sled_id,
1734-
labels.join(", ")
1735-
)))
1732+
Ok(Some(format!("set sled {sled_id} RoT settings: {}", labels.join(", "))))
17361733
}
17371734

17381735
fn cmd_sled_update_host_phase_1(

dev-tools/reconfigurator-cli/tests/input/cmds-mupdate-update-flow.txt

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,42 @@ blueprint-diff latest
124124
sled-set serial1 mupdate-override unset
125125
inventory-generate
126126

127-
# This will attempt to update the first sled's host OS. Walk through that update
128-
# and the host OS of the two other sleds.
127+
# This will attempt to update the RoT bootloader on the first sled.
129128
blueprint-plan latest latest
130129
blueprint-show latest
131130
blueprint-diff latest
131+
132+
# Update the RoT bootloader.
133+
sled-update-rot-bootloader serial0 --stage0 2.0.0
134+
135+
# If were to generate inventory and replan now, we'd want to update the RoT on
136+
# this sled, then its SP, then its host OS, then repeat all four for the other
137+
# three sleds. That's not the point of this test, so let's short-circuit that a
138+
# bit: we'll go ahead and change inventory to reflect all of these MGS-based
139+
# updates are done on all sleds.
140+
141+
# Finish the MGS-based updates on sled 0.
142+
sled-update-rot serial0 --slot-a 2.0.0
143+
sled-update-sp serial0 --active 2.0.0
132144
sled-update-host-phase2 serial0 --boot-disk B --slot-b 0c0362b640cece5b9a5e86d8fa683bd2eb84c3e7f90731f597197d604ffa76e3
133145
sled-update-host-phase1 serial0 --active B --slot-b 44714733af7600b30a50bfd2cbaf707ff7ee9724073ff70a6732e55a88864cf6
134-
inventory-generate
135146

136-
# Second sled host OS
137-
blueprint-plan latest latest
138-
blueprint-diff latest
147+
# All the MGS-based updates on sled 1.
148+
sled-update-rot-bootloader serial1 --stage0 2.0.0
149+
sled-update-rot serial1 --slot-a 2.0.0
150+
sled-update-sp serial1 --active 2.0.0
139151
sled-update-host-phase2 serial1 --boot-disk B --slot-b 0c0362b640cece5b9a5e86d8fa683bd2eb84c3e7f90731f597197d604ffa76e3
140152
sled-update-host-phase1 serial1 --active B --slot-b 44714733af7600b30a50bfd2cbaf707ff7ee9724073ff70a6732e55a88864cf6
141-
inventory-generate
142153

143-
# Third sled host OS
144-
blueprint-plan latest latest
145-
blueprint-diff latest
154+
# All the MGS-based updates on sled 2.
155+
sled-update-rot-bootloader serial2 --stage0 2.0.0
156+
sled-update-rot serial2 --slot-a 2.0.0
157+
sled-update-sp serial2 --active 2.0.0
146158
sled-update-host-phase2 serial2 --boot-disk B --slot-b 0c0362b640cece5b9a5e86d8fa683bd2eb84c3e7f90731f597197d604ffa76e3
147159
sled-update-host-phase1 serial2 --active B --slot-b 44714733af7600b30a50bfd2cbaf707ff7ee9724073ff70a6732e55a88864cf6
148-
inventory-generate
149160

150-
# All host OS updates complete
161+
# All MGS-based updates complete.
162+
inventory-generate
151163
blueprint-plan latest latest
152164
blueprint-diff latest
153165

dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,10 +1058,10 @@ Sled serial0
10581058
A 0101010101010101010101010101010101010101010101010101010101010101
10591059
B 0202020202020202020202020202020202020202020202020202020202020202
10601060
cabooses:
1061-
SLOT BOARD NAME VERSION GIT_COMMIT SIGN
1062-
SpSlot0 SimGimletSp SimGimletSp 0.0.1 unknown n/a
1063-
RotSlotA SimRot SimRot 0.0.2 unknown SimRot
1064-
Stage0 SimRotStage0 SimRotStage0 0.0.1 unknown SimRotStage0
1061+
SLOT BOARD NAME VERSION GIT_COMMIT SIGN
1062+
SpSlot0 SimGimletSp SimGimletSp 0.0.1 unknown n/a
1063+
RotSlotA SimRot SimRot 0.0.2 unknown sign-gimlet
1064+
Stage0 SimRot SimRot 0.0.1 unknown sign-gimlet
10651065
RoT pages:
10661066
SLOT DATA_BASE64
10671067
RoT: active slot: slot A
@@ -1083,10 +1083,10 @@ Sled serial1
10831083
A 0101010101010101010101010101010101010101010101010101010101010101
10841084
B 0202020202020202020202020202020202020202020202020202020202020202
10851085
cabooses:
1086-
SLOT BOARD NAME VERSION GIT_COMMIT SIGN
1087-
SpSlot0 SimGimletSp SimGimletSp 0.0.1 unknown n/a
1088-
RotSlotA SimRot SimRot 0.0.2 unknown SimRot
1089-
Stage0 SimRotStage0 SimRotStage0 0.0.1 unknown SimRotStage0
1086+
SLOT BOARD NAME VERSION GIT_COMMIT SIGN
1087+
SpSlot0 SimGimletSp SimGimletSp 0.0.1 unknown n/a
1088+
RotSlotA SimRot SimRot 0.0.2 unknown sign-gimlet
1089+
Stage0 SimRot SimRot 0.0.1 unknown sign-gimlet
10901090
RoT pages:
10911091
SLOT DATA_BASE64
10921092
RoT: active slot: slot A
@@ -1108,10 +1108,10 @@ Sled serial2
11081108
A 0101010101010101010101010101010101010101010101010101010101010101
11091109
B 0202020202020202020202020202020202020202020202020202020202020202
11101110
cabooses:
1111-
SLOT BOARD NAME VERSION GIT_COMMIT SIGN
1112-
SpSlot0 SimGimletSp SimGimletSp 0.0.1 unknown n/a
1113-
RotSlotA SimRot SimRot 0.0.2 unknown SimRot
1114-
Stage0 SimRotStage0 SimRotStage0 0.0.1 unknown SimRotStage0
1111+
SLOT BOARD NAME VERSION GIT_COMMIT SIGN
1112+
SpSlot0 SimGimletSp SimGimletSp 0.0.1 unknown n/a
1113+
RotSlotA SimRot SimRot 0.0.2 unknown sign-gimlet
1114+
Stage0 SimRot SimRot 0.0.1 unknown sign-gimlet
11151115
RoT pages:
11161116
SLOT DATA_BASE64
11171117
RoT: active slot: slot A

0 commit comments

Comments
 (0)