[pve-devel] [PATCH ha-manager 3/6] go idle if no service is configured for HA anymore

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Feb 8 14:39:05 CET 2016


When we remove all services for HA the CRM stays master and has
it's watchdog waiting to breake loose and kill the node.

We do not want that, so if there is no service left (enabled _and_
disabled) we close the watchdog and go back in the "wait_for_quorum"
state.
If a service gets added again a CRM gets promoted to be the new
master again.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/CRM.pm                         | 14 ++++++++++++++
 src/test/test-service-command5/log.expect |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/src/PVE/HA/CRM.pm b/src/PVE/HA/CRM.pm
index 3eec1ff..36c1df9 100644
--- a/src/PVE/HA/CRM.pm
+++ b/src/PVE/HA/CRM.pm
@@ -218,6 +218,20 @@ sub do_one_iteration {
 
 	    } else {
 		$manager->manage();
+
+		# when no service is configured release lock and go in an
+		# idle state
+		if (!PVE::HA::Tools::has_services($haenv)) {
+		    $haenv->log('info', "no services configured, release " .
+				" manager lock and go idle");
+		    if ($self->{ha_manager_wd}) {
+			$haenv->watchdog_close($self->{ha_manager_wd});
+			delete $self->{ha_manager_wd};
+		    }
+		    $haenv->release_ha_manager_lock();
+		    $self->set_local_status({ state => 'wait_for_quorum'});
+		}
+
 	    }
 	};
 	if (my $err = $@) {
diff --git a/src/test/test-service-command5/log.expect b/src/test/test-service-command5/log.expect
index 32506f1..3d22d41 100644
--- a/src/test/test-service-command5/log.expect
+++ b/src/test/test-service-command5/log.expect
@@ -22,6 +22,8 @@ info     25    node3/lrm: starting service vm:103
 info     25    node3/lrm: service status vm:103 started
 info    120      cmdlist: execute service vm:103 delete
 info    120    node1/crm: removing stale service 'vm:103' (no config)
+info    120    node1/crm: no services configured, release  manager lock and go idle
+info    120    node1/crm: status change master => wait_for_quorum
 info    122    node2/crm: status change slave => wait_for_quorum
 info    124    node3/crm: status change slave => wait_for_quorum
 info    720     hardware: exit simulation - done
-- 
2.1.4





More information about the pve-devel mailing list