From f1071f5908c1f67a11d8ec0ef70e4b5e010b6395 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Thu, 10 Nov 2016 16:17:09 +0700 Subject: [PATCH] Fix error message format in action handler Change-Id: I562429934b6f53eb5bc84adba38b7446b9b58c51 --- mistral/engine/action_handler.py | 6 ++- .../tests/unit/engine/test_error_handling.py | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/mistral/engine/action_handler.py b/mistral/engine/action_handler.py index 4d1c83df..5eb037c5 100644 --- a/mistral/engine/action_handler.py +++ b/mistral/engine/action_handler.py @@ -36,8 +36,10 @@ def on_action_complete(action_ex, result): try: action.complete(result) except exc.MistralException as e: - msg = ("Failed to complete action [action=%s, task=%s]: %s\n%s" % - (action_ex.name, task_ex.name, e, tb.format_exc())) + msg = ( + "Failed to complete action [error=%s, action=%s, task=%s]:\n%s" + % (e, action_ex.name, task_ex.name, tb.format_exc()) + ) LOG.error(msg) diff --git a/mistral/tests/unit/engine/test_error_handling.py b/mistral/tests/unit/engine/test_error_handling.py index 3a93c47b..adba6fda 100644 --- a/mistral/tests/unit/engine/test_error_handling.py +++ b/mistral/tests/unit/engine/test_error_handling.py @@ -16,6 +16,7 @@ from oslo_config import cfg from mistral.db.v2 import api as db_api from mistral import exceptions as exc +from mistral.services import workbooks as wb_service from mistral.services import workflows as wf_service from mistral.tests.unit.engine import base from mistral.workflow import states @@ -538,3 +539,42 @@ class ErrorHandlingEngineTest(base.EngineTestCase): self.assertIsNotNone(state_info) self.assertTrue(state_info.find('error=') > 0) self.assertTrue(state_info.find('error=') < state_info.find('wf=')) + + def test_error_message_format_on_adhoc_action_error(self): + wb_text = """ + version: '2.0' + + name: wb + + actions: + my_action: + input: + - output + output: <% invalid_yaql_function() %> + base: std.echo + base-input: + output: <% $.output %> + + workflows: + wf: + tasks: + task1: + action: my_action output="test" + """ + + wb_service.create_workbook_v2(wb_text) + + wf_ex = self.engine.start_workflow('wb.wf', {}) + + self.await_workflow_error(wf_ex.id) + + with db_api.transaction(): + wf_ex = db_api.get_workflow_execution(wf_ex.id) + + task_ex = wf_ex.task_executions[0] + + state_info = task_ex.state_info + + self.assertIsNotNone(state_info) + self.assertTrue(state_info.find('error=') > 0) + self.assertTrue(state_info.find('error=') < state_info.find('action='))