From b5f0b5cc16dd3221df06e2fc1353b048eef17d06 Mon Sep 17 00:00:00 2001
From: Bernardo Dal Seno <bdalseno@google.com>
Date: Thu, 13 Sep 2012 22:25:32 +0200
Subject: [PATCH] Always_failover doesn't require --allow-failover anymore

If an administrator sets always_failover, it means that there is no need
for another explicit approval to failover instead of migrating.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cmdlib.py        | 11 +++--------
 man/gnt-instance.rst |  3 +++
 qa/qa_instance.py    |  5 ++---
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index a83878703..71d4698ae 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8174,14 +8174,9 @@ class TLMigrateInstance(Tasklet):
     # check if failover must be forced instead of migration
     if (not self.cleanup and not self.failover and
         i_be[constants.BE_ALWAYS_FAILOVER]):
-      if self.fallback:
-        self.lu.LogInfo("Instance configured to always failover; fallback"
-                        " to failover")
-        self.failover = True
-      else:
-        raise errors.OpPrereqError("This instance has been configured to"
-                                   " always failover, please allow failover",
-                                   errors.ECODE_STATE)
+      self.lu.LogInfo("Instance configured to always failover; fallback"
+                      " to failover")
+      self.failover = True
 
     # check bridge existance
     _CheckInstanceBridgesExist(self.lu, instance, node=target_node)
diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst
index c08ea4f4c..b208954ed 100644
--- a/man/gnt-instance.rst
+++ b/man/gnt-instance.rst
@@ -1573,6 +1573,9 @@ The ``--no-runtime-changes`` option forbids migrate to alter an
 instance's runtime before migrating it (eg. ballooning an instance
 down because the target node doesn't have enough available memory).
 
+If an instance has the backend parameter ``always\_failover`` set to
+true, then the migration is automatically converted into a failover.
+
 See **ganeti(7)** for a description of ``--submit`` and other common
 options.
 
diff --git a/qa/qa_instance.py b/qa/qa_instance.py
index 9b9168db8..5cc628760 100644
--- a/qa/qa_instance.py
+++ b/qa/qa_instance.py
@@ -275,10 +275,9 @@ def TestInstanceMigrate(instance):
                   (constants.BE_ALWAYS_FAILOVER, constants.VALUE_TRUE)),
                  instance["name"]])
 
-  AssertCommand(cmd, fail=True)
+  AssertCommand(cmd)
   qa_utils.RunInstanceCheck(instance, True)
-  AssertCommand(["gnt-instance", "migrate", "--force", "--allow-failover",
-                 instance["name"]])
+  # TODO: Verify that a failover has been done instead of a migration
 
   # TODO: Verify whether the default value is restored here (not hardcoded)
   AssertCommand(["gnt-instance", "modify", "-B",
-- 
GitLab