Skip to content

Commit

Permalink
fix(backend): Show the correct number of nodes replaced instead of re…
Browse files Browse the repository at this point in the history
…quested
  • Loading branch information
sasa-tomic committed Jul 20, 2023
1 parent 6f7b587 commit d91e613
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rs/decentralization/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,11 @@ impl SubnetChangeRequest {
comment: resized_subnet.comment,
run_log: resized_subnet.run_log,
};
let node_add_count = subnet_change.added().len();
let node_remove_count = subnet_change.removed().len();
info!(
"Subnet {} resized, {} nodes added, {} nodes removed",
self.subnet.id, how_many_nodes_to_add, how_many_nodes_to_remove
self.subnet.id, node_add_count, node_remove_count
);
Ok(subnet_change)
}
Expand Down
5 changes: 3 additions & 2 deletions rs/ic-management-backend/src/endpoints/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ async fn replace(
let replace_target = if num_unhealthy == 1 { "node" } else { "nodes" };
motivations.push(format!("replacing {num_unhealthy} unhealthy {replace_target}"));
}
let num_optimized = request.optimize.unwrap_or(0);
let change = change_request.optimize(num_optimized, &replacements_unhealthy)?;
// Optimize the requested number of nodes, and remove unhealthy nodes if there are any
let change = change_request.optimize(request.optimize.unwrap_or(0), &replacements_unhealthy)?;
let num_optimized = change.removed().len() - num_unhealthy;
if num_optimized > 0 {
let replace_target = if num_optimized == 1 { "node" } else { "nodes" };
motivations.push(format!(
Expand Down

0 comments on commit d91e613

Please sign in to comment.