Using the added stop-all functionality from daemon-utils in cluster-merge
authorRené Nussbaumer <rn@google.com>
Fri, 16 Apr 2010 11:49:47 +0000 (13:49 +0200)
committerRené Nussbaumer <rn@google.com>
Tue, 20 Apr 2010 09:38:05 +0000 (11:38 +0200)
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

index fb5e5b2..89eb563 100755 (executable)
@@ -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")