Canceling a workflow¶
You can cancel a workflow run that is in progress. When you cancel a workflow run, the orchestrator cancels all jobs and steps that are part of that workflow.
Canceling a workflow run¶
-
Using the OpenTestFactory CLI, list the running workflow runs:
opentf-ctl get workflows
WORKFLOW_ID STATUS NAME <workflow_id_1> RUNNING Test Orchestrator with No Initial Environments <workflow_id_2> DONE Workflow end-to-end
-
Cancel the workflow run:
opentf-ctl kill workflow <workflow_id_1>
Killing workflow <workflow_id_1>.
Steps the orchestrator takes to cancel a workflow run¶
When canceling a workflow run, you may be running other software that uses resources that are related to the workflow run. To help you free up resources related to the workflow run, it may help to understand the steps the orchestrator performs to cancel a workflow run.
- To cancel the workflow run, the orchestrator re-evaluates
if
conditions for all currently running jobs. If the condition evaluates totrue
, the job will not get canceled. For example, the conditionif: always()
would evaluate to true and the job continues to run. When there is no condition, that is the equivalent of the conditionif: success()
, which evaluates to false for a cancelled workflow. - For jobs that continue to run, the orchestrator re-evaluates
if
conditions for the unfinished steps. If the condition evaluates totrue
, the step continues to run. You can use thecancelled()
expression to apply a status check to the step. For more information, see “Expressions.” - For jobs that need to be cancelled, the orchestrator waits for the completion of the currently
running step. It then marks the job as cancelled and re-evaluates
if
conditions for the unfinished steps. Steps that do not use thealways()
orcancelled()
status check will be skipped.