From d6de0e57c21472b99cbe71ec62b3967ef7282dec Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 23 Aug 2017 17:39:51 -0400 Subject: [PATCH] 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 --- nova/compute/manager.py | 4 ++++ nova/tests/functional/test_servers.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 45947298ef9c..345ee133ffaa 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -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, diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 73769b653401..980ef6e5e285 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -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,