Re: [PATCH pve-ha-manager v2 5/6] api: status: add load imbalance to status

Daniel Kral
2026-04-30T07:47:23Z

On Wed Apr 29, 2026 at 2:20 PM CEST, Dominik Rusovac wrote:
> This is a very basic measure to enable users to detect the prevailing
> load imbalance in the UI, which atm reveals nothing about the latter.
>
> imo, enabling users to track how the load imbalance changed over time
> (using RRD graphs, for example) should be considered, in the long run.
>
> Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
> ---
>
> Notes:
> changes since v1:
> * check whether load balancing system is enabled
> * binding $crs->{ha} to $mode
>
> src/PVE/API2/HA/Status.pm | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm
> index 4894f3b..8dadff3 100644
> --- a/src/PVE/API2/HA/Status.pm
> +++ b/src/PVE/API2/HA/Status.pm
> @@ -199,8 +199,11 @@ __PACKAGE__->register_method({
> }
> my $datacenter_config = eval { cfs_read_file('datacenter.cfg') } // {};
> if (my $crs = $datacenter_config->{crs}) {
> - $extra_status .= " - $crs->{ha} load CRS"
> - if $crs->{ha} && $crs->{ha} ne 'basic';
> + my $mode = $crs->{ha};
> + $extra_status .=
> + " - $mode load CRS "
> + . sprintf("(load imbalance: %.2f", 100 * $status->{imbalance}) . "%)"
> + if $crs->{'ha-auto-rebalance'} && $mode && $mode ne 'basic';

Sorry, I missed that bit in the previous review, but this should be
something like

my $mode = $crs->{ha};
$extra_status .= " $mode load CRS" if $mode && $mode ne 'basic';
$extra_status .=
sprintf(" (load imbalance: %.2f", 100 * $status->{imbalance}) . " %)"
if $crs->{'ha-auto-rebalance'} && $mode && $mode ne 'basic';

Otherwise the CRS mode wouldn't be visible anymore if auto rebalancing
is not enabled.

> }
> my $time_str = localtime($status->{timestamp});
> my $status_text = "$master ($status_str, $time_str)$extra_status";