[pve-devel] [RFC v3 pve-ha-manager 6/8] correctly reset node status on popwer on/off

Dietmar Maurer dietmar at proxmox.com
Wed Dec 16 09:04:48 CET 2015


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 src/PVE/HA/Sim/RTHardware.pm     | 3 ++-
 src/PVE/HA/Sim/TestEnv.pm        | 7 +------
 src/PVE/HA/Sim/TestHardware.pm   | 4 +++-
 src/test/test-basic5/log.expect  | 2 ++
 src/test/test-reboot1/log.expect | 8 ++++----
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 54f6fba..2148e20 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -207,7 +207,7 @@ sub sim_hardware_cmd {
 	
 	if ($cmd eq 'power') {
 	    if ($cstatus->{$node}->{power} ne $action) {
-		if ($action eq 'on') {	      
+		if ($action eq 'on') {
 		    $d->{crm} = $self->fork_daemon($lockfh, 'crm', $node) if !$d->{crm};
 		    $d->{lrm} = $self->fork_daemon($lockfh, 'lrm', $node) if !$d->{lrm};
 		} else {
@@ -222,6 +222,7 @@ sub sim_hardware_cmd {
 			$d->{lrm} = undef;
 		    }
 		    $self->watchdog_reset_nolock($node);
+		    $self->write_service_status($node, {});
 		}
 	    }
 
diff --git a/src/PVE/HA/Sim/TestEnv.pm b/src/PVE/HA/Sim/TestEnv.pm
index 8e47db0..414c274 100644
--- a/src/PVE/HA/Sim/TestEnv.pm
+++ b/src/PVE/HA/Sim/TestEnv.pm
@@ -123,12 +123,7 @@ sub is_node_shutdown {
 
     die "undefined node status for node '$node'" if !defined($cstatus->{$node});
 
-    if (defined($cstatus->{$node}->{shutdown}) &&
-	$cstatus->{$node}->{shutdown} eq 'shutdown') {
-	return 1;
-    }
-
-    return 0;
+    return defined($cstatus->{$node}->{shutdown}) ? 1 : 0;
 }
 
 1;
diff --git a/src/PVE/HA/Sim/TestHardware.pm b/src/PVE/HA/Sim/TestHardware.pm
index 3a06906..89af119 100644
--- a/src/PVE/HA/Sim/TestHardware.pm
+++ b/src/PVE/HA/Sim/TestHardware.pm
@@ -106,7 +106,7 @@ sub sim_hardware_cmd {
 	if ($cmd eq 'power') {
 	    die "sim_hardware_cmd: unknown action '$action'" if $action !~ m/^(on|off)$/;
 	    if ($cstatus->{$node}->{power} ne $action) {
-		if ($action eq 'on') {	      
+		if ($action eq 'on') {
 		    $d->{crm} = PVE::HA::CRM->new($d->{crm_env}) if !$d->{crm};
 		    $d->{lrm} = PVE::HA::LRM->new($d->{lrm_env}) if !$d->{lrm};
 		} else {
@@ -118,6 +118,8 @@ sub sim_hardware_cmd {
 			$d->{lrm_env}->log('info', "killed by poweroff");
 			$d->{lrm} = undef;
 		    }
+		    $self->watchdog_reset_nolock($node);
+		    $self->write_service_status($node, {});
 		}
 	    }
 
diff --git a/src/test/test-basic5/log.expect b/src/test/test-basic5/log.expect
index ca25f00..7a1782b 100644
--- a/src/test/test-basic5/log.expect
+++ b/src/test/test-basic5/log.expect
@@ -62,4 +62,6 @@ info    523    node2/lrm: service vm:101 - end migrate to node 'node1'
 info    524    node3/crm: service 'vm:101': state changed from 'migrate' to 'started'  (node = node1)
 info    541    node1/lrm: got lock 'ha_agent_node1_lock'
 info    541    node1/lrm: status change wait_for_agent_lock => active
+info    541    node1/lrm: starting service vm:101
+info    541    node1/lrm: service status vm:101 started
 info   1100     hardware: exit simulation - done
diff --git a/src/test/test-reboot1/log.expect b/src/test/test-reboot1/log.expect
index 43e7d0f..48e43cb 100644
--- a/src/test/test-reboot1/log.expect
+++ b/src/test/test-reboot1/log.expect
@@ -21,8 +21,7 @@ info     25    node3/lrm: status change wait_for_agent_lock => active
 info     25    node3/lrm: starting service vm:103
 info     25    node3/lrm: service status vm:103 started
 info    120      cmdlist: execute reboot node3
-info    120    node3/lrm: restart LRM, freeze all services
-info    120    node1/crm: service 'vm:103': state changed from 'started' to 'freeze' 
+info    120    node3/lrm: shutdown LRM, stop all services
 info    126    node3/lrm: exit (loop end)
 info    126       reboot: execute power node3 off
 info    125    node3/crm: killed by poweroff
@@ -30,6 +29,7 @@ info    126       reboot: execute power node3 on
 info    125    node3/crm: status change startup => wait_for_quorum
 info    126    node3/lrm: status change startup => wait_for_agent_lock
 info    144    node3/crm: status change wait_for_quorum => slave
-info    160    node1/crm: service 'vm:103': state changed from 'freeze' to 'started' 
-info    165    node3/lrm: status change wait_for_agent_lock => active
+info    145    node3/lrm: status change wait_for_agent_lock => active
+info    145    node3/lrm: starting service vm:103
+info    145    node3/lrm: service status vm:103 started
 info    720     hardware: exit simulation - done
-- 
2.1.4



More information about the pve-devel mailing list