From: René Nussbaumer Date: Fri, 16 Apr 2010 11:49:47 +0000 (+0200) Subject: Using the added stop-all functionality from daemon-utils in cluster-merge X-Git-Tag: v2.1.2~45 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/d8aab233450ab4b0c182b2c270e162bba8cc4ccf Using the added stop-all functionality from daemon-utils in cluster-merge Additionally also move to the RunWhileStopped method for the configuration merger. Signed-off-by: René Nussbaumer Reviewed-by: Guido Trotter Reviewed-by: Michael Hanselmann --- diff --git a/tools/cluster-merge b/tools/cluster-merge index fb5e5b2..89eb563 100755 --- a/tools/cluster-merge +++ b/tools/cluster-merge @@ -208,30 +208,14 @@ class Merger(object): " Fail reason: %s; output: %s" % (cluster, result.fail_reason, result.output)) - - # R0201: Method could be a function - def _EnableWatcher(self): # pylint: disable-msg=R0201 - """Reenable watcher (locally). - - """ - result = utils.RunCmd(["gnt-cluster", "watcher", "continue"]) - - if result.failed: - logging.warning("Unable to continue watcher. Fail reason: %s;" - " output: %s", result.fail_reason, result.output) - def _StopDaemons(self): """Stop all daemons on merging nodes. """ - # FIXME: Worth to put this into constants? - cmds = [] - for daemon in (constants.RAPI, constants.MASTERD, - constants.NODED, constants.CONFD): - cmds.append("%s stop %s" % (constants.DAEMON_UTIL, daemon)) + cmd = "%s stop-all" % constants.DAEMON_UTIL for data in self.merger_data: for node in data.nodes: - result = self._RunCmd(node, " && ".join(cmds)) + result = self._RunCmd(node, cmd) if result.failed: raise errors.RemoteError("Unable to stop daemons on %s." @@ -401,22 +385,27 @@ class Merger(object): self._StopDaemons() logging.info("Merging config") self._FetchRemoteConfig() - self._KillMasterDaemon() - - rbsteps.append("Restore %s from another master candidate" % - constants.CLUSTER_CONF_FILE) - self._MergeConfig() - self._StartMasterDaemon(no_vote=True) - - # Point of no return, delete rbsteps - del rbsteps[:] - - logging.warning("We are at the point of no return. Merge can not easily" - " be undone after this point.") - logging.info("Readd nodes and redistribute config") - self._ReaddMergedNodesAndRedist() - self._KillMasterDaemon() - self._StartMasterDaemon() + + def _OfflineClusterMerge(): + """Closure run when master daemons stopped + + """ + rbsteps.append("Restore %s from another master candidate" % + constants.CLUSTER_CONF_FILE) + self._MergeConfig() + self._StartMasterDaemon(no_vote=True) + + # Point of no return, delete rbsteps + del rbsteps[:] + + logging.warning("We are at the point of no return. Merge can not easily" + " be undone after this point.") + logging.info("Readd nodes and redistribute config") + self._ReaddMergedNodesAndRedist() + self._KillMasterDaemon() + + cli.RunWhileClusterStopped(logging.info, _OfflineClusterMerge) + logging.info("Starting instances again") self._StartupAllInstances() logging.info("Post cluster verification")