Skip to content

Commit

Permalink
feat(cli): Check that there are two download URLs for elect proposals (
Browse files Browse the repository at this point in the history
  • Loading branch information
sasa-tomic committed Mar 8, 2024
1 parent 971d815 commit 1ac8581
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions rs/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ pub(crate) mod version {

/// Git tag for the release.
release_tag: String,

/// Force proposal submission, ignoring missing download URLs
#[clap(long)]
force: bool,
},
/// Update the elected/blessed HostOS versions in the registry
/// by adding a new version and potentially removing obsolete versions
Expand All @@ -302,6 +306,10 @@ pub(crate) mod version {

/// Git tag for the release.
release_tag: String,

/// Force proposal submission, ignoring missing download URLs
#[clap(long)]
force: bool,
},
}
impl From<UpdateCommands> for Artifact {
Expand Down
13 changes: 11 additions & 2 deletions rs/cli/src/ic_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ impl IcAdminWrapper {
async fn download_images_and_validate_sha256(
image: &Artifact,
version: &String,
ignore_missing_urls: bool,
) -> anyhow::Result<(Vec<String>, String)> {
let update_urls = vec![
Self::get_s3_cdn_image_url(version, &image.s3_folder()),
Expand Down Expand Up @@ -560,7 +561,13 @@ impl IcAdminWrapper {
update_urls.join(", ")
));
} else if update_urls.len() == 1 {
warn!("Only 1 update image is available. At least 2 should be present in the proposal");
if ignore_missing_urls {
warn!("Only 1 update image is available. At least 2 should be present in the proposal");
} else {
return Err(anyhow::anyhow!(
"Only 1 update image is available. At least 2 should be present in the proposal"
));
}
}
Ok((update_urls, expected_hash))
}
Expand All @@ -569,9 +576,11 @@ impl IcAdminWrapper {
release_artifact: &Artifact,
version: &String,
release_tag: &String,
force: bool,
retire_versions: Option<Vec<String>>,
) -> anyhow::Result<UpdateVersion> {
let (update_urls, expected_hash) = Self::download_images_and_validate_sha256(release_artifact, version).await?;
let (update_urls, expected_hash) =
Self::download_images_and_validate_sha256(release_artifact, version, force).await?;

let template = format!(
r#"Elect new {release_artifact} binary revision [{version}](https://github.com/dfinity/ic/tree/{release_tag})
Expand Down
3 changes: 2 additions & 1 deletion rs/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,12 @@ async fn main() -> Result<(), anyhow::Error> {
let release_artifact: &Artifact = &update_command.subcommand.clone().into();

let update_version = match &update_command.subcommand {
cli::version::UpdateCommands::Replica { version, release_tag} | cli::version::UpdateCommands::HostOS { version, release_tag} => {
cli::version::UpdateCommands::Replica { version, release_tag, force} | cli::version::UpdateCommands::HostOS { version, release_tag, force} => {
ic_admin::IcAdminWrapper::prepare_to_propose_to_update_elected_versions(
release_artifact,
version,
release_tag,
*force,
runner.prepare_versions_to_retire(release_artifact, false).await.map(|res| res.1)?,
)
}
Expand Down

0 comments on commit 1ac8581

Please sign in to comment.