Re: [PATCH ha-manager v3 35/40] implement automatic rebalancing

Michael Köppl
2026-03-31T11:01:08Z

On Tue Mar 31, 2026 at 11:42 AM CEST, Daniel Kral wrote:

[snip]

> # ./perl-array-empty.pl
> array1 value: $VAR1 = undef;
> array1 first: $VAR1 = undef;
> array2 value: $VAR1 = [];
> array2 first: $VAR1 = undef;
> array3 value: $VAR1 = [
> {}
> ];
> array3 first: $VAR1 = {};
> array4 value: $VAR1 = [
> {
> 'something' => 'a'
> },
> {
> 'else' => 'b'
> }
> ];
> array4 first: $VAR1 = {
> 'something' => 'a'
> };
>
> Or do you have another reproducer for this?
>

as discussed off-list, my intuition failed me here. I would've expected
this to not work, but of course autovivification makes it work...

>>> +}
>>> +
>>> +sub score_best_balancing_migrations_topsis {
>>> + my ($self, $migration_candidates, $limit) = @_;
>>> +
>>> + die "implement in subclass";
>>> +}
>>> +
>>> +sub select_best_balancing_migration_topsis {
>>> + my ($self, $migration_candidates) = @_;
>>> +
>>> + my $migrations = $self->score_best_balancing_migrations_topsis($migration_candidates, 1);
>>> +
>>> + return $migrations->[0];
>>> +}
>>> +
>>> # Returns a hash with $nodename => $score pairs. A lower $score is better.
>>> sub score_nodes_to_start_service {
>>> my ($self, $sid) = @_;
>>> diff --git a/src/PVE/HA/Usage/Dynamic.pm b/src/PVE/HA/Usage/Dynamic.pm
>>> index 24c85a41..76d0feaa 100644
>>> --- a/src/PVE/HA/Usage/Dynamic.pm
>>> +++ b/src/PVE/HA/Usage/Dynamic.pm
>>> @@ -104,6 +104,39 @@ sub remove_service_usage {
>>> $self->{haenv}->log('warning', "unable to remove service '$sid' usage - $@") if $@;
>>> }
>>>
>>
>> [snip]