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 <[email protected]>
Reviewed-by: Michael Hanselmann <[email protected]>
(cherry picked from commit b5f0b5cc16dd3221df06e2fc1353b048eef17d06)
---
 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 f8f061e..8e0a622 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8072,14 +8072,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 2d27bfd..749efb6 100644
--- a/man/gnt-instance.rst
+++ b/man/gnt-instance.rst
@@ -1547,6 +1547,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 0ea9f2b..637ce9b 100644
--- a/qa/qa_instance.py
+++ b/qa/qa_instance.py
@@ -236,10 +236,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",
-- 
1.7.7.3

Reply via email to