Delete instance allocations when the instance is deleted

In a deployment that still has Ocata computes, the resource
tracker will delete the allocations for an instance when it
is deleted, but in an all-Pike+ computes deployment, the
allocations will only be removed for a deleted instance
during the update_available_resource periodic task.

The capacity on the node should be freed as soon as the
instance is deleted, like when we shelve offload an
instance, so this does that.

The ServerMovingTests functional tests were glossing over
this by forcing the run of the update_available_resource
periodic task code after the instance was deleted but
before checking the allocations were gone from Placement.
So this change removes that part of the tests to show
this fixes the problem.

Change-Id: I0f57b4ba8e4c3931b70bd737de5b7c8ae47f033d
Closes-Bug: #1712684
This commit is contained in:
Matt Riedemann 2017-08-23 17:39:51 -04:00
parent c35ad953e4
commit d6de0e57c2
2 changed files with 4 additions and 2 deletions

View File

@ -724,6 +724,10 @@ class ComputeManager(manager.Manager):
bdm.destroy()
self._update_resource_tracker(context, instance)
rt = self._get_resource_tracker()
rt.reportclient.delete_allocation_for_instance(instance.uuid)
self._notify_about_instance_usage(context, instance, "delete.end",
system_metadata=system_meta)
compute_utils.notify_about_instance_action(context, instance,

View File

@ -1311,8 +1311,6 @@ class ServerMovingTests(test.TestCase, integrated_helpers.InstanceHelperMixin):
self.api.delete_server(server['id'])
self._wait_until_deleted(server)
self._run_periodics()
source_usages = self._get_provider_usages(source_rp_uuid)
self.assertEqual({'VCPU': 0,
'MEMORY_MB': 0,