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 38F161FF187 for ; Mon, 3 Nov 2025 16:49:52 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 73AB621BB8; Mon, 3 Nov 2025 16:50:28 +0100 (CET) Mime-Version: 1.0 Date: Mon, 03 Nov 2025 16:50:24 +0100 Message-Id: Cc: "pve-devel" From: =?utf-8?q?Michael_K=C3=B6ppl?= To: "Proxmox VE development discussion" X-Mailer: aerc 0.21.0 References: <20251027164513.542678-1-d.kral@proxmox.com> <20251027164513.542678-8-d.kral@proxmox.com> In-Reply-To: <20251027164513.542678-8-d.kral@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762185007348 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.036 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 Subject: Re: [pve-devel] [PATCH ha-manager v3 4/8] rules: resource affinity: decouple get_resource_affinity helper from Usage class 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" On Mon Oct 27, 2025 at 5:43 PM CET, Daniel Kral wrote: > -=head3 get_resource_affinity($rules, $sid, $online_node_usage) > +=head3 get_resource_affinity($rules, $sid, $ss, $online_nodes) > > Returns a list of two hashes, where the first describes the positive resource > affinity and the second hash describes the negative resource affinity for > -resource C<$sid> according to the resource affinity rules in C<$rules> and the > -resource locations in C<$online_node_usage>. > +resource C<$sid> according to the resource affinity rules in C<$rules>, the > +service status C<$ss> and the C<$online_nodes> hash. > > For the positive resource affinity of a resource C<$sid>, each element in the > hash represents an online node, where other resources, which C<$sid> is in > @@ -529,8 +530,8 @@ resource C<$sid> is in a negative affinity with, the returned value will be: > > =cut > > -sub get_resource_affinity : prototype($$$) { > - my ($rules, $sid, $online_node_usage) = @_; > +sub get_resource_affinity : prototype($$$$) { > + my ($rules, $sid, $ss, $online_nodes) = @_; > > my $together = {}; > my $separate = {}; > @@ -543,14 +544,16 @@ sub get_resource_affinity : prototype($$$) { > for my $csid (keys %{ $rule->{resources} }) { > next if $csid eq $sid; > > - my $nodes = $online_node_usage->get_service_nodes($csid); > - > - next if !$nodes || !@$nodes; # skip unassigned nodes > + my ($state, $node, $target) = $ss->{$csid}->@{qw(state node target)}; During my testing of your other series [0], I noticed a problem with resources that are set to 'ignored'. $state is undefined if the resource is set to ignored because AFAICT its corresponding entry in $ss is removed in the loop that removes stale or ignored service in the manage function. This results in the following warning being printed repeatedly: Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: removing stale service 'ct:101' (ignored state requested) Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 77. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 77. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 81. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 94. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 94. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $state in string eq at /usr/share/perl5/PVE/HA/Usage.pm line 94. Nov 03 16:37:07 pve-trixbuild02 pve-ha-crm[122707]: Use of uninitialized value $service_state in string ne at /usr/share/perl5/PVE/HA/Manager.pm line 816. This can be reproduced with the following scenario: - Add 2 resources (for resource affinity rules), setting 1 to ignored - Create a resource affinity rule This also results in another problem when then trying to set the resource to any other state again. The resource cannot be set to the other state and remains 'queued', showing the following error in the pve-ha-crm journal. Nov 03 16:42:27 pve-trixbuild02 pve-ha-crm[122707]: got unexpected error - unknown service state '' at /usr/share/perl5/PVE/HA/Manager.pm line 798. Not entirely certain that my reasoning why this is happening is correct, though. [0] https://lore.proxmox.com/pve-devel/20251103102118.153666-1-d.kral@proxmox.com > + my ($current_node, $target_node) = > + PVE::HA::Usage::get_used_service_nodes($online_nodes, $state, $node, $target); > > if ($rule->{affinity} eq 'positive') { > - $together->{$_}++ for @$nodes; > + $together->{$current_node}++ if defined($current_node); > + $together->{$target_node}++ if defined($target_node); _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel