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

Daniel Kral
2026-03-31T13:55:35Z

On Tue Mar 31, 2026 at 11:39 AM CEST, Dominik Rusovac wrote:
> On Tue Mar 31, 2026 at 11:32 AM CEST, Daniel Kral wrote:
>> Good catch, thanks to you both!
>>
>> Even though it's unpractical, users can still set the threshold to 0.0,
>> which could actually cause a division by zero here, because the
>> threshold is compared by a >= relation.
>>

[...]

>>
>> The system is rather unstable in that regard anyway (same if $margin =
>> 0.0), because it always tries to load balance every $hold_duration HA
>> rounds.
>>
>> I'm not sure whether we should prevent this with adjusting the range for
>> both the threshold and margin to be at least larger than some minimum
>> value, so that the load balancing system won't become unstable.
>>
>
> yeah, either this, or you add a guard to return early (before the
> threshold guard) whenever imbalance is 0.0, I guess

As discussed off-list, I think it's reasonable to allow an imbalance
$threshold of 0.0, but even then a current $imbalance of 0.0 shouldn't
trigger that, so I'll change the comparison above to a '>' relation
instead of a '>=' relation.

An imbalance $threshold = 0.0 could mean 'try to always find a load
balancing migration'. Though very aggressive, it doesn't do any harm in
itself and doesn't mean the load balancing system will commit to a
rebalancing migration after all.

However, setting $margin = 0.0 will indicate that any migration - even
if it doesn't change the imbalance at all - will be committed. But after
all this is a user configuration and we should check in the datacenter
config that the values aren't invalid (e.g. negative values) and add to
the {verbose_,}description that the value of 0.0 might not be what users
want, but can still do.