Skip to content

Commit 5783271

Browse files
authored
Make fake BORD and SIGN values a little more realistic (#40)
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 artifact `board`s. Artifact name matching board is a property that's true for the SP in both fake data and production, but is only true for the bootloader and RoT in the fake data generated by tufaceous. This PR changes the fake data to be more consistent with real data: * TUF artifact `name` does not necessarily match hubris caboose `name` * All RoTs and RoT bootloaders report the same `BORD` * Each target type (sled, switch, psc) has distinct `SIGN` values despite the `BORD` values matching
1 parent ba754fa commit 5783271

File tree

2 files changed

+57
-19
lines changed

2 files changed

+57
-19
lines changed

artifact/src/kind.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,36 @@ impl KnownArtifactKind {
246246
pub fn iter() -> KnownArtifactKindIter {
247247
<Self as IntoEnumIterator>::iter()
248248
}
249+
250+
/// For fake artifacts we generate for tests, what `SIGN` value do we insert
251+
/// in the Hubris caboose for this artifact kind?
252+
pub fn fake_artifact_hubris_sign(&self) -> Option<String> {
253+
match self {
254+
// Only RoT and RoT bootloader artifacts are signed. We want to use
255+
// a distinct sign value for kind of system, just like real systems
256+
// have.
257+
KnownArtifactKind::GimletRot
258+
| KnownArtifactKind::GimletRotBootloader => {
259+
Some("sign-gimlet".to_string())
260+
}
261+
KnownArtifactKind::SwitchRot
262+
| KnownArtifactKind::SwitchRotBootloader => {
263+
Some("sign-switch".to_string())
264+
}
265+
KnownArtifactKind::PscRot | KnownArtifactKind::PscRotBootloader => {
266+
Some("sign-psc".to_string())
267+
}
268+
269+
KnownArtifactKind::GimletSp
270+
| KnownArtifactKind::Host
271+
| KnownArtifactKind::Trampoline
272+
| KnownArtifactKind::InstallinatorDocument
273+
| KnownArtifactKind::ControlPlane
274+
| KnownArtifactKind::Zone
275+
| KnownArtifactKind::PscSp
276+
| KnownArtifactKind::SwitchSp => None,
277+
}
278+
}
249279
}
250280

251281
#[derive(Debug, Error)]

lib/src/assemble/manifest.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,6 @@ impl<'a> FakeDataAttributes<'a> {
427427
use hubtools::{CabooseBuilder, HubrisArchiveBuilder};
428428

429429
let board = match self.kind {
430-
KnownArtifactKind::GimletRotBootloader
431-
| KnownArtifactKind::PscRotBootloader
432-
| KnownArtifactKind::SwitchRotBootloader => "SimRotStage0",
433430
// non-Hubris artifacts: just make fake data
434431
KnownArtifactKind::Host
435432
| KnownArtifactKind::Trampoline
@@ -447,27 +444,38 @@ impl<'a> FakeDataAttributes<'a> {
447444
);
448445
}
449446

450-
// hubris artifacts: build a fake archive (SimGimletSp and
447+
// In production, all the bootloaders and RoTs claim to have the
448+
// same board (currently: `oxide-rot-1`). Let's do that here too.
449+
KnownArtifactKind::GimletRotBootloader
450+
| KnownArtifactKind::PscRotBootloader
451+
| KnownArtifactKind::SwitchRotBootloader
452+
| KnownArtifactKind::GimletRot
453+
| KnownArtifactKind::PscRot
454+
| KnownArtifactKind::SwitchRot => "SimRot",
455+
456+
// SP artifacts: build a fake archive (SimGimletSp and
451457
// SimGimletRot are used by sp-sim)
452458
KnownArtifactKind::GimletSp => "SimGimletSp",
453-
KnownArtifactKind::GimletRot => "SimRot",
454-
KnownArtifactKind::PscSp => "fake-psc-sp",
455-
KnownArtifactKind::PscRot => "fake-psc-rot",
456459
KnownArtifactKind::SwitchSp => "SimSidecarSp",
457-
KnownArtifactKind::SwitchRot => "SimRot",
460+
KnownArtifactKind::PscSp => "SimPscSp",
458461
};
459462

460-
// For our purposes sign = board represents what we want for the RoT
461-
// and we don't care about the sign value for the SP
462-
// We now have an assumption that board == name for our production
463-
// images
464-
let caboose = CabooseBuilder::default()
465-
.git_commit("this-is-fake-data")
466-
.board(board)
467-
.version(self.version.to_string())
468-
.name(board)
469-
.sign(board)
470-
.build();
463+
let caboose = {
464+
// We use a fake git commit that contains `self.kind` to ensure that
465+
// the artifacts we produce are distinct for each `kind`, even if
466+
// all the other caboose fields are identical.
467+
let mut builder = CabooseBuilder::default()
468+
.git_commit(format!("this-is-a-fake-{}", self.kind))
469+
.board(board)
470+
.name(board)
471+
.version(self.version.to_string());
472+
473+
if let Some(sign) = self.kind.fake_artifact_hubris_sign() {
474+
builder = builder.sign(sign);
475+
}
476+
477+
builder.build()
478+
};
471479

472480
let mut builder = HubrisArchiveBuilder::with_fake_image();
473481
builder.write_caboose(caboose.as_slice()).unwrap();

0 commit comments

Comments
 (0)