From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 3FA3B1FF164 for ; Fri, 20 Jun 2025 16:31:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3D00EDACE; Fri, 20 Jun 2025 16:32:05 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Fri, 20 Jun 2025 16:31:13 +0200 Message-Id: <20250620143148.218469-6-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250620143148.218469-1-d.kral@proxmox.com> References: <20250620143148.218469-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.012 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH ha-manager v2 01/26] tree-wide: make arguments for select_service_node explicit X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Explicitly state all the parameters at all call sites for select_service_node(...) to clarify in which states these are. The call site in next_state_recovery(...) sets $best_scored to 1, as it should find the next best node when recovering from the failed node $current_node. All references to $best_scored in select_service_node() are there to check whether $current_node can be selected, but as $current_node is not available anyway, so this change should not change the result of select_service_node(...). Otherwise, $sd->{failed_nodes} and $sd->{maintenance_node} should contain only the failed $current_node in next_state_recovery(...), and therefore both can be passed as these should be impossible states here anyway. A cleaner way could be to explicitly remove them beforehand or do extra checks in select_service_node(...). Signed-off-by: Daniel Kral --- changes since v1: - NEW! src/PVE/HA/Manager.pm | 11 ++++++++++- src/test/test_failover1.pl | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index 12292e6..85f2b1a 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -971,6 +971,7 @@ sub next_state_started { $try_next, $sd->{failed_nodes}, $sd->{maintenance_node}, + 0, # best_score ); if ($node && ($sd->{node} ne $node)) { @@ -1083,7 +1084,15 @@ sub next_state_recovery { $self->recompute_online_node_usage(); # we want the most current node state my $recovery_node = select_service_node( - $self->{groups}, $self->{online_node_usage}, $sid, $cd, $sd->{node}, + $self->{groups}, + $self->{online_node_usage}, + $sid, + $cd, + $sd->{node}, + 0, # try_next + $sd->{failed_nodes}, + $sd->{maintenance_node}, + 1, # best_score ); if ($recovery_node) { diff --git a/src/test/test_failover1.pl b/src/test/test_failover1.pl index 371bdcf..2478b2b 100755 --- a/src/test/test_failover1.pl +++ b/src/test/test_failover1.pl @@ -24,13 +24,26 @@ my $service_conf = { group => 'prefer_node1', }; +my $sd = { + failed_nodes => undef, + maintenance_node => undef, +}; + my $current_node = $service_conf->{node}; sub test { my ($expected_node, $try_next) = @_; my $node = PVE::HA::Manager::select_service_node( - $groups, $online_node_usage, "vm:111", $service_conf, $current_node, $try_next, + $groups, + $online_node_usage, + "vm:111", + $service_conf, + $current_node, + $try_next, + $sd->{failed_nodes}, + $sd->{maintenance_node}, + 0, # best_score ); my (undef, undef, $line) = caller(); -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel