Commit 11dc66f3 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno Committed by Iustin Pop

Add new back-end parameter "always_failover"

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: default avatarBernardo Dal Seno <bdalseno@google.com>
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 1cdc9dbb
......@@ -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" %
......
......@@ -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)
......
......@@ -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 = {
......
......@@ -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.
......
......@@ -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
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment