From e8cdc3347f0ee65a9a4e6f3fc716c83479d097b1 Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Mon, 14 Oct 2024 19:08:52 +0000 Subject: [PATCH] Allow indexing SP images on `name` instead of `board` Currently, we expect each SP image in the TUF repo to have a unique board name. This prevents us from also packaging other images for use in manufacturing. Relax this slightly by requiring all SP images to have a unique `name` instead of a unique `board`. We will still select by `board` via wicketd meaning the actual runtime behavior should still be the same. --- update-common/src/artifacts/update_plan.rs | 12 +++++++++--- wicketd/src/update_tracker.rs | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/update-common/src/artifacts/update_plan.rs b/update-common/src/artifacts/update_plan.rs index 6d755892f2..9b59bd984b 100644 --- a/update-common/src/artifacts/update_plan.rs +++ b/update-common/src/artifacts/update_plan.rs @@ -276,8 +276,14 @@ impl<'a> UpdatePlanBuilder<'a> { data.extend_from_slice(&chunk); } + // We purposely read out `name` instead of `board` here to + // allow for packaging multiple images for the same board + // in the TUF repo (specifically the manufacturing images) + // We will still select the image in wicketd via `board` + // as the only images we want to install via wicket are those + // with name == board. let (artifact_id, board) = - read_hubris_board_from_archive(artifact_id, data.clone())?; + read_hubris_name_from_archive(artifact_id, data.clone())?; let slot = match sp_map.entry(board) { btree_map::Entry::Vacant(slot) => slot, @@ -1012,7 +1018,7 @@ fn read_hubris_sign_from_archive( // This function takes and returns `id` to avoid an unnecessary clone; `id` will // be present in either the Ok tuple or the error. -fn read_hubris_board_from_archive( +fn read_hubris_name_from_archive( id: ArtifactId, data: Vec, ) -> Result<(ArtifactId, Board), RepositoryError> { @@ -1028,7 +1034,7 @@ fn read_hubris_board_from_archive( return Err(RepositoryError::ReadHubrisCaboose { id, error }); } }; - let board = match caboose.board() { + let board = match caboose.name() { Ok(board) => board, Err(error) => { return Err(RepositoryError::ReadHubrisCabooseBoard { id, error }); diff --git a/wicketd/src/update_tracker.rs b/wicketd/src/update_tracker.rs index 0fad3ba37f..747da4e464 100644 --- a/wicketd/src/update_tracker.rs +++ b/wicketd/src/update_tracker.rs @@ -943,6 +943,10 @@ impl UpdateDriver { })? .into_inner(); + // The sp_artifacts were built on the caboose `NAME` + // entry but we intentonally get via the `BORD` entry + // as that represents the only images we want to install + // via wicket let Some(sp_artifact) = sp_artifacts.get(&caboose.board) else { return Err(