Skip to content
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

[wicketd] Don't check RoT CMPA/CFPA until we've decided to update it #4459

Merged
merged 1 commit into from
Nov 9, 2023
Merged
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
13 changes: 12 additions & 1 deletion wicketd/src/artifacts/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use camino::Utf8PathBuf;
use display_error_chain::DisplayErrorChain;
use dropshot::HttpError;
use omicron_common::api::external::SemverVersion;
use omicron_common::api::internal::nexus::KnownArtifactKind;
use omicron_common::update::{ArtifactHashId, ArtifactId, ArtifactKind};
use slog::error;
Expand Down Expand Up @@ -105,6 +106,15 @@ pub(super) enum RepositoryError {
#[error("missing artifact of kind `{0:?}`")]
MissingArtifactKind(KnownArtifactKind),

#[error(
"muliple versions present for artifact of kind `{kind:?}`: {v1}, {v2}"
)]
MultipleVersionsPresent {
kind: KnownArtifactKind,
v1: SemverVersion,
v2: SemverVersion,
},

#[error(
"duplicate hash entries found in artifacts.json for kind `{}`, hash `{}`", .0.kind, .0.hash
)]
Expand Down Expand Up @@ -134,7 +144,8 @@ impl RepositoryError {
| RepositoryError::ParsingHubrisArchive { .. }
| RepositoryError::ReadHubrisCaboose { .. }
| RepositoryError::ReadHubrisCabooseBoard { .. }
| RepositoryError::ReadHubrisCabooseBoardUtf8(_) => {
| RepositoryError::ReadHubrisCabooseBoardUtf8(_)
| RepositoryError::MultipleVersionsPresent { .. } => {
HttpError::for_bad_request(None, message)
}

Expand Down
53 changes: 53 additions & 0 deletions wicketd/src/artifacts/update_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,59 @@ impl<'a> UpdatePlanBuilder<'a> {
}
}

// Ensure that all A/B RoT images for each board kind have the same
// version number.
for (kind, mut single_board_rot_artifacts) in [
(
KnownArtifactKind::GimletRot,
self.gimlet_rot_a.iter().chain(&self.gimlet_rot_b),
),
(
KnownArtifactKind::PscRot,
self.psc_rot_a.iter().chain(&self.psc_rot_b),
),
(
KnownArtifactKind::SwitchRot,
self.sidecar_rot_a.iter().chain(&self.sidecar_rot_b),
),
] {
// We know each of these iterators has at least 2 elements (one from
// the A artifacts and one from the B artifacts, checked above) so
// we can safely unwrap the first.
let version =
&single_board_rot_artifacts.next().unwrap().id.version;
for artifact in single_board_rot_artifacts {
if artifact.id.version != *version {
return Err(RepositoryError::MultipleVersionsPresent {
kind,
v1: version.clone(),
v2: artifact.id.version.clone(),
});
}
}
}

// Repeat the same version check for all SP images. (This is a separate
// loop because the types of the iterators don't match.)
for (kind, mut single_board_sp_artifacts) in [
(KnownArtifactKind::GimletSp, self.gimlet_sp.values()),
(KnownArtifactKind::PscSp, self.psc_sp.values()),
(KnownArtifactKind::SwitchSp, self.sidecar_sp.values()),
] {
// We know each of these iterators has at least 1 element (checked
// above) so we can safely unwrap the first.
let version = &single_board_sp_artifacts.next().unwrap().id.version;
for artifact in single_board_sp_artifacts {
if artifact.id.version != *version {
return Err(RepositoryError::MultipleVersionsPresent {
kind,
v1: version.clone(),
v2: artifact.id.version.clone(),
});
}
}
}

Ok(UpdatePlan {
system_version: self.system_version,
gimlet_sp: self.gimlet_sp, // checked above
Expand Down
Loading
Loading