Skip to content

Commit e9b6077

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow deletion of compute service with no compute nodes" into stable/victoria
2 parents 816c3e9 + e238cc9 commit e9b6077

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

275290
aggrs = self.aggregate_api.get_aggregates_by_host(context,
276291
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
@@ -712,11 +712,7 @@ def test_services_delete_compute_host_not_found(
712712
'topic': 'compute',
713713
'report_count': 0})
714714
compute.create()
715-
# FIXME(artom) Until bug 1860312 is fixed, the ComputeHostNotFound
716-
# error will get bubbled up to the API as an error 500.
717-
self.assertRaises(
718-
webob.exc.HTTPInternalServerError,
719-
self.controller.delete, self.req, compute.id)
715+
self.controller.delete(self.req, compute.id)
720716
mock_get_all_by_host.assert_called_with(
721717
self.req.environ['nova.context'], 'fake-compute-host')
722718

0 commit comments

Comments
 (0)