Merge "Allow deletion of compute service with no compute nodes" into stable/victoria
This commit is contained in:
commit
e9b60776b4
|
@ -267,10 +267,25 @@ class ServiceController(wsgi.Controller):
|
||||||
# service delete since we could orphan resource providers and
|
# service delete since we could orphan resource providers and
|
||||||
# break the ability to do things like confirm/revert instances
|
# break the ability to do things like confirm/revert instances
|
||||||
# in VERIFY_RESIZE status.
|
# in VERIFY_RESIZE status.
|
||||||
|
compute_nodes = []
|
||||||
|
try:
|
||||||
compute_nodes = objects.ComputeNodeList.get_all_by_host(
|
compute_nodes = objects.ComputeNodeList.get_all_by_host(
|
||||||
context, service.host)
|
context, service.host)
|
||||||
self._assert_no_in_progress_migrations(
|
self._assert_no_in_progress_migrations(
|
||||||
context, id, compute_nodes)
|
context, id, compute_nodes)
|
||||||
|
except exception.ComputeHostNotFound:
|
||||||
|
# NOTE(artom) Consider the following situation:
|
||||||
|
# - Using the Ironic virt driver
|
||||||
|
# - Replacing (so removing and re-adding) all baremetal
|
||||||
|
# nodes associated with a single nova-compute service
|
||||||
|
# The update resources periodic will have destroyed the
|
||||||
|
# compute node records because they're no longer being
|
||||||
|
# reported by the virt driver. If we then attempt to
|
||||||
|
# manually delete the compute service record,
|
||||||
|
# get_all_host() above will raise, as there are no longer
|
||||||
|
# any compute node records for the host. Catch it here and
|
||||||
|
# continue to allow compute service deletion.
|
||||||
|
pass
|
||||||
|
|
||||||
aggrs = self.aggregate_api.get_aggregates_by_host(context,
|
aggrs = self.aggregate_api.get_aggregates_by_host(context,
|
||||||
service.host)
|
service.host)
|
||||||
|
|
|
@ -712,11 +712,7 @@ class ServicesTestV21(test.TestCase):
|
||||||
'topic': 'compute',
|
'topic': 'compute',
|
||||||
'report_count': 0})
|
'report_count': 0})
|
||||||
compute.create()
|
compute.create()
|
||||||
# FIXME(artom) Until bug 1860312 is fixed, the ComputeHostNotFound
|
self.controller.delete(self.req, compute.id)
|
||||||
# error will get bubbled up to the API as an error 500.
|
|
||||||
self.assertRaises(
|
|
||||||
webob.exc.HTTPInternalServerError,
|
|
||||||
self.controller.delete, self.req, compute.id)
|
|
||||||
mock_get_all_by_host.assert_called_with(
|
mock_get_all_by_host.assert_called_with(
|
||||||
self.req.environ['nova.context'], 'fake-compute-host')
|
self.req.environ['nova.context'], 'fake-compute-host')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue