@@ -451,7 +451,7 @@ impl Runner {
451451 }
452452
453453 pub async fn remove_nodes ( & self , nodes_remover : NodesRemover ) -> anyhow:: Result < RunnerProposal > {
454- let ( healths, nodes_with_proposals) = try_join ( self . health_client . nodes ( ) , self . registry . nodes_with_proposals ( ) ) . await ?;
454+ let ( healths, nodes_with_proposals) = try_join ( self . health_client . nodes ( ) , self . registry . nodes_and_proposals ( ) ) . await ?;
455455 let ( mut node_removals, motivation) = nodes_remover. remove_nodes ( healths, nodes_with_proposals) ;
456456 node_removals. sort_by_key ( |nr| nr. reason . message ( ) ) ;
457457
@@ -528,27 +528,32 @@ impl Runner {
528528 let node_operators = self . registry . operators ( ) . await ?;
529529 // Filter out nodes that are not healthy
530530 let nodes_all = self . registry . nodes ( ) . await ?;
531- let healthy_nodes = nodes_all
531+ let healthy_nodes = available_nodes
532532 . iter ( )
533- . filter ( |( node_id , _node ) | health_of_nodes. get ( * node_id ) == Some ( & HealthStatus :: Healthy ) )
533+ . filter ( |node | health_of_nodes. get ( & node . id ) == Some ( & HealthStatus :: Healthy ) )
534534 . collect :: < Vec < _ > > ( ) ;
535535 // Build a hashmap {node_id -> node} of all nodes that are in some (any) subnet
536536 let nodes_in_subnets = subnets
537537 . values ( )
538538 . flat_map ( |s| s. nodes . iter ( ) . map ( |n| ( n. principal , n) ) )
539539 . collect :: < AHashMap < _ , _ > > ( ) ;
540540 // Build a hashmap of healthy nodes, grouped by node operator {operator -> Vec<Node>}
541- let healthy_nodes_by_operator = healthy_nodes. iter ( ) . into_group_map_by ( |( _node_id, node) | node. operator . principal ) ;
541+ let healthy_nodes_by_operator = healthy_nodes
542+ . iter ( )
543+ . into_group_map_by ( |node| nodes_all. get ( & node. id ) . expect ( "Node should exist" ) . operator . principal ) ;
542544 // Finally, prepare a list of operators that have at least 1 node, but NONE of their nodes are in a subnet
543545 let operators_without_nodes_in_subnets = node_operators
544546 . iter ( )
545547 . filter_map ( |( operator_id, operator) | {
546548 if let Some ( operator_nodes) = healthy_nodes_by_operator. get ( operator_id) {
547- if operator_nodes. iter ( ) . all ( |( node_id , _node ) | !nodes_in_subnets. contains_key ( node_id ) ) {
549+ if operator_nodes. iter ( ) . all ( |node | !nodes_in_subnets. contains_key ( & node . id ) ) {
548550 Some ( (
549551 operator_id,
550552 operator. datacenter . as_ref ( ) . map ( |dc| dc. name . clone ( ) ) . unwrap_or_default ( ) ,
551- operator_nodes. iter ( ) . map ( |( _, node) | ( * node) . clone ( ) ) . collect :: < Vec < _ > > ( ) ,
553+ operator_nodes
554+ . iter ( )
555+ . map ( |node| nodes_all. get ( & node. id ) . expect ( "Node should exist" ) . clone ( ) )
556+ . collect :: < Vec < _ > > ( ) ,
552557 ) )
553558 } else {
554559 None
0 commit comments