Make gnt-cluster upgrade refuse to upgrade if an upgrade to be resumed
is present. For the convenience of the user, consider an upgrade
command to the same target version as the upgrade to be resumed as an
equivalent way of saying that the pending upgrade is to be resumed.
Fixes issue 906.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 lib/client/gnt_cluster.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
index 96c115f..705c2d6 100644
--- a/lib/client/gnt_cluster.py
+++ b/lib/client/gnt_cluster.py
@@ -2002,6 +2002,22 @@ def UpgradeGanetiCommand(opts, args):
              " has to be given")
     return 1
 
+  # If we're not told to resume, verify there is no upgrade
+  # in progress.
+  if not opts.resume:
+    oldversion, versionstring = _ReadIntentToUpgrade()
+    if versionstring is not None:
+      # An upgrade is going on; verify whether the target matches
+      if versionstring == opts.to:
+        ToStderr("An upgrade is already in progress. Target version matches,"
+                 " resuming.")
+        opts.resume = True
+        opts.to = None
+      else:
+        ToStderr("An upgrade from %s to %s is in progress; use --resume to"
+                 " finish it first" % (oldversion, versionstring))
+        return 1
+
   oldversion = constants.RELEASE_VERSION
 
   if opts.resume:
-- 
2.1.0.rc2.206.gedb03e5

Reply via email to