Skip to content

Commit

Permalink
fix(backend): Only remove dead nodes from the registry by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sasa-tomic committed Jan 4, 2024
1 parent 44e0a7f commit 938d675
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions rs/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ pub(crate) mod nodes {
#[clap(long)]
no_auto: bool,

/// Remove also degraded nodes; by default only dead (offline) nodes are automatically removed
#[clap(long)]
remove_degraded: bool,

/// Specifies the filter used to remove extra nodes
extra_nodes_filter: Vec<String>,

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 @@ -243,7 +243,7 @@ async fn main() -> Result<(), anyhow::Error> {
},
cli::Commands::Nodes(nodes) => {
match &nodes.subcommand {
cli::nodes::Commands::Remove { extra_nodes_filter, no_auto, exclude, motivation } => {
cli::nodes::Commands::Remove { extra_nodes_filter, no_auto, remove_degraded, exclude, motivation } => {
if motivation.is_none() && !extra_nodes_filter.is_empty() {
cmd.error(
ErrorKind::MissingRequiredArgument,
Expand All @@ -255,6 +255,7 @@ async fn main() -> Result<(), anyhow::Error> {
runner.remove_nodes(NodesRemoveRequest {
extra_nodes_filter: extra_nodes_filter.clone(),
no_auto: *no_auto,
remove_degraded: *remove_degraded,
exclude: Some(exclude.clone()),
motivation: motivation.clone().unwrap_or_default(),
}, simulate).await
Expand Down
8 changes: 7 additions & 1 deletion rs/ic-management-backend/src/endpoints/nodes_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ async fn remove(
reason: NodeRemovalReason::Duplicates(principal),
});
}
if !matches!(status, ic_management_types::Status::Healthy) {
let should_remove_node = if request.remove_degraded {
matches!(status, ic_management_types::Status::Dead)
|| matches!(status, ic_management_types::Status::Degraded)
} else {
matches!(status, ic_management_types::Status::Dead)
};
if should_remove_node {
return Some(NodeRemoval {
node: n,
reason: NodeRemovalReason::Unhealthy(status),
Expand Down
1 change: 1 addition & 0 deletions rs/ic-management-types/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl Display for HostosRolloutReason {
#[derive(Serialize, Deserialize)]
pub struct NodesRemoveRequest {
pub no_auto: bool,
pub remove_degraded: bool,
pub extra_nodes_filter: Vec<String>,
pub exclude: Option<Vec<String>>,
pub motivation: String,
Expand Down

0 comments on commit 938d675

Please sign in to comment.