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

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Dec 11 20:01:44 CET 2015


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

diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm
index 89177ee..b070273 100644
--- a/src/PVE/HA/LRM.pm
+++ b/src/PVE/HA/LRM.pm
@@ -44,8 +44,17 @@ sub shutdown_request {
     my ($self) = @_;
 
     $self->{shutdown_request} = 1;
+    my $haenv = $self->{haenv};
+
+    my $restart = !$haenv->is_poweroff();
 
-    $self->{mode} = 'restart'; # fixme: detect shutdown/reboot
+    if ($restart) {
+	$haenv->log('notice', "restart LRM, freeze all services");
+	$self->{mode} = 'restart';
+    } else {
+	$haenv->log('notice', "stop LRM, remaining services will not get freezed");
+	$self->{mode} = 'shutdown';
+    }
 
     eval { $self->update_lrm_status(); };
     if (my $err = $@) {
@@ -241,11 +250,12 @@ 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') {
 
 		    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