From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1E6C51FF16B for ; Tue, 29 Jul 2025 19:59:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B8CB719AF3; Tue, 29 Jul 2025 20:01:17 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Tue, 29 Jul 2025 20:00:41 +0200 Message-ID: <20250729180107.428855-2-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250729180107.428855-1-d.kral@proxmox.com> References: <20250729180107.428855-1-d.kral@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753812063225 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.014 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [manager.pm] Subject: [pve-devel] [PATCH ha-manager v4 01/19] 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 --- 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 12292e67..85f2b1ab 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 371bdcfb..2478b2bc 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.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel