]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
manager: online node usage: factor out possible traget and future proof
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 22 Jul 2022 07:12:37 +0000 (09:12 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 22 Jul 2022 07:12:38 +0000 (09:12 +0200)
only count up target selection if that node is already in the online
node usage list, to avoid that a offline node is considered online if
its a target from any command

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/HA/Manager.pm

index aefb482ea0b030954c277d63de8a23afa3617c34..ec29e03a5817249c01e6b3d64eb1fcf9df656663 100644 (file)
@@ -187,6 +187,7 @@ sub recompute_online_node_usage {
     foreach my $sid (keys %{$self->{ss}}) {
        my $sd = $self->{ss}->{$sid};
        my $state = $sd->{state};
+       my $target = $sd->{target}; # optional
        if (defined($online_node_usage->{$sd->{node}})) {
            if (
                $state eq 'started' || $state eq 'request_stop' || $state eq 'fence' ||
@@ -196,13 +197,13 @@ sub recompute_online_node_usage {
            } elsif (($state eq 'migrate') || ($state eq 'relocate')) {
                # count it for both, source and target as load is put on both
                $online_node_usage->{$sd->{node}}++;
-               $online_node_usage->{$sd->{target}}++;
+               $online_node_usage->{$target}++;
            } elsif ($state eq 'stopped') {
                # do nothing
            } else {
                die "should not be reached (sid = '$sid', state = '$state')";
            }
-       } elsif (defined(my $target = $sd->{target})) {
+       } elsif (defined($target) && defined($online_node_usage->{$target})) {
            if ($state eq 'migrate' || $state eq 'relocate') {
                # to correctly track maintenance modi and also consider the target as used for the
                # case a node dies, as we cannot really know if the to-be-aborted incoming migration