Define Workflow Failure Strategy

Updated 4 weeks ago by Archana Singh

A Failure Strategy defines how your Workflow handles different failure conditions.

In this topic:

Before You Begin

Step: Add Workflow Failure Strategy

To define the failure strategy for the entire Workflow, do the following:

  1. In a Workflow, click Failure Strategy. The default failure strategy appears.

    The default failure strategy is to fail the Workflow if there is any application error, and to rollback the Workflow execution. You can modify the default strategy or additional strategies.
  2. Click Add Failure Strategy. The Failure Strategy settings appear.

The dialog has the following fields:

Failure

Select the type of error:

Application Error

Harness encountered an application error during deployment.

Unsupported Types

The following types are listed but not supported at this time:

  • Connectivity Error: Harness is unable to connect to the target host/cluster/etc, or a provider, such as a Git repo.
  • Authentication Error: Harness is unable to authenticate using the credentials you supplied in the Cloud Provider, Artifact Source, Source Repo Provider, and other connectors.
  • Verification Error: If you have set up verification steps in your Workflow and a deployment event is flagged as an error by the step, Harness will fail the deployment.

Scope

Select the scope of the strategy. If you select Workflow, the Action is applied to the entire Workflow. If you select Workflow Phase, then the Action is applied to the Workflow Phase only.

For example, if you selected Workflow Phase and then selected the Action Rollback Phase Execution, and a failure occurred in the second Phase of the Workflow, then the second Phase of the Workflow would be rolled back but the first Phase of the Workflow would not be rolled back.

Action

Select the action for Harness to take in the event of a failure, such as a retry or a rollback:

Manual Intervention

(Applies to Workflow steps only)

You will be prompted to approve or reject the deployment on the Deployments page.

Manual Intervention is applicable for Workflow step-level failure strategies. If you have overridden the strategy at the Workflow step level by defining the strategy at the Phase level, then this is not applicable.

Rollback Workflow Execution

(Applies to Workflow Phase only)

Harness will initiate rollback.

This is not applicable for Workflow steps, presently. Harness does not propagate the failure strategy from Workflow steps to the parent Phases. The rollback strategy should be defined at Workflow Phase level using Rollback Phase Execution.

Rollback Phase Execution

Harness will initiate rollback of the Phase.

Ignore

Harness ignores any failure and continues with deployment. This setting can confuse some users because the deployment will likely fail.

Retry

(Applies to Workflow steps only)

Harness will retry the step where the failure occurred. This is also only applicable to Workflow steps.

End Execution

Harness will end the Workflow (fail the state) without rolling back.

Abort Workflow

Harness will abort the Workflow without rolling back.

Step: Step-level Custom Failure Strategy

To define the failure strategy for the step section of a Workflow, do the following:

  1. Next to the step section title, click the More Options ⋮ menu. The step-level settings appear.
  2. In Failure Strategy, click Custom. The Failure Strategy settings appear.
  3. Click Add Failure Strategy.
  4. Fill out the strategy. The dialog has the following fields:
  • Failure - Select the type of error, such as Verification, Application, etc.
  • Action - Select the action for Harness to take in the event of a failure, such as a retry or a rollback.
  • Specific Steps - Select any specific Workflow steps that you want to target for the Failure Strategy. The criteria for the strategy will be applied to those steps only.`

There is no Scope setting, like the Scope setting in the Workflow-level Failure Strategy, because the scope of this strategy is the step section.

  1. Click Submit. The failure strategy is added to the step section.

Review: Multiple Failure Strategies in a Workflow

When using multiple Failure Strategies in a Workflow, consider the following:

  • For failure strategies that do not overlap (different types of failures selected), they will behave as expected.
  • Two failures cannot occur at the same time, so whichever error occurs, that Failure Strategy will be used.

Conflicts

Conflicts might arise between failure strategies on the same level or different levels. By level, we mean the step-level or the Workflow level:

Same level

If there is a conflict between multiple failures in strategies on the same level, the first applicable strategy is used, and the remaining strategies are ignored.

For example, consider these two strategies:

  1. Abort Workflow on Verification Failure or Authentication Failure.
  2. Ignore on Verification Failure or Connectivity Error.

Here's what will happen:

  • On a verification failure, the Workflow is aborted.
  • On an authentication failure, the Workflow is aborted.
  • On a connectivity error, the error is ignored.
Different levels

If there is a clash of selected failures in strategies on different levels, the step-level strategy will be used and the Workflow level strategy will be ignored.


How did we do?