Commit e57602c2 authored by Guido Trotter's avatar Guido Trotter
Browse files

Migrate/Failover: allow less-than-max-mem op

Failover works magically after we relax the check: the start operation
will just use less memory, if less memory is available.

For migrate we need to balloon down the source memory before the
migration, if the target node doesn't have enough capacity.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarIustin Pop <>
parent c113a9ab
......@@ -7908,9 +7908,11 @@ class TLMigrateInstance(Tasklet):
# check memory requirements on the secondary node
if (not self.cleanup and
(not self.failover or instance.admin_state == constants.ADMINST_UP)):
_CheckNodeFreeMemory(, target_node, "migrating instance %s" %, i_be[constants.BE_MAXMEM],
self.tgt_free_mem = _CheckNodeFreeMemory(, target_node,
"migrating instance %s" %,
else:"Not checking memory on the secondary node as"
" instance will not be started")
......@@ -7968,6 +7970,16 @@ class TLMigrateInstance(Tasklet):
# Failover is never live = False
if not (self.failover or self.cleanup):
remote_info = self.rpc.call_instance_info(instance.primary_node,,
remote_info.Raise("Error checking instance on node %s" %
instance_running = bool(remote_info.payload)
if instance_running:
self.current_mem = int(remote_info.payload["memory"])
def _RunAllocator(self):
"""Run the allocator based on input opcode.
......@@ -8213,6 +8225,13 @@ class TLMigrateInstance(Tasklet):
" synchronized on target node,"
" aborting migration" % dev.iv_name)
if self.current_mem > self.tgt_free_mem:
self.feedback_fn("* setting instance memory to %s" % self.tgt_free_mem)
rpcres = self.rpc.call_instance_balloon_memory(instance.primary_node,
rpcres.Raise("Cannot modify instance runtime memory")
# First get the migration information from the remote node
result = self.rpc.call_migration_info(source_node, instance)
msg = result.fail_msg
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