[pve-devel] [PATCH v2 ha-manager 12/15] manager: avoid scoring nodes when not trying next and current node is valid

Fiona Ebner f.ebner at proxmox.com
Thu Nov 17 15:00:13 CET 2022


With the Usage::Static plugin, scoring is not as cheap anymore and
select_service_node() is called for each running service.

This should cover most calls of select_service_node().

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

No changes from v1.

 src/PVE/HA/Manager.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index cc2ada4..69bfbc3 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -152,6 +152,8 @@ sub select_service_node {
     return $maintenance_fallback
 	if defined($maintenance_fallback) && $pri_groups->{$top_pri}->{$maintenance_fallback};
 
+    return $current_node if !$try_next && $pri_groups->{$top_pri}->{$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
@@ -171,8 +173,6 @@ sub select_service_node {
 	} else {
 	    return $nodes[0];
 	}
-    } elsif (defined($found)) {
-	return $nodes[$found];
     } else {
 	return $nodes[0];
     }
-- 
2.30.2






More information about the pve-devel mailing list