From d8aab233450ab4b0c182b2c270e162bba8cc4ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Fri, 16 Apr 2010 13:49:47 +0200 Subject: [PATCH] Using the added stop-all functionality from daemon-utils in cluster-merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additionally also move to the RunWhileStopped method for the configuration merger. Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- tools/cluster-merge | 57 ++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/tools/cluster-merge b/tools/cluster-merge index fb5e5b2fe..89eb563e4 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") -- GitLab