0
votes

We have dozen of multistage YAML pipelines responsible for deploying microservices. Each of them has a stage A which targets EnvA environment with an Exclusive Lock enabled.

The Exclusive lock guarantees us two things:

  1. the latest run only from each of the pipeline can be executed (batch behavior)
  2. only one run across all of the pipelines can use the EnvA environment at the same time, other are waiting when the environment will be free

The environment has also an Azure Function check which verifies the time of the day and allows or forbids deployment. It means that for example, the Azure Function allows deployment between 8.00 - 10.00 and 14:00 - 16:00.

The only documentation about this feature is The exclusive lock check allows only a single run from the pipeline to proceed. All stages in all runs of that pipeline which use the resource are paused. When the stage using the lock completes, then another stage can proceed to use the resource. Also, only one stage will be allowed to continue. Any other stages which tried to take the lock will be cancelled. Exclusive lock

There is not any information on how the timeout works for the Exclusive lock:

Is it the max time the stage could occupy the EnvA environment and for example if the timeout is set for 10 minutes but the stage's job takes 20mins then after 10 minutes the lock is released and the next pipeline can use this environment even the previous one is still in progress?

When the timeout starts, when a particular pipeline's stage locked the environment? Or when the pipeline stage starts and is waiting in a queue for pipeline A, B, C, D to release the EnvA environment?

What are the states of the Exclusive lock, acquired, obtained? How to track the queue of the pipelines which waits for other pipelines to release the lock?

1

1 Answers

0
votes

Is it the max time the stage could occupy the EnvA environment and for example if the timeout is set for 10 minutes but the stage's job takes 20mins then after 10 minutes the lock is released and the next pipeline can use this environment even the previous one is still in progress?

If you configure the Exclusive lock and set the timeout value to 10 minutes, it will not release the lock after 10 minutes, It will cause the next pipeline to fail after 10 minutes.

For example, we set the timeout value to 10 minutes, add the env to pipeline A and pipeline B, run the pipeline A which contain the power shell script Start-Sleep -Seconds 1000, then run pipeline B.

Result:

The pipeline B will fail after 10 minutes.

enter image description here

In addition, if we set the timeout value to 10 days. The pipeline B will continue check. When the pipeline A using the lock complete, the pipeline B will continue to run.

enter image description here