Factor out the prioritized node hash set in the select_service_node as it is used multiple times and makes the intent a little clearer.
Signed-off-by: Daniel Kral <d.k...@proxmox.com> --- src/PVE/HA/Manager.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index 7a8e7dc..8f2ab3d 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -175,23 +175,24 @@ sub select_service_node { # select node from top priority node list my $top_pri = $pri_list[0]; + my $pri_nodes = $pri_groups->{$top_pri}; # try to avoid nodes where the service failed already if we want to relocate if ($try_next) { foreach my $node (@$tried_nodes) { - delete $pri_groups->{$top_pri}->{$node}; + delete $pri_nodes->{$node}; } } return $maintenance_fallback - if defined($maintenance_fallback) && $pri_groups->{$top_pri}->{$maintenance_fallback}; + if defined($maintenance_fallback) && $pri_nodes->{$maintenance_fallback}; - return $current_node if (!$try_next && !$best_scored) && $pri_groups->{$top_pri}->{$current_node}; + return $current_node if (!$try_next && !$best_scored) && $pri_nodes->{$current_node}; my $scores = $online_node_usage->score_nodes_to_start_service($sid, $current_node); my @nodes = sort { $scores->{$a} <=> $scores->{$b} || $a cmp $b - } keys %{$pri_groups->{$top_pri}}; + } keys %$pri_nodes; my $found; for (my $i = scalar(@nodes) - 1; $i >= 0; $i--) { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel