diff --git a/tools/cluster-merge b/tools/cluster-merge index fb5e5b2fe07ac29ef33fa2665c1fd0309c0500fb..89eb563e4ff960dc23fa488fa4482b9228436de2 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")