Change the action error message format

* Some users rely on the presence of the root error related to
  running an action and it's not convenient that it is now in
  the end of the string, e.g. if we look at the corresponding
  task execution "state_info" field. This patch includes the cause
  error message in the beginning of the resulting error string
  returned by the action executor so that it's clearly visible.
  This message can be also truncated in some cases (depending on
  the config option) so we need to make sure we keep the cause
  error message.

Closes-Bug: #1847984
Change-Id: Ieb10c10401380410665c418f4688681e929b1e23
This commit is contained in:
Renat Akhmerov 2019-10-11 19:03:07 +07:00
parent ce4dad8a18
commit 5d387db6c2
3 changed files with 49 additions and 4 deletions

View File

@ -123,13 +123,13 @@ class DefaultExecutor(base.Executor):
except BaseException as e:
msg = (
"The action raised an exception [action_ex_id=%s, "
"action_cls='%s', attributes='%s', params='%s']\n %s" % (
"The action raised an exception [action_ex_id=%s, msg='%s', "
"action_cls='%s', attributes='%s', params='%s']" % (
action_ex_id,
e,
action_cls,
action_cls_attrs,
params,
e
params
)
)

View File

@ -821,3 +821,35 @@ class ErrorHandlingEngineTest(base.EngineTestCase):
task_ex = wf_ex.task_executions[0]
self.assertDictEqual({'my_var': 2}, task_ex.published)
def test_action_error_message_format(self):
wf_text = """---
version: '2.0'
wf:
tasks:
task1:
action: std.fail
"""
wf_service.create_workflows(wf_text)
wf_ex = self.engine.start_workflow('wf')
self.await_workflow_error(wf_ex.id)
with db_api.transaction():
wf_ex = db_api.get_workflow_execution(wf_ex.id)
self.assertEqual(1, len(wf_ex.task_executions))
task_ex = wf_ex.task_executions[0]
expected = (
"The action raised an exception [action_ex_id=%s, "
"msg='Fail action expected exception.'"
) % task_ex.action_executions[0].id
# Making sure that the actual error message goes before
# other debugging information.
self.assertTrue(task_ex.state_info.startswith(expected))

View File

@ -0,0 +1,13 @@
---
fixes:
- |
Some users rely on the presence of the root error related to
running an action and it's not convenient that it is now in
the end of the string, e.g. if we look at the corresponding
task execution "state_info" field. Now a cause error message
is included in the beginning of the resulting error string
returned by the action executor so that it's clearly visible.
This message can be also truncated in some cases (depending on
the config option) so we need to make sure we keep the cause
error message.