Remove NovaException logging from scatter_gather_cells
With change I861b223ee46b0f0a31f646a4b45f8a02410253cf the caller of the various scatter_gatter functions can get any exception result and decide what kind of logging is necessary, so this change removes the logging from the scatter_gather_cells method **for NovaExceptions**. This is needed because of change Iaea1cb4ed93bb98f451de4f993106d7891ca3682 where showing a server which is deleted, which results in an InstanceNotFound exception, gets logged as an exception in the nova-api logs and shouldn't be. Non-NovaExceptions will still get logged as before since those are likely due to unexpected errors, like DBErrors. Change-Id: I930ee897c46385c3c9719b393753c4484caf909f Closes-Bug: #1804325
This commit is contained in:
parent
47bcc39cd6
commit
939a61d1c6
|
@ -440,7 +440,9 @@ def scatter_gather_cells(context, cell_mappings, timeout, fn, *args, **kwargs):
|
|||
with target_cell(context, cell_mapping) as cctxt:
|
||||
result = fn(cctxt, *args, **kwargs)
|
||||
except Exception as e:
|
||||
LOG.exception('Error gathering result from cell %s', cell_uuid)
|
||||
# Only log the exception traceback for non-nova exceptions.
|
||||
if not isinstance(e, exception.NovaException):
|
||||
LOG.exception('Error gathering result from cell %s', cell_uuid)
|
||||
result = e.__class__(e.args)
|
||||
# The queue is already synchronized.
|
||||
queue.put((cell_uuid, result))
|
||||
|
|
|
@ -430,9 +430,23 @@ class ContextTestCase(test.NoDBTestCase):
|
|||
ctxt, mappings, 30, objects.InstanceList.get_by_filters)
|
||||
self.assertEqual(2, len(results))
|
||||
self.assertIn(mock.sentinel.instances, results.values())
|
||||
isinstance(results.values(), Exception)
|
||||
self.assertIsInstance(results[mapping1.uuid], Exception)
|
||||
# non-NovaException gets logged
|
||||
self.assertTrue(mock_log_exception.called)
|
||||
|
||||
# Now run it again with a NovaException to see it's not logged.
|
||||
mock_log_exception.reset_mock()
|
||||
mock_get_inst.side_effect = [mock.sentinel.instances,
|
||||
exception.NotFound()]
|
||||
|
||||
results = context.scatter_gather_cells(
|
||||
ctxt, mappings, 30, objects.InstanceList.get_by_filters)
|
||||
self.assertEqual(2, len(results))
|
||||
self.assertIn(mock.sentinel.instances, results.values())
|
||||
self.assertIsInstance(results[mapping1.uuid], exception.NovaException)
|
||||
# NovaExceptions are not logged, the caller should handle them.
|
||||
mock_log_exception.assert_not_called()
|
||||
|
||||
@mock.patch('nova.context.scatter_gather_cells')
|
||||
@mock.patch('nova.objects.CellMappingList.get_all')
|
||||
def test_scatter_gather_all_cells(self, mock_get_all, mock_scatter):
|
||||
|
|
Loading…
Reference in New Issue