Skip to content

Commit

Permalink
fix(dre): [DRE-241] Prefer existing nodes in subnet when selecting be…
Browse files Browse the repository at this point in the history
…st results (#734)

Co-authored-by: sa-github-api <[email protected]>
  • Loading branch information
sasa-tomic and sa-github-api authored Aug 16, 2024
1 parent 5071669 commit ec22c7c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rs/decentralization/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::subnets::unhealthy_with_nodes;
use crate::SubnetChangeResponse;
use actix_web::http::StatusCode;
use actix_web::{HttpResponse, ResponseError};
use ahash::AHashSet;
use anyhow::anyhow;
use ic_base_types::PrincipalId;
use ic_management_types::{MinNakamotoCoefficients, NetworkError, NodeFeature, Status};
Expand Down Expand Up @@ -403,6 +404,16 @@ impl DecentralizedSubnet {
if best_results.is_empty() {
None
} else {
// If any of the best_results nodes are already in the subnet,
// we should prefer them. This is because we want to keep the
// same nodes in the subnet if they are already there.
let current_nodes_set: AHashSet<_> = current_nodes.iter().collect();
for result in best_results {
if current_nodes_set.contains(&result.node) {
return Some(result.clone());
}
}

// We sort the current nodes by alphabetical order on their
// PrincipalIDs to ensure consistency of the seed with the
// same machines in the subnet
Expand Down

0 comments on commit ec22c7c

Please sign in to comment.