[pve-devel] [PATCH ha-manager 10/18] compile ha rules to a more compact representation
Daniel Kral
d.kral at proxmox.com
Fri Aug 29 15:42:02 CEST 2025
On Fri Aug 29, 2025 at 2:43 PM CEST, Michael Köppl wrote:
> On Thu Aug 21, 2025 at 4:35 PM CEST, Daniel Kral wrote:
>> sub write_rules_config {
>> @@ -391,8 +391,9 @@ sub get_resource_motion_info {
>> my $ss = $manager_status->{service_status};
>> my $ns = $manager_status->{node_status};
>>
>> - my $rules = read_and_check_effective_rules_config();
>> - my ($together, $separate) = get_affinitive_resources($rules, $sid);
>> + my $affinity = read_and_compile_rules_config();
>
> nit: maybe something like $compiled_rules? Calling a variable for this
> structure $affinity didn't make it quite clear to me what this is,
> especially when later on it's used as $affinity->{'resource-affinity'}.
> Maybe I'm just misinterpreting this, though.
>
> Or could you maybe explain why this compiled rule structure is then
> called affinity?
ACK, I'll call it that as it makes it more future proof too, because
there could be rules that have nothing to do with 'affinity'.
>> diff --git a/src/PVE/HA/Rules.pm b/src/PVE/HA/Rules.pm
>> index a075feac..d7593532 100644
>> --- a/src/PVE/HA/Rules.pm
>> +++ b/src/PVE/HA/Rules.pm
>> @@ -47,6 +47,12 @@ Each I<rule plugin> is required to implement the methods C<L<type()>>,
>> C<L<properties()>>, and C<L<options>> from the C<L<PVE::SectionConfig>> to
>> extend the properties of this I<base plugin> with plugin-specific properties.
>>
>> +Each I<rule plugin> is required to implement the method
>> +C<L<< plugin_compile()|/$class->plugin_compile(...) >>> to distill a compiled
>> +representation of the more verbose C<$rules> from the config file, which is
>> +returned by C<L<< compile()|/$class->compile(...) >>> to be more appropriate
>> +and efficient for the scheduler and other users.
>
> Is this supposed to say "other uses" or do you actually mean "other
> users"? Do you mean that this more efficient representation can (and
> probably should) be used for other uses cases when e.g. iterating over
> only resource affinity rules?
With "users" I meant other call sites that use the compiled rules
instead of the rules. As the helpers were converted to using the
compiled rules now too, many call sites are 'required' to use the
compiled rules anyway to be able to use these rule helpers (e.g.
get_node_affinity, get_affinitive_resources, ...).
If there's a better term I'm happy to change it.
More information about the pve-devel
mailing list