Properly report preprocessing errors to a user
Currently we only return "Data pre-processing failed" and the only option to figure out what went wrong is to dive into logs. Also fixed error message for unexpected exceptions during pre-processing to actually contain some exception information. Change-Id: I998c0bbd48cc57b7b13fac220f4f7cfe2a5e0681 Closes-Bug: #1523907
This commit is contained in:
parent
f7d7d76a4c
commit
22fddca500
@ -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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- Fixed confusing error message shown to user when something bad happens
|
||||
during preprocessing (https://launchpad.net/bugs/1523907).
|
Loading…
Reference in New Issue
Block a user