Skip to content

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

  1. 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
    
  2. 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.

  1. To cancel the workflow run, the orchestrator re-evaluates if conditions for all currently running jobs. If the condition evaluates to true, the job will not get canceled. For example, the condition if: always() would evaluate to true and the job continues to run. When there is no condition, that is the equivalent of the condition if: success(), which evaluates to false for a cancelled workflow.
  2. For jobs that continue to run, the orchestrator re-evaluates if conditions for the unfinished steps. If the condition evaluates to true, the step continues to run. You can use the cancelled() expression to apply a status check to the step. For more information, see “Expressions.”
  3. 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 the always() or cancelled() status check will be skipped.