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

feature(dre): add all methods to manage the API boundary nodes #456

Merged
merged 5 commits into from
Jun 6, 2024
Merged
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
56 changes: 55 additions & 1 deletion rs/cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -89,6 +89,9 @@ pub enum Commands {
/// Manage nodes
Nodes(nodes::Cmd),

/// Manage API boundary nodes
ApiBoundaryNodes(api_boundary_nodes::Cmd),

/// Vote on our proposals
Vote {
/// Override default accepted proposers
@@ -245,7 +248,7 @@ pub mod subnet {
#[clap(long, num_args(1..))]
include: Vec<PrincipalId>,

/// Motivation for resing the subnet
/// Motivation for resizing the subnet
#[clap(short, long, aliases = ["summary"])]
motivation: Option<String>,
},
@@ -455,6 +458,57 @@ pub mod nodes {
}
}

pub mod api_boundary_nodes {
use super::*;

#[derive(Parser, Clone)]
pub struct Cmd {
#[clap(subcommand)]
pub subcommand: Commands,
}

#[derive(Subcommand, Clone)]
pub enum Commands {
/// Update specified set of nodes to the provided version.
/// The provided "version" must be already elected.
/// The "nodes" list must contain the node IDs where the version should be rolled out.
Update {
/// Node IDs where to rollout the version
#[clap(long, num_args(1..), required = true)]
nodes: Vec<PrincipalId>,

#[clap(long, required = true)]
version: String,

/// Motivation for creating the subnet
#[clap(short, long, aliases = ["summary"], required = true)]
motivation: Option<String>,
},

/// Turn a set of unassigned nodes into API BNs
Add {
/// Node IDs to turn into API BNs
#[clap(long, num_args(1..), required = true)]
nodes: Vec<PrincipalId>,

/// guestOS version
#[clap(long, required = true)]
version: String,

/// Motivation for creating the subnet
#[clap(short, long, aliases = ["summary"], required = true)]
motivation: Option<String>,
},

/// Decommission a set of API BNs and turn them again in unassigned nodes
Remove {
/// Node IDs to turn into API BNs
#[clap(long, num_args(1..), required = true)]
nodes: Vec<PrincipalId>,
},
}
}

pub mod proposals {
use clap::ValueEnum;
use ic_nns_governance::pb::v1::{ProposalStatus as ProposalStatusUpstream, Topic as TopicUpstream};
30 changes: 27 additions & 3 deletions rs/cli/src/ic_admin.rs
Original file line number Diff line number Diff line change
@@ -626,7 +626,7 @@ must be identical, and must match the SHA256 from the payload of the NNS proposa
}
}

pub async fn update_unassigned_nodes(&self, nns_subned_id: &String, network: &Network, simulate: bool) -> Result<(), Error> {
pub async fn update_unassigned_nodes(&self, nns_subnet_id: &String, network: &Network, simulate: bool) -> Result<(), Error> {
let local_registry_path = local_registry_path(network);
let local_registry = LocalRegistry::new(local_registry_path, Duration::from_secs(10))
.map_err(|e| anyhow::anyhow!("Error in creating local registry instance: {:?}", e))?;
@@ -638,9 +638,9 @@ must be identical, and must match the SHA256 from the payload of the NNS proposa

let subnets = local_registry.get_family_entries::<SubnetRecord>()?;

let nns = match subnets.get_key_value(nns_subned_id) {
let nns = match subnets.get_key_value(nns_subnet_id) {
Some((_, value)) => value,
None => return Err(anyhow::anyhow!("Couldn't find nns subnet with id '{}'", nns_subned_id)),
None => return Err(anyhow::anyhow!("Couldn't find nns subnet with id '{}'", nns_subnet_id)),
};

let registry_state = RegistryState::new(network, true).await;
@@ -877,6 +877,17 @@ pub enum ProposeCommand {
node_ids: Vec<PrincipalId>,
replica_version: String,
},
AddApiBoundaryNodes {
nodes: Vec<PrincipalId>,
version: String,
},
RemoveApiBoundaryNodes {
nodes: Vec<PrincipalId>,
},
DeployGuestosToSomeApiBoundaryNodes {
nodes: Vec<PrincipalId>,
version: String,
},
}

impl ProposeCommand {
@@ -948,6 +959,19 @@ impl ProposeCommand {
Self::DeployGuestosToAllUnassignedNodes { replica_version } => {
vec!["--replica-version-id".to_string(), replica_version.clone()]
}
Self::AddApiBoundaryNodes { nodes, version } => [
vec!["--nodes".to_string()],
nodes.iter().map(|n| n.to_string()).collect::<Vec<_>>(),
vec!["--version".to_string(), version.to_string()],
]
.concat(),
Self::RemoveApiBoundaryNodes { nodes } => [vec!["--nodes".to_string()], nodes.iter().map(|n| n.to_string()).collect::<Vec<_>>()].concat(),
Self::DeployGuestosToSomeApiBoundaryNodes { nodes, version } => [
vec!["--nodes".to_string()],
nodes.iter().map(|n| n.to_string()).collect::<Vec<_>>(),
vec!["--version".to_string(), version.to_string()],
]
.concat(),
}
}
}
55 changes: 55 additions & 0 deletions rs/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -327,6 +327,7 @@ async fn async_main() -> Result<(), anyhow::Error> {
}
}
}

cli::Commands::Nodes(nodes) => match &nodes.subcommand {
cli::nodes::Commands::Remove {
extra_nodes_filter,
@@ -354,6 +355,60 @@ async fn async_main() -> Result<(), anyhow::Error> {
}
},

cli::Commands::ApiBoundaryNodes(api_boundary_nodes) => match &api_boundary_nodes.subcommand {
cli::api_boundary_nodes::Commands::Update { nodes, version, motivation } => {
runner_instance
.ic_admin
.propose_run(
ic_admin::ProposeCommand::DeployGuestosToSomeApiBoundaryNodes {
nodes: nodes.to_vec(),
version: version.to_string(),
},
ic_admin::ProposeOptions {
title: Some(format!("Update {} API boundary node(s) to {version}", nodes.clone().len())),
summary: Some(format!("Update {} API boundary node(s) to {version}", nodes.clone().len())),
motivation: motivation.clone(),
},
simulate,
)
.await?;
Ok(())
}
cli::api_boundary_nodes::Commands::Add { nodes, version, motivation } => {
runner_instance
.ic_admin
.propose_run(
ic_admin::ProposeCommand::AddApiBoundaryNodes {
nodes: nodes.to_vec(),
version: version.to_string(),
},
ic_admin::ProposeOptions {
title: Some(format!("Add {} API boundary node(s)", nodes.clone().len())),
summary: Some(format!("Add {} API boundary node(s)", nodes.clone().len())),
motivation: motivation.clone(),
},
simulate,
)
.await?;
Ok(())
}
cli::api_boundary_nodes::Commands::Remove { nodes } => {
runner_instance
.ic_admin
.propose_run(
ic_admin::ProposeCommand::RemoveApiBoundaryNodes { nodes: nodes.to_vec() },
ic_admin::ProposeOptions {
title: Some(format!("Remove {} API boundary node(s)", nodes.clone().len())),
summary: Some(format!("Remove {} API boundary node(s)", nodes.clone().len())),
motivation: None,
},
simulate,
)
.await?;
Ok(())
}
},

cli::Commands::Vote {
accepted_neurons,
accepted_topics,