From f01196805bc391b47d00af2a7093b3f0ef65744d Mon Sep 17 00:00:00 2001 From: Ramesh Nachimuthu Date: Tue, 10 Jun 2014 11:33:48 +0530 Subject: autoconfig: Handle sync host deletion in auto config. Auto config uses a user configured host to periodically sync the gluster configuration. If the host used for sync itself is removed from the cluster, then auto config will detect this as all other hosts are getting removed from cluster. Fixing this issue by not removing all the hosts except sync host in auto mode. User has to run the auto config manually with differnt host to remove sync host. Change-Id: I18fa51b4ed9674264ea8b2d2f615f7680a59c04e Bug-Url: https://bugzilla.redhat.com/1107998 Signed-off-by: Ramesh Nachimuthu Reviewed-on: http://review.gluster.org/8024 Reviewed-by: Sahina Bose --- plugins/discovery.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/discovery.py b/plugins/discovery.py index 825d8d3..e236842 100755 --- a/plugins/discovery.py +++ b/plugins/discovery.py @@ -496,6 +496,13 @@ def _findDuplicateHost(hosts, clusterName): return host.get('hostname') +def getRemovedHostsCount(clusterDelta): + removedHostsCount = 0 + for host in clusterDelta.get('_hosts', []): + if host.get(CHANGE_MODE) == CHANGE_MODE_REMOVE: + removedHostsCount += 1 + return removedHostsCount + if __name__ == '__main__': args = parse_input() clusterdata = discoverCluster(args.hostip, args.cluster, args.timeout) @@ -553,6 +560,14 @@ if __name__ == '__main__': print "Start the Nagios service to monitor" #auto mode means write the configurations without asking confirmation elif args.mode == "auto": + removed_hosts_count = getRemovedHostsCount(clusterDelta) + if removed_hosts_count > 0: + hostsInCluster = server_utils.getHostConfigsForCluster( + args.cluster) + if removed_hosts_count == (len(hostsInCluster) - 1): + print "Can't remove all hosts except sync host in " \ + "'auto' mode. Run auto discovery manually" + sys.exit(utils.PluginStatusCode.CRITICAL) writeDelta(clusterDelta, configManager, args.force, args.nagiosServerIP, args.mode, args.timeout) msg = "Cluster configurations synced successfully from host %s" % \ -- cgit