Synchronize Deployments using Barriers

Updated 2 months ago by Michael Cretzman

Barriers allow you to synchronize different stages in your Pipeline, and control the flow of your deployment systematically.

In this topic:

Before You Begin

Review: Barriers and Synchronization

When deploying interdependent services, such as microservices or a large and complicated application, there might be a need to coordinate the timing of the different components' deployments. A common example is the need to verify a group of services only after all the services are deployed successfully.

Harness address this scenario using barriers. Barriers allow you to synchronize different stages in your Pipeline, and control the flow of your deployment systematically.

Barriers have an effect only when two or more stages use the same barrier name (Barrier Reference setting), and are executed in parallel in a Pipeline. When executed in parallel, both stages will cross the barrier at the same time.

If a stage fails before reaching its barrier point, the stage signals the other stages that have the same barrier, and the other stage will react as if they failed as well. At that point, each stage will act according to its Define a Failure Strategy on Stages and Steps.

Step 1: Add Barrier

A barrier is simply a name added in a Pipeline's Flow Control settings.

In your Pipeline, click Flow Control.

In Flow Control, click Add Barrier.

In Barrier Name, enter a unique name, and then click outside of the settings. The barrier is created.

Next, the name is selected using the Barrier step in the stages where you want to synchronize.

Step 2: Configure Barrier

To apply a barrier, do the following:

In your stage, in Execution, click Add Step, and then click Barrier.

Enter a name for the step.

In Timeout, enter the timeout period, in milliseconds. For example, 600000 milliseconds is 10 minutes. The timeout period determines how long each stage with a barrier must wait for the other stage to reach their barrier point. When the timeouts expire, it is considered a deployment failure.

Barrier timeouts are not hard timeouts. A barrier can fail anytime between timeout + 1min.

In Barrier Reference, select the name of an existing barrier.

Click Apply Changes.

You cannot use a Harness variable expression in Barrier Reference.

Now you can add another Barrier step using the same name to another stage at the point where you want to synchronize execution.

Notes

  • You can have multiple barriers in a stage. Every barrier in the same stage must use a unique Barrier Reference.
  • Ensure the Barrier Reference string for each related barrier across the different stages matches.


Please Provide Feedback