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

feat(cli): Check that there are two download URLs for elect proposals #236

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
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
Loading