[pve-devel] [PATCH ha-manager 04/18] rules: resource affinity: inter-consistency check with merged positive rules
Daniel Kral
d.kral at proxmox.com
Fri Aug 29 15:28:16 CEST 2025
On Fri Aug 29, 2025 at 2:43 PM CEST, Michael Köppl wrote:
> One nit inline
>
> On Thu Aug 21, 2025 at 4:35 PM CEST, Daniel Kral wrote:
>> @@ -248,58 +255,6 @@ __PACKAGE__->register_check(
>>
>> =cut
>>
>> -my $sort_by_lowest_resource_id = sub {
>> - my ($rules) = @_;
>> -
>> - my $lowest_rule_resource_id = {};
>> - for my $ruleid (keys %$rules) {
>> - my @rule_resources = sort keys $rules->{$ruleid}->{resources}->%*;
>> - $lowest_rule_resource_id->{$ruleid} = $rule_resources[0];
>> - }
>> -
>> - # sort rules such that rules with the lowest numbered resource come first
>> - my @sorted_ruleids = sort {
>> - $lowest_rule_resource_id->{$a} cmp $lowest_rule_resource_id->{$b}
>> - } sort keys %$rules;
>> -
>> - return @sorted_ruleids;
>> -};
>> -
>> -# returns a list of hashes, which contain disjoint resource affinity rules, i.e.,
>> -# put resource affinity constraints on disjoint sets of resources
>> -my $find_disjoint_resource_affinity_rules = sub {
>> - my ($rules) = @_;
>> -
>> - my @disjoint_rules = ();
>> -
>> - # order needed so that it is easier to check whether there is an overlap
>> - my @sorted_ruleids = $sort_by_lowest_resource_id->($rules);
>> -
>> - for my $ruleid (@sorted_ruleids) {
>> - my $rule = $rules->{$ruleid};
>> -
>> - my $found = 0;
>> - for my $entry (@disjoint_rules) {
>> - next if sets_are_disjoint($rule->{resources}, $entry->{resources});
>> -
>> - $found = 1;
>> - push @{ $entry->{ruleids} }, $ruleid;
>> - $entry->{resources}->{$_} = 1 for keys $rule->{resources}->%*;
>> -
>> - last;
>> - }
>> - if (!$found) {
>> - push @disjoint_rules,
>> - {
>> - ruleids => [$ruleid],
>> - resources => { $rule->{resources}->%* },
>> - };
>> - }
>> - }
>> -
>> - return @disjoint_rules;
>> -};
>> -
>
> nit: I think the removal of this would have been better to do in the
> previous patch. It's not really related to the changes made in this
> patch AFAICT and the function is not used anymore at this point.
Ah right, ACK, I forgot to reply to this patch afterwards but I wrongly
squashed that in a rebase, it should have gone to the previous patch,
but thanks for pointing it out either way! I'll move it in a v2.
More information about the pve-devel
mailing list