Beispiel #1
0
    def fail_workflow_execution(self, message, exception):
        # Prepare attributes based on message type.
        if isinstance(message, wf_db_models.WorkflowExecutionDB):
            msg_type = 'workflow'
            wf_ex_db = message
            wf_ex_id = str(wf_ex_db.id)
            task = None
        else:
            msg_type = 'task'
            ac_ex_db = message
            wf_ex_id = ac_ex_db.context['orquesta']['workflow_execution_id']
            task_ex_id = ac_ex_db.context['orquesta']['task_execution_id']
            wf_ex_db = wf_db_access.WorkflowExecution.get_by_id(wf_ex_id)
            task_ex_db = wf_db_access.TaskExecution.get_by_id(task_ex_id)
            task = {'id': task_ex_db.task_id, 'route': task_ex_db.task_route}

        # Log the error.
        LOG.error('[%s] Unknown error while processing %s execution. %s: %s',
                  wf_ex_db.action_execution, msg_type,
                  exception.__class__.__name__, str(exception))

        # Fail the task execution so it's marked correctly in the
        # conductor state to allow for task rerun if needed.
        if isinstance(message, ex_db_models.ActionExecutionDB):
            msg = '[%s] Unknown error while processing %s execution. Failing task execution "%s".'
            LOG.error(msg, wf_ex_db.action_execution, msg_type, task_ex_id)
            wf_svc.update_task_execution(task_ex_id,
                                         ac_const.LIVEACTION_STATUS_FAILED)
            wf_svc.update_task_state(task_ex_id,
                                     ac_const.LIVEACTION_STATUS_FAILED)

        # Fail the workflow execution.
        msg = '[%s] Unknown error while processing %s execution. Failing workflow execution "%s".'
        LOG.error(msg, wf_ex_db.action_execution, msg_type, wf_ex_id)
        wf_svc.fail_workflow_execution(wf_ex_id, exception, task=task)
Beispiel #2
0
    def fail_workflow_execution(self, message, exception):
        # Prepare attributes based on message type.
        if isinstance(message, wf_db_models.WorkflowExecutionDB):
            msg_type = "workflow"
            wf_ex_db = message
            wf_ex_id = str(wf_ex_db.id)
            task = None
        else:
            msg_type = "task"
            ac_ex_db = message
            wf_ex_id = ac_ex_db.context["orquesta"]["workflow_execution_id"]
            task_ex_id = ac_ex_db.context["orquesta"]["task_execution_id"]
            wf_ex_db = wf_db_access.WorkflowExecution.get_by_id(wf_ex_id)
            task_ex_db = wf_db_access.TaskExecution.get_by_id(task_ex_id)
            task = {"id": task_ex_db.task_id, "route": task_ex_db.task_route}

        # Log the error.
        msg = "Unknown error while processing %s execution. %s: %s"
        wf_svc.update_progress(
            wf_ex_db,
            msg % (msg_type, exception.__class__.__name__, str(exception)),
            severity="error",
        )

        # Fail the task execution so it's marked correctly in the
        # conductor state to allow for task rerun if needed.
        if isinstance(message, ex_db_models.ActionExecutionDB):
            msg = 'Unknown error while processing %s execution. Failing task execution "%s".'
            wf_svc.update_progress(
                wf_ex_db, msg % (msg_type, task_ex_id), severity="error"
            )
            wf_svc.update_task_execution(task_ex_id, ac_const.LIVEACTION_STATUS_FAILED)
            wf_svc.update_task_state(task_ex_id, ac_const.LIVEACTION_STATUS_FAILED)

        # Fail the workflow execution.
        msg = 'Unknown error while processing %s execution. Failing workflow execution "%s".'
        wf_svc.update_progress(wf_ex_db, msg % (msg_type, wf_ex_id), severity="error")
        wf_svc.fail_workflow_execution(wf_ex_id, exception, task=task)