]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
lrm: always give up lock if node went successfully into maintenance
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 20 Mar 2023 12:06:55 +0000 (13:06 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 20 Mar 2023 12:07:45 +0000 (13:07 +0100)
the change as of now is a no-op, as we only ever switched to
maintenance mode on shutdown-request, and there we exited immediately
if no active service and worker where around anyway.

So this is mostly preparing for a manual maintenance mode without any
pending shutdown.

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

index 3b8ca440f475e0cac86bc8096751c2bca2b11987..4f126862a3c7737368ead9aa310e3569c7aecc29 100644 (file)
@@ -392,8 +392,11 @@ sub work {
        if ($fence_request) {
            $haenv->log('err', "node need to be fenced during maintenance mode - releasing agent_lock\n");
            $self->set_local_status({ state => 'lost_agent_lock'});
-       } elsif (!$self->get_protected_ha_agent_lock()) {
-           $self->set_local_status({ state => 'lost_agent_lock'});
+       } elsif ($self->active_service_count() || $self->run_workers()) {
+           # keep the lock and watchdog as long as not all services cleared the node
+           if (!$self->get_protected_ha_agent_lock()) {
+               $self->set_local_status({ state => 'lost_agent_lock'});
+           }
        }
     }
 
@@ -522,16 +525,16 @@ sub work {
 
        my $exit_lrm = 0;
 
-       if ($self->{shutdown_request}) {
-           if ($service_count == 0 && $self->run_workers() == 0) {
-               # safety: going into maintenance and all active services got moved -> OK
-               give_up_watchdog_protection($self);
+       if ($service_count == 0 && $self->run_workers() == 0) {
+           # safety: going into maintenance and all active services got moved -> OK
+           give_up_watchdog_protection($self);
 
+           if ($self->{shutdown_request}) {
                $exit_lrm = 1;
-
-               # restart with no or freezed services, release the lock
-               $haenv->release_ha_agent_lock();
            }
+
+           # maintenance mode with no or only frozen services anymore, release the lock
+           $haenv->release_ha_agent_lock();
        }
 
        $self->manage_resources() if !$exit_lrm;