Merge "Remove source node allocation after live migration completes"
This commit is contained in:
commit
320c0f377b
@ -5633,6 +5633,10 @@ class ComputeManager(manager.Manager):
|
|||||||
# method
|
# method
|
||||||
destroy_vifs = True
|
destroy_vifs = True
|
||||||
|
|
||||||
|
# NOTE(danms): Save source node before calling post method on
|
||||||
|
# destination, which will update it
|
||||||
|
source_node = instance.node
|
||||||
|
|
||||||
# Define domain at destination host, without doing it,
|
# Define domain at destination host, without doing it,
|
||||||
# pause/suspend/terminate do not work.
|
# pause/suspend/terminate do not work.
|
||||||
post_at_dest_success = True
|
post_at_dest_success = True
|
||||||
@ -5664,6 +5668,10 @@ class ComputeManager(manager.Manager):
|
|||||||
# host even before next periodic task.
|
# host even before next periodic task.
|
||||||
self.update_available_resource(ctxt)
|
self.update_available_resource(ctxt)
|
||||||
|
|
||||||
|
rt = self._get_resource_tracker()
|
||||||
|
rt.delete_allocation_for_migrated_instance(
|
||||||
|
instance, source_node)
|
||||||
|
|
||||||
self._update_scheduler_instance_info(ctxt, instance)
|
self._update_scheduler_instance_info(ctxt, instance)
|
||||||
self._notify_about_instance_usage(ctxt, instance,
|
self._notify_about_instance_usage(ctxt, instance,
|
||||||
"live_migration._post.end",
|
"live_migration._post.end",
|
||||||
|
@ -1225,6 +1225,18 @@ class ResourceTracker(object):
|
|||||||
"instance on the source node %s",
|
"instance on the source node %s",
|
||||||
cn_uuid, instance=instance)
|
cn_uuid, instance=instance)
|
||||||
|
|
||||||
|
def delete_allocation_for_migrated_instance(self, instance, node):
|
||||||
|
my_resources = scheduler_utils.resources_from_flavor(instance,
|
||||||
|
instance.flavor)
|
||||||
|
cn = self.compute_nodes[node]
|
||||||
|
res = self.reportclient.remove_provider_from_instance_allocation(
|
||||||
|
instance.uuid, cn.uuid, instance.user_id, instance.project_id,
|
||||||
|
my_resources)
|
||||||
|
if not res:
|
||||||
|
LOG.error('Failed to clean allocation of a migrated instance '
|
||||||
|
'on the source node %s', cn.uuid,
|
||||||
|
instance=instance)
|
||||||
|
|
||||||
def _find_orphaned_instances(self):
|
def _find_orphaned_instances(self):
|
||||||
"""Given the set of instances and migrations already account for
|
"""Given the set of instances and migrations already account for
|
||||||
by resource tracker, sanity check the hypervisor to determine
|
by resource tracker, sanity check the hypervisor to determine
|
||||||
|
@ -1820,31 +1820,17 @@ class ServerMovingTests(test.TestCase, integrated_helpers.InstanceHelperMixin):
|
|||||||
self._run_periodics()
|
self._run_periodics()
|
||||||
|
|
||||||
source_usages = self._get_provider_usages(source_rp_uuid)
|
source_usages = self._get_provider_usages(source_rp_uuid)
|
||||||
# NOTE(lajos katona): After bug 1712045 is solved on the source there
|
# NOTE(danms): There should be no usage for the source
|
||||||
# will be no allocations:
|
self.assertFlavorMatchesAllocation(
|
||||||
# self.assertFlavorMatchesAllocation(
|
{'ram': 0, 'disk': 0, 'vcpus': 0}, source_usages)
|
||||||
# {'ram': 0, 'disk': 0, 'vcpus': 0}, source_usages)
|
|
||||||
|
|
||||||
# NOTE(lajos katona): while bug 1712045 is not solved on the source
|
|
||||||
# host the allocations are remaining:
|
|
||||||
# on the original host should not have the old resource usage
|
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, source_usages)
|
|
||||||
|
|
||||||
dest_usages = self._get_provider_usages(dest_rp_uuid)
|
dest_usages = self._get_provider_usages(dest_rp_uuid)
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_usages)
|
self.assertFlavorMatchesAllocation(self.flavor1, dest_usages)
|
||||||
|
|
||||||
allocations = self._get_allocations_by_server_uuid(server['id'])
|
allocations = self._get_allocations_by_server_uuid(server['id'])
|
||||||
# the server has an allocation on the source and dest nodes
|
# the server has an allocation on only the dest node
|
||||||
self.assertEqual(2, len(allocations))
|
self.assertEqual(1, len(allocations))
|
||||||
|
self.assertNotIn(source_rp_uuid, allocations)
|
||||||
# NOTE(lajos katona): When bug 1712045 is solved the server has
|
|
||||||
# no allocation on the source:
|
|
||||||
# self.assertNotIn(source_rp_uuid, allocations)
|
|
||||||
|
|
||||||
# Instead the source allocation is still there
|
|
||||||
source_allocation = allocations[source_rp_uuid]['resources']
|
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, source_allocation)
|
|
||||||
|
|
||||||
dest_allocation = allocations[dest_rp_uuid]['resources']
|
dest_allocation = allocations[dest_rp_uuid]['resources']
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
||||||
|
|
||||||
@ -1874,32 +1860,16 @@ class ServerMovingTests(test.TestCase, integrated_helpers.InstanceHelperMixin):
|
|||||||
self._run_periodics()
|
self._run_periodics()
|
||||||
|
|
||||||
source_usages = self._get_provider_usages(source_rp_uuid)
|
source_usages = self._get_provider_usages(source_rp_uuid)
|
||||||
# NOTE(lajos katona): After bug 1712045 is solved on the source there
|
# NOTE(danms): There should be no usage for the source
|
||||||
# will be no allocations:
|
self.assertFlavorMatchesAllocation(
|
||||||
# self.assertFlavorMatchesAllocation(
|
{'ram': 0, 'disk': 0, 'vcpus': 0}, source_usages)
|
||||||
# {'ram': 0, 'disk': 0, 'vcpus': 0}, source_usages)
|
|
||||||
|
|
||||||
# NOTE(lajos katona): while bug 1712045 is not solved on the source
|
|
||||||
# host the allocations are remaining:
|
|
||||||
# on the original host should not have the old resource usage
|
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, source_usages)
|
|
||||||
|
|
||||||
dest_usages = self._get_provider_usages(dest_rp_uuid)
|
dest_usages = self._get_provider_usages(dest_rp_uuid)
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_usages)
|
self.assertFlavorMatchesAllocation(self.flavor1, dest_usages)
|
||||||
|
|
||||||
allocations = self._get_allocations_by_server_uuid(server['id'])
|
allocations = self._get_allocations_by_server_uuid(server['id'])
|
||||||
# NOTE(lajos katona): the server has 2 allocations, instead of one,
|
self.assertEqual(1, len(allocations))
|
||||||
# after bug 1712045 will be solved we can expect just one allocation
|
self.assertNotIn(source_rp_uuid, allocations)
|
||||||
self.assertEqual(2, len(allocations))
|
|
||||||
|
|
||||||
# NOTE(lajos katona): When bug 1712045 is solved the server has
|
|
||||||
# no allocation on the source:
|
|
||||||
# self.assertNotIn(source_rp_uuid, allocations)
|
|
||||||
|
|
||||||
# Instead the source allocation is still there
|
|
||||||
source_allocation = allocations[source_rp_uuid]['resources']
|
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, source_allocation)
|
|
||||||
|
|
||||||
dest_allocation = allocations[dest_rp_uuid]['resources']
|
dest_allocation = allocations[dest_rp_uuid]['resources']
|
||||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user