Commit d0cd1368 authored by Klaus Aehlig's avatar Klaus Aehlig

Support group evacuation by failover

Support evacuating a node group not using migration.
This can be useful if the group evacuated to has different
hardware.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 2039321f
......@@ -243,7 +243,8 @@ def EvacuateGroup(opts, args):
iallocator=opts.iallocator,
target_groups=opts.to,
early_release=opts.early_release,
sequential=opts.sequential)
sequential=opts.sequential,
force_failover=opts.force_failover)
result = SubmitOrSend(op, opts, cl=cl)
# Keep track of submitted jobs
......@@ -359,7 +360,8 @@ commands = {
"[--dry-run] <group-name> <new-name>", "Rename a node group"),
"evacuate": (
EvacuateGroup, [ArgGroup(min=1, max=1)],
[TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT, SEQUENTIAL_OPT]
[TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT, SEQUENTIAL_OPT,
FORCE_FAILOVER_OPT]
+ SUBMIT_OPTS,
"[-I <iallocator>] [--to <group>]",
"Evacuate all instances within a group"),
......
......@@ -28,6 +28,7 @@ from ganeti import constants
from ganeti import errors
from ganeti import locking
from ganeti import objects
from ganeti import opcodes
from ganeti import qlang
from ganeti import query
from ganeti import utils
......@@ -834,6 +835,24 @@ class LUGroupEvacuate(LogicalUnit):
return (run_nodes, run_nodes)
@staticmethod
def _MigrateToFailover(op):
"""Return an equivalent failover opcode for a migrate one.
If the argument is not a failover opcode, return it unchanged.
"""
if not isinstance(op, opcodes.OpInstanceMigrate):
return op
else:
return opcodes.OpInstanceFailover(
instance_name=op.instance_name,
instance_uuid=getattr(op, "instance_uuid", None),
target_node=getattr(op, "target_node", None),
target_node_uuid=getattr(op, "target_node_uuid", None),
ignore_ipolicy=op.ignore_ipolicy,
cleanup=op.cleanup)
def Exec(self, feedback_fn):
inst_names = list(self.owned_locks(locking.LEVEL_INSTANCE))
......@@ -856,6 +875,10 @@ class LUGroupEvacuate(LogicalUnit):
self.LogInfo("Iallocator returned %s job(s) for evacuating node group %s",
len(jobs), self.op.group_name)
if self.op.force_failover:
self.LogInfo("Will insist on failovers")
jobs = [[self._MigrateToFailover(op) for op in job] for job in jobs]
if self.op.sequential:
self.LogInfo("Jobs will be submitted to run sequentially")
for job in jobs[1:]:
......
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