Add cancelled state to executions
Allow workflow executions to be cancelled and propagate state up for subworkflows and with-items task. Cancelled workflow executions are subject to expiration. Change-Id: I74925105420e84c0b164f83b76edaa9b1612b5d5 Implements: blueprint mistral-cancel-state
This commit is contained in:
@@ -50,11 +50,26 @@ def stop_workflow(wf_ex, state, msg=None):
|
||||
# with ERROR state.
|
||||
wf.stop(state, msg)
|
||||
|
||||
# Cancels subworkflows.
|
||||
if state == states.CANCELLED:
|
||||
for task_ex in wf_ex.task_executions:
|
||||
sub_wf_exs = db_api.get_workflow_executions(
|
||||
task_execution_id=task_ex.id
|
||||
)
|
||||
|
||||
for sub_wf_ex in sub_wf_exs:
|
||||
if not states.is_completed(sub_wf_ex.state):
|
||||
stop_workflow(sub_wf_ex, state, msg=msg)
|
||||
|
||||
|
||||
def fail_workflow(wf_ex, msg=None):
|
||||
stop_workflow(wf_ex, states.ERROR, msg)
|
||||
|
||||
|
||||
def cancel_workflow(wf_ex, msg=None):
|
||||
stop_workflow(wf_ex, states.CANCELLED, msg)
|
||||
|
||||
|
||||
@profiler.trace('workflow-handler-on-task-complete')
|
||||
def on_task_complete(task_ex):
|
||||
wf_ex = task_ex.workflow_execution
|
||||
|
||||
Reference in New Issue
Block a user