Add new back-end parameter "always_failover"
authorBernardo Dal Seno <bdalseno@google.com>
Mon, 5 Dec 2011 19:10:42 +0000 (20:10 +0100)
committerIustin Pop <iustin@google.com>
Thu, 8 Dec 2011 09:51:20 +0000 (10:51 +0100)
Instances that have this parameter is set to True are never migrated, but
instead they can only fail over.  There are some cases where freezing the
kernel may cause problems, and hence this behavior is preferable.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/client/gnt_instance.py
lib/cmdlib.py
lib/constants.py
man/gnt-backup.rst
man/gnt-cluster.rst
man/gnt-instance.rst

index 55f3072..d0a91ea 100644 (file)
@@ -1228,6 +1228,9 @@ def ShowInstanceConfig(opts, args):
     buf.write("    - memory: %sMiB\n" %
               compat.TryToRoman(instance["be_actual"][constants.BE_MAXMEM],
                                 convert=opts.roman_integers))
+    buf.write("    - %s: %s\n" %
+              (constants.BE_ALWAYS_FAILOVER,
+               instance["be_actual"][constants.BE_ALWAYS_FAILOVER]))
     buf.write("    - NICs:\n")
     for idx, (ip, mac, mode, link) in enumerate(instance["nics"]):
       buf.write("      - nic/%d: MAC: %s, IP: %s, mode: %s, link: %s\n" %
index 8541e93..7f728d6 100644 (file)
@@ -7547,6 +7547,18 @@ class TLMigrateInstance(Tasklet):
       self.lu.LogInfo("Not checking memory on the secondary node as"
                       " instance will not be started")
 
+    # 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)
+
     # check bridge existance
     _CheckInstanceBridgesExist(self.lu, instance, node=target_node)
 
index 574bf91..f0bba6a 100644 (file)
@@ -904,12 +904,14 @@ BE_MAXMEM = "maxmem"
 BE_MINMEM = "minmem"
 BE_VCPUS = "vcpus"
 BE_AUTO_BALANCE = "auto_balance"
+BE_ALWAYS_FAILOVER = "always_failover"
 
 BES_PARAMETER_TYPES = {
   BE_MAXMEM: VTYPE_SIZE,
   BE_MINMEM: VTYPE_SIZE,
   BE_VCPUS: VTYPE_INT,
   BE_AUTO_BALANCE: VTYPE_BOOL,
+  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
   }
 
 BES_PARAMETER_COMPAT = {
@@ -1715,6 +1717,7 @@ BEC_DEFAULTS = {
   BE_MAXMEM: 128,
   BE_VCPUS: 1,
   BE_AUTO_BALANCE: True,
+  BE_ALWAYS_FAILOVER: False,
   }
 
 NDC_DEFAULTS = {
index 0e0077a..ff01d63 100644 (file)
@@ -152,6 +152,11 @@ auto_balance
     whether the instance is considered in the N+1 cluster checks
     (enough redundancy in the cluster to survive a node failure)
 
+always\_failover
+    ``True`` or ``False``, whether the instance must be failed over
+    (shut down and rebooted) always or it may be migrated (briefly
+    suspended)
+
 
 The ``-t`` options specifies the disk layout type for the instance.
 If not passed, the configuration of the original instance is used.
index 3c46a29..187b69d 100644 (file)
@@ -337,6 +337,10 @@ auto\_balance
     Value of the auto\_balance flag for instances to use by default,
     will be set to true if not specified.
 
+always\_failover
+    Default value for the ``always\_failover`` flag for instances; if
+    not set, ``False`` is used.
+
 
 The ``-N (--nic-parameters)`` option allows you to set the default nic
 parameters for the cluster. The parameter format is a comma-separated
index dcee0d4..2fab5d4 100644 (file)
@@ -144,6 +144,11 @@ auto\_balance
     whether the instance is considered in the N+1 cluster checks
     (enough redundancy in the cluster to survive a node failure)
 
+always\_failover
+    ``True`` or ``False``, whether the instance must be failed over
+    (shut down and rebooted) always or it may be migrated (briefly
+    suspended)
+
 Note that before 2.6 Ganeti had a ``memory`` parameter, which was the
 only value of memory an instance could have. With the
 ``maxmem``/``minmem`` change Ganeti guarantees that at least the minimum
@@ -1444,7 +1449,7 @@ ignored.
 The option ``-f`` will skip the prompting for confirmation.
 
 If ``--allow-failover`` is specified it tries to fallback to failover if
-it already can determine that a migration won't work (i.e. if the
+it already can determine that a migration won't work (e.g. if the
 instance is shut down). Please note that the fallback will not happen
 during execution. If a migration fails during execution it still fails.