diff options
author | Balazs Gibizer <balazs.gibizer@est.tech> | 2020-11-10 17:26:23 +0100 |
---|---|---|
committer | Balazs Gibizer <balazs.gibizer@est.tech> | 2020-11-10 17:39:50 +0100 |
commit | 3b44275868e08992a36e9163f533d689f27a0119 (patch) | |
tree | 18acc5f639ec1a931a4d10aef6cb65db5134a2c5 /nova/tests/unit/test_utils.py | |
parent | dc93e3b510f53d5b2198c8edd22528f0c899617e (diff) | |
download | nova-3b44275868e08992a36e9163f533d689f27a0119.tar.gz |
Improve error handling during service level check
The service level check introduced in
Ie15ec8299ae52ae8f5334d591ed3944e9585cf71 should handle the case when a
compute service is wrongly configured with DB credentials. The previous
patch did not handle this and it caused a misleading error at compute
service startup. This patch makes sure that a user friendly warning is
logged in this case then the service level check is done ignoring the DB
configuration and only checking the local cell.
A subsequent patch will add a separate check that fails the compute
service startup in such invalid configuration.
Change-Id: I89cdf3852266ed93a2ac7cd6261fe269932026ac
Related-Bug: #1871482
Diffstat (limited to 'nova/tests/unit/test_utils.py')
-rw-r--r-- | nova/tests/unit/test_utils.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nova/tests/unit/test_utils.py b/nova/tests/unit/test_utils.py index 226f6afc91..5b8df06dae 100644 --- a/nova/tests/unit/test_utils.py +++ b/nova/tests/unit/test_utils.py @@ -1267,3 +1267,30 @@ class TestOldComputeCheck(test.NoDBTestCase): self.assertIn('system', str(ex)) mock_get_min_service.assert_called_once_with( mock.ANY, ['nova-compute']) + + @mock.patch.object(utils.LOG, 'warning') + @mock.patch('nova.objects.service.Service.get_minimum_version') + @mock.patch('nova.objects.service.get_minimum_version_all_cells') + def test_api_db_is_configured_but_the_service_cannot_access_db( + self, mock_get_all, mock_get, mock_warn): + # This is the case when the nova-compute service is wrongly configured + # with db credentials but nova-compute is never allowed to access the + # db directly. + mock_get_all.side_effect = exception.DBNotAllowed( + binary='nova-compute') + + oldest = service_obj.SERVICE_VERSION_ALIASES[ + service_obj.OLDEST_SUPPORTED_SERVICE_VERSION] + mock_get.return_value = oldest - 1 + + ex = self.assertRaises( + exception.TooOldComputeService, utils.raise_if_old_compute) + + self.assertIn('cell', str(ex)) + mock_get_all.assert_called_once_with(mock.ANY, ['nova-compute']) + mock_get.assert_called_once_with(mock.ANY, 'nova-compute') + mock_warn.assert_called_once_with( + 'This service is configured for access to the API database but is ' + 'not allowed to directly access the database. You should run this ' + 'service without the [api_database]/connection config option. The ' + 'service version check will only query the local cell.') |