This saves another round of sequential ssh scans over each cluster node,
and gives us another opportunity to rollback to the previous version if
the upgrade fails.

Signed-off-by: Brian Foley <[email protected]>
---
 lib/client/gnt_cluster.py | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
index 5c01666..b76956e 100644
--- a/lib/client/gnt_cluster.py
+++ b/lib/client/gnt_cluster.py
@@ -2061,8 +2061,9 @@ def _GetRunning():
   return len(cl.Query(constants.QR_JOB, [], qfilter).data)
 
 
-def _SetGanetiVersion(versionstring):
-  """Set the active version of ganeti to the given versionstring
+def _SetGanetiVersionAndEnsure(versionstring):
+  """Symlink the active version of ganeti to the given versionstring,
+  and run the ensure-dirs script.
 
   @type versionstring: string
   @rtype: list
@@ -2094,6 +2095,9 @@ def _SetGanetiVersion(versionstring):
         os.path.join(pathutils.SYSCONFDIR, "ganeti/share")]
     cmds = [rm_lib_cmd, link_lib_cmd, rm_share_cmd, ln_share_cmd]
 
+  # Run the ensure-dirs script to verify the new version is OK.
+  cmds.append([pathutils.ENSURE_DIRS])
+
   # Submit all commands to ssh, exiting on the first failure.
   # The command string is a single argument that's given to ssh to submit to
   # the remote shell, so it only needs enough escaping to satisfy the remote
@@ -2274,8 +2278,8 @@ def _SwitchVersionAndConfig(versionstring, downgrade):
   # safer to push through the up/dowgrade than to try to roll it back.
 
   ToStdoutAndLoginfo("Switching to version %s on all nodes", versionstring)
-  rollback.append(lambda: _SetGanetiVersion(constants.DIR_VERSION))
-  badnodes = _SetGanetiVersion(versionstring)
+  rollback.append(lambda: _SetGanetiVersionAndEnsure(constants.DIR_VERSION))
+  badnodes = _SetGanetiVersionAndEnsure(versionstring)
   if badnodes:
     ToStderr("Failed to switch to Ganeti version %s on nodes %s"
              % (versionstring, ", ".join(badnodes)))
@@ -2303,7 +2307,7 @@ def _UpgradeAfterConfigurationChange(oldversion):
   As this part is run at a time where the new version of Ganeti is already
   running, no communication should happen via luxi, as this is not a stable
   interface. Also, as the configuration change is the point of no return,
-  all actions are pushed trough, even if some of them fail.
+  all actions are pushed through, even if some of them fail.
 
   @param oldversion: the version the upgrade started from
   @type oldversion: string
@@ -2313,13 +2317,6 @@ def _UpgradeAfterConfigurationChange(oldversion):
   """
   returnvalue = 0
 
-  ToStdoutAndLoginfo("Ensuring directories everywhere.")
-  badnodes = _VerifyCommand([pathutils.ENSURE_DIRS])
-  if badnodes:
-    ToStderr("Warning: failed to ensure directories on %s." %
-             (", ".join(badnodes)))
-    returnvalue = 1
-
   ToStdoutAndLoginfo("Starting daemons everywhere.")
   badnodes = _VerifyCommand([pathutils.DAEMON_UTIL, "start-all"])
   if badnodes:
-- 
2.8.0.rc3.226.g39d4020

Reply via email to