summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtom Lifshitz <alifshit@redhat.com>2021-07-28 12:48:50 +0200
committerArtom Lifshitz <alifshit@redhat.com>2021-07-29 10:47:26 +0200
commit9efdd0b085733a0a4c4192aab8fc870c8aadf316 (patch)
tree1d1e3941f4f91f2d8d09aefd41f43026b247406b
parentb2fd01f0b4871dd0182daf234e0531a59e910621 (diff)
downloadnova-9efdd0b085733a0a4c4192aab8fc870c8aadf316.tar.gz
Reproducer unit test for bug 1860312
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, the datbase layer will raise an exception, as there are no longer any compute node records for the host. This exception gets bubbled up as an error 500 in the API. This patch adds a unit test to demonstrate this. Related bug: 1860312 Change-Id: I03eec634b25582ec9643cacf3e5868c101176983 (cherry picked from commit 32257a2a6d159406577c885a9d7e366cbf0c72b9) (cherry picked from commit e6cd23c3b4928b421b8c706f9cc218020779e367)
-rw-r--r--nova/tests/unit/api/openstack/compute/test_services.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/nova/tests/unit/api/openstack/compute/test_services.py b/nova/tests/unit/api/openstack/compute/test_services.py
index 170b39f208..07acbaab16 100644
--- a/nova/tests/unit/api/openstack/compute/test_services.py
+++ b/nova/tests/unit/api/openstack/compute/test_services.py
@@ -701,6 +701,25 @@ class ServicesTestV21(test.TestCase):
mock_get_compute_nodes.assert_called_once_with(
self.req.environ['nova.context'], compute.host)
+ @mock.patch(
+ 'nova.objects.ComputeNodeList.get_all_by_host',
+ side_effect=exception.ComputeHostNotFound(host='fake-compute-host'))
+ def test_services_delete_compute_host_not_found(
+ self, mock_get_all_by_host):
+ compute = objects.Service(self.ctxt,
+ **{'host': 'fake-compute-host',
+ 'binary': 'nova-compute',
+ 'topic': 'compute',
+ 'report_count': 0})
+ compute.create()
+ # FIXME(artom) Until bug 1860312 is fixed, the ComputeHostNotFound
+ # 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(
+ self.req.environ['nova.context'], 'fake-compute-host')
+
def test_services_delete_not_found(self):
self.assertRaises(webob.exc.HTTPNotFound,