diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 3ee1f5b14ff0..75bbf342644f 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -1053,6 +1053,8 @@ class ComputeTaskManager(base.Base): 'was already deleted.', instance=instance) # This is a placeholder in case the quota recheck fails. instances.append(None) + rc = self.scheduler_client.reportclient + rc.delete_allocation_for_instance(instance.uuid) continue else: instance.availability_zone = ( diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py index 5917701f96ff..1c1c8a6fddba 100644 --- a/nova/tests/unit/conductor/test_conductor.py +++ b/nova/tests/unit/conductor/test_conductor.py @@ -1762,7 +1762,11 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase): select_destinations.return_value = [{'host': 'fake-host', 'nodename': 'nodesarestupid', 'limits': None}] - self.conductor.schedule_and_build_instances(**self.params) + with mock.patch.object(self.conductor.scheduler_client, + 'reportclient') as mock_rc: + self.conductor.schedule_and_build_instances(**self.params) + mock_rc.delete_allocation_for_instance.assert_called_once_with( + inst_uuid) # we don't create the instance since the build request is gone self.assertFalse(inst_create.called) # we don't build the instance since we didn't create it