@@ -266,10 +266,25 @@ def delete(self, req, id):
266
266
# service delete since we could orphan resource providers and
267
267
# break the ability to do things like confirm/revert instances
268
268
# 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
273
288
274
289
aggrs = self .aggregate_api .get_aggregates_by_host (context ,
275
290
service .host )
0 commit comments