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