GoogleCloudPlatform / GoogleCloudPlatform/cloud-builders-community
Add a GCS lock builder
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 848
- PR merge metrics
- No merged PRs in 30d
Description
## Additional Info
A common problem people encounter when using Cloud Build is the lack of concurrency control between builds. Coordinating builds to ensure they have exclusive access to resources (git tags, deployments, etc.) is a hard problem to solve in general.
One approach is to provide some locking mechanism so that builds can acquire and release a lock before entering a critical section and releasing once completed.
GCS's consistency along with particular request headers can be used to implement a lock.
A popular (bit simplistic) implementation is: https://github.com/mco-gh/gcslock
A more thorough analysis on the topic can be found at: https://www.joyfulbikeshedding.com/blog/2021-05-19-robust-distributed-locking-algorithm-based-on-google-cloud-storage.html
## Example
```yaml
steps:
- name: gcr.io/cloud-builders-community/gcs-lock-acquire
args: ['gs://bucket/lock']
- id: deployment-step
name: ...
args: ['my', 'deployment', 'arguments']
- name: gcr.io/cloud-builders-community/gcs-lock-release
args: ['gs://bucket/lock']
```
Contributor guide
Assessment
This issue has not been assessed yet.