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:
Winson Chan
2016-07-23 00:10:09 +00:00
parent 001598237c
commit 82ab51b0c1
14 changed files with 763 additions and 38 deletions

View File

@@ -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