Skip to content

Commit

Permalink
chore(cli): Remove the separate subcommand to retire replica versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sasa-tomic committed Jul 25, 2023
1 parent dc306c0 commit 17aad3b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 42 deletions.
20 changes: 4 additions & 16 deletions rs/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,13 @@ pub(crate) mod version {

#[derive(Subcommand, Clone)]
pub enum Commands {
/// Retire replica versions
Retire {
/// Specify if the summary should be edited during the process
///
/// Default value of summary is:
/// Removing the obsolete IC replica versions from the registry, to
/// prevent unintended version in the future
#[clap(long)]
edit_summary: bool,
},

/// Bless replica version with release notes using the ic-admin CLI and
/// automatically retire obsolete replica versions
/// Update the elected/blessed replica versions in the registry
/// by adding a new version and potentially removing obsolete versions
Update {
/// Specify the commit hash of the version that is being deployed.
/// Specify the commit hash of the version that is being elected.
version: String,

/// Sepcify the name of the rc branch that contains the release
/// commits.
/// RC branch that contains the release commits.
rc_branch_name: String,
},
}
Expand Down
6 changes: 1 addition & 5 deletions rs/cli/src/ic_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl Cli {
self.propose_run(cmd, Default::default(), simulate)
}

pub(crate) async fn prepare_to_propose_to_bless_new_replica_version(
pub(crate) async fn prepare_to_propose_to_update_elected_replica_versions(
version: &String,
rc_branch_name: &String,
) -> anyhow::Result<UpdateReplicaVersions> {
Expand Down Expand Up @@ -448,9 +448,6 @@ pub(crate) enum ProposeCommand {
command: String,
args: Vec<String>,
},
RetireReplicaVersion {
versions: Vec<String>,
},
RemoveNodes {
nodes: Vec<PrincipalId>,
},
Expand Down Expand Up @@ -512,7 +509,6 @@ impl ProposeCommand {
vec![subnet.to_string(), version.clone()]
}
Self::Raw { command: _, args } => args.clone(),
Self::RetireReplicaVersion { versions } => versions.to_vec(),
Self::RemoveNodes { nodes } => nodes.iter().map(|n| n.to_string()).collect(),
Self::UpdateElectedReplicaVersions {
version_to_bless,
Expand Down
33 changes: 12 additions & 21 deletions rs/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::cli::version::Commands::{Retire, Update};
use crate::cli::version::Commands::Update;
use clap::{error::ErrorKind, CommandFactory, Parser};
use ic_canisters::governance_canister_version;
use ic_management_types::requests::NodesRemoveRequest;
Expand Down Expand Up @@ -167,36 +167,27 @@ async fn main() -> Result<(), anyhow::Error> {

cli::Commands::Version(cmd) => {
match &cmd.subcommand {
Retire { edit_summary } => {
let runner = runner::Runner::from_opts(&cli_opts).await?;
let (template, versions) = runner.prepare_versions_to_retire(*edit_summary).await?;
let ic_admin = ic_admin::Cli::from_opts(&cli_opts, true).await?;
ic_admin.propose_run(
ic_admin::ProposeCommand::RetireReplicaVersion { versions },
ic_admin::ProposeOptions {
title: Some("Retire IC replica version".to_string()),
summary: Some(template),
motivation: None,
},
simulate,
)
},
Update { version, rc_branch_name } => {
let runner = runner::Runner::from_opts(&cli_opts).await?;
let (_, versions) = runner.prepare_versions_to_retire(false).await?;
let (_, retire_versions) = runner.prepare_versions_to_retire(false).await?;
let ic_admin = ic_admin::Cli::from_opts(&cli_opts, true).await?;
let new_replica_info = ic_admin::Cli::prepare_to_propose_to_bless_new_replica_version(version, rc_branch_name).await?;
let proposal_title = if versions.is_empty() {
Some(format!("Elect new replica binary revision (commit {})", &version[..8]))
let new_replica_info = ic_admin::Cli::prepare_to_propose_to_update_elected_replica_versions(version, rc_branch_name).await?;
let proposal_title = if retire_versions.is_empty() {
Some(format!("Elect new IC/Replica revision (commit {})", &version[..8]))
} else {
Some(format!("Elect new replica binary revision (commit {}), and retire old replica versions {}", &version[..8], versions.iter().map(|v| &v[..8]).join(",")))
let pluralize = if retire_versions.len() == 1 {
"version"
} else {
"versions"
};
Some(format!("Elect new IC/Replica revision (commit {}), and retire old replica {} {}", &version[..8], pluralize, retire_versions.iter().map(|v| &v[..8]).join(",")))
};

ic_admin.propose_run(ic_admin::ProposeCommand::UpdateElectedReplicaVersions{
version_to_bless: version.to_string(),
update_url: new_replica_info.update_url,
stringified_hash: new_replica_info.stringified_hash,
versions_to_retire: versions.clone(),
versions_to_retire: retire_versions.clone(),
}, ic_admin::ProposeOptions{
title: proposal_title,
summary: Some(new_replica_info.summary),
Expand Down

0 comments on commit 17aad3b

Please sign in to comment.