[pve-devel] [PATCH ha-manager v3 4/8] rules: resource affinity: decouple get_resource_affinity helper from Usage class

Daniel Kral d.kral at proxmox.com
Mon Nov 3 17:01:15 CET 2025


On Mon Nov 3, 2025 at 4:50 PM CET, Michael Köppl wrote:
> On Mon Oct 27, 2025 at 5:43 PM CET, Daniel Kral wrote:
>> @@ -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.

Good catch, thanks!

Oh this makes sense, there's auto-vivification on $ss directly, because
of $ss->{$csid}->... in

	my ($state, $node, $target) = $ss->{$csid}->@{qw(state node target)};

and especially here, the loop iterates over $rule->{resources}->%*,
which is completely external and doesn't filter out the ignored
services. I'll fix that in a v4 and check for other possible
auto-vivification bugs in the patches, thanks!




More information about the pve-devel mailing list