Skip to content

Commit 732caaf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow deletion of compute service with no compute nodes" into stable/wallaby
2 parents f64ccc4 + df5158b commit 732caaf

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

nova/api/openstack/compute/services.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,25 @@ def delete(self, req, id):
266266
# service delete since we could orphan resource providers and
267267
# break the ability to do things like confirm/revert instances
268268
# in VERIFY_RESIZE status.
269-
compute_nodes = objects.ComputeNodeList.get_all_by_host(
270-
context, service.host)
271-
self._assert_no_in_progress_migrations(
272-
context, id, compute_nodes)
269+
compute_nodes = []
270+
try:
271+
compute_nodes = objects.ComputeNodeList.get_all_by_host(
272+
context, service.host)
273+
self._assert_no_in_progress_migrations(
274+
context, id, compute_nodes)
275+
except exception.ComputeHostNotFound:
276+
# NOTE(artom) Consider the following situation:
277+
# - Using the Ironic virt driver
278+
# - Replacing (so removing and re-adding) all baremetal
279+
# nodes associated with a single nova-compute service
280+
# The update resources periodic will have destroyed the
281+
# compute node records because they're no longer being
282+
# reported by the virt driver. If we then attempt to
283+
# manually delete the compute service record,
284+
# get_all_host() above will raise, as there are no longer
285+
# any compute node records for the host. Catch it here and
286+
# continue to allow compute service deletion.
287+
pass
273288

274289
aggrs = self.aggregate_api.get_aggregates_by_host(context,
275290
service.host)

nova/tests/unit/api/openstack/compute/test_services.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,7 @@ def test_services_delete_compute_host_not_found(
711711
'topic': 'compute',
712712
'report_count': 0})
713713
compute.create()
714-
# FIXME(artom) Until bug 1860312 is fixed, the ComputeHostNotFound
715-
# error will get bubbled up to the API as an error 500.
716-
self.assertRaises(
717-
webob.exc.HTTPInternalServerError,
718-
self.controller.delete, self.req, compute.id)
714+
self.controller.delete(self.req, compute.id)
719715
mock_get_all_by_host.assert_called_with(
720716
self.req.environ['nova.context'], 'fake-compute-host')
721717

0 commit comments

Comments
 (0)