Commit d8aab233 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

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: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 9f3ac970
......@@ -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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment