diff --git a/ironic_inspector/process.py b/ironic_inspector/process.py index f34affb7b..4d5b2eb24 100644 --- a/ironic_inspector/process.py +++ b/ironic_inspector/process.py @@ -81,8 +81,11 @@ def process(introspection_data): LOG.exception(_LE('Hook %(hook)s failed, delaying error report ' 'until node look up: %(error)s'), {'hook': hook_ext.name, 'error': exc}) - failures.append(_('Unexpected exception during preprocessing ' - 'in hook %s') % hook_ext.name) + failures.append(_('Unexpected exception %(exc_class)s during ' + 'preprocessing in hook %(hook)s: %(error)s') % + {'hook': hook_ext.name, + 'exc_class': exc.__class__.__name__, + 'error': exc}) node_info = _find_node_info(introspection_data, failures) if node_info: @@ -96,7 +99,7 @@ def process(introspection_data): 'uuid': node_info.uuid, 'failures': '\n'.join(failures) } - node_info.finished(error=_('Data pre-processing failed')) + node_info.finished(error='\n'.join(failures)) raise utils.Error(msg) elif not node_info: msg = _('The following failures happened during running ' @@ -119,8 +122,10 @@ def process(introspection_data): node_info.finished(error=str(exc)) raise except Exception as exc: - msg = _('Unexpected exception during processing') - LOG.exception(msg) + LOG.exception(_LE('Unexpected exception during processing')) + msg = _('Unexpected exception %(exc_class)s during processing: ' + '%(error)s') % {'exc_class': exc.__class__.__name__, + 'error': exc} node_info.finished(error=msg) raise utils.Error(msg) diff --git a/ironic_inspector/test/test_process.py b/ironic_inspector/test/test_process.py index 06a96a28e..245a25547 100644 --- a/ironic_inspector/test/test_process.py +++ b/ironic_inspector/test/test_process.py @@ -144,7 +144,7 @@ class TestProcess(BaseTest): process.process, self.data) pop_mock.return_value.finished.assert_called_once_with( - error='Unexpected exception during processing') + error='Unexpected exception RuntimeError during processing: boom') @prepare_mocks def test_hook_unexpected_exceptions(self, cli, pop_mock, process_mock): @@ -158,7 +158,10 @@ class TestProcess(BaseTest): process.process, self.data) pop_mock.return_value.finished.assert_called_once_with( - error='Data pre-processing failed') + error=mock.ANY) + error_message = pop_mock.return_value.finished.call_args[1]['error'] + self.assertIn('RuntimeError', error_message) + self.assertIn('boom', error_message) @prepare_mocks def test_hook_unexpected_exceptions_no_node(self, cli, pop_mock, diff --git a/releasenotes/notes/preprocessing-error-01e55b4db20fb7fc.yaml b/releasenotes/notes/preprocessing-error-01e55b4db20fb7fc.yaml new file mode 100644 index 000000000..cdcbfb3b8 --- /dev/null +++ b/releasenotes/notes/preprocessing-error-01e55b4db20fb7fc.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Fixed confusing error message shown to user when something bad happens + during preprocessing (https://launchpad.net/bugs/1523907).