[pve-devel] [RFC v2 pve-ha-manager 8/9] do not freeze services on a graceful poweroff

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 14 15:30:00 CET 2015


When stopping the LRM because the Node shuts gracefully down we now
do not freeze remaining services anymore.
If the node comes back up again within about 2 minutes it takes up
work and start it's services as expected. If not, the node will be
fenced so that the services can be started elsewhere.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/LRM.pm     | 22 +++++++++++++++++++---
 src/PVE/HA/Manager.pm |  3 ++-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm
index 74bcee6..fe844da 100644
--- a/src/PVE/HA/LRM.pm
+++ b/src/PVE/HA/LRM.pm
@@ -44,8 +44,18 @@ sub shutdown_request {
     my ($self) = @_;
 
     $self->{shutdown_request} = 1;
+    my $haenv = $self->{haenv};
+
+    my $shutdown = $haenv->is_poweroff();
 
-    $self->{mode} = 'restart'; # fixme: detect shutdown/reboot
+    if ($shutdown) {
+	$haenv->log('notice', "stop LRM while powering node off." .
+		    " Remaining services will not get freezed");
+	$self->{mode} = 'shutdown';
+    } else {
+	$haenv->log('notice', "stop LRM, freeze all services");
+	$self->{mode} = 'restart';
+    }
 
     eval { $self->update_lrm_status(); };
     if (my $err = $@) {
@@ -271,11 +281,17 @@ sub do_one_iteration {
 
 	    if ($self->{shutdown_request}) {
 
-		# fixme: request service stop or relocate ?
+		# service will be relocate if we shutdown and don't come back
+		# fast enough
 
 		my $service_count = $self->active_service_count();
 
-		if ($service_count == 0) {
+		if ($service_count == 0 || $self->{mode} eq 'shutdown') {
+
+		    # gracefully shut down remaining started HA Services
+		    if ($service_count > 0) {
+			&$shutdown_all_remaining_services($self);
+		    }
 
 		    if ($self->{ha_agent_wd}) {
 			$haenv->watchdog_close($self->{ha_agent_wd});
diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index 6a98cd3..757deb7 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -361,7 +361,8 @@ sub manage {
 	    my $lrm_mode = $sd->{node} ? $lrm_modes->{$sd->{node}} : undef;
 	    $lrm_mode = 'unknown'if !$lrm_mode;
 	    if (($sd->{state} eq 'started' || $sd->{state} eq 'stopped' ||
-		 $sd->{state} eq 'request_stop') && ($lrm_mode ne 'active')) {
+		 $sd->{state} eq 'request_stop') && ($lrm_mode ne 'active' &&
+		 $lrm_mode ne 'shutdown') ) {
 		&$change_service_state($self, $sid, 'freeze');
 	    }
 		    
-- 
2.1.4





More information about the pve-devel mailing list