Merge "Warn if we find compute services in cell0"
This commit is contained in:
commit
9dceb735f6
|
@ -6223,6 +6223,17 @@ class HostAPI:
|
||||||
services = []
|
services = []
|
||||||
service_dict = nova_context.scatter_gather_all_cells(context,
|
service_dict = nova_context.scatter_gather_all_cells(context,
|
||||||
objects.ServiceList.get_all, disabled, set_zones=set_zones)
|
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():
|
for cell_uuid, service in service_dict.items():
|
||||||
if not nova_context.is_cell_failure_sentinel(service):
|
if not nova_context.is_cell_failure_sentinel(service):
|
||||||
services.extend(service)
|
services.extend(service)
|
||||||
|
|
|
@ -194,6 +194,20 @@ class ComputeHostAPITestCase(test.TestCase):
|
||||||
self.assertEqual(['host-%s' % uuids.cell1],
|
self.assertEqual(['host-%s' % uuids.cell1],
|
||||||
[svc.host for svc in services])
|
[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('nova.objects.CellMappingList.get_all')
|
||||||
@mock.patch.object(objects.HostMappingList, 'get_by_cell_id')
|
@mock.patch.object(objects.HostMappingList, 'get_by_cell_id')
|
||||||
@mock.patch('nova.context.scatter_gather_all_cells')
|
@mock.patch('nova.context.scatter_gather_all_cells')
|
||||||
|
|
Loading…
Reference in New Issue