[pve-devel] [PATCH ha-manager 16/18] api: status: sync active service counting with lrm's helper
Daniel Kral
d.kral at proxmox.com
Tue Sep 2 10:10:27 CEST 2025
On Thu Aug 21, 2025 at 4:35 PM CEST, Daniel Kral wrote:
> diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm
> index 6e13c2c8..3d9aabaa 100644
> --- a/src/PVE/API2/HA/Status.pm
> +++ b/src/PVE/API2/HA/Status.pm
> @@ -197,13 +197,21 @@ __PACKAGE__->register_method({
> my $active_count = {};
> foreach my $sid (sort keys %{ $status->{service_status} }) {
> my $sd = $status->{service_status}->{$sid};
> + my $target = $sd->{target}; # count as active if we are the target.
> next if !$sd->{node};
> $active_count->{ $sd->{node} } = 0 if !defined($active_count->{ $sd->{node} });
> my $req_state = $sd->{state};
> next if !defined($req_state);
> next if $req_state eq 'stopped';
> next if $req_state eq 'freeze';
> + next if $req_state eq 'error';
> + next if $req_state eq 'request_start';
> $active_count->{ $sd->{node} }++;
> +
> + if ($target && $target ne $sd->{node}) {
> + $active_count->{$target} = 0 if !defined($active_count->{$target});
> + $active_count->{$target}++;
> + }
@Michael and I noticed that this (intermediate) change doesn't account
for cases where $sd->{node} is falsy but $sd->{target} is set, which
doesn't make it equal to the lrm's helper.
I'll see what I'll do for a v2, but I'll either just fix it in-place or
move the whole thing into the loop below already, so that $active_count
is already scalar instead of a hash reference, so it's simpler to see in
the last patch that using the introduced helper is valid.
> }
>
> foreach my $node (sort keys %{ $status->{node_status} }) {
More information about the pve-devel
mailing list