Merge "Warn if we find compute services in cell0"

This commit is contained in:
Zuul 2023-10-14 00:40:32 +00:00 committed by Gerrit Code Review
commit 9dceb735f6
2 changed files with 25 additions and 0 deletions

View File

@ -6223,6 +6223,17 @@ class HostAPI:
services = []
service_dict = nova_context.scatter_gather_all_cells(context,
objects.ServiceList.get_all, disabled, set_zones=set_zones)
cell0_computes = [
x for x in
service_dict.get(objects.CellMapping.CELL0_UUID, [])
if x.binary == 'nova-compute']
for cn in cell0_computes:
LOG.warning(
'Found compute service %(service)s in cell0; '
'This should never happen!',
{'service': cn.host})
for cell_uuid, service in service_dict.items():
if not nova_context.is_cell_failure_sentinel(service):
services.extend(service)

View File

@ -194,6 +194,20 @@ class ComputeHostAPITestCase(test.TestCase):
self.assertEqual(['host-%s' % uuids.cell1],
[svc.host for svc in services])
@mock.patch('nova.context.scatter_gather_cells')
def test_service_get_all_cell0_computes(self, mock_sg):
service = objects.Service(binary='nova-compute', host='rogue')
mock_sg.return_value = {
objects.CellMapping.CELL0_UUID: [service],
}
with mock.patch.object(compute, 'LOG') as mock_log:
services = self.host_api.service_get_all(self.ctxt, all_cells=True)
mock_log.warning.assert_called_once_with(
'Found compute service %(service)s in cell0; '
'This should never happen!',
{'service': 'rogue'})
self.assertEqual([service], services)
@mock.patch('nova.objects.CellMappingList.get_all')
@mock.patch.object(objects.HostMappingList, 'get_by_cell_id')
@mock.patch('nova.context.scatter_gather_all_cells')