Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GCS lock builder #520

Open
jsok opened this issue Aug 3, 2021 · 0 comments
Open

Add a GCS lock builder #520

jsok opened this issue Aug 3, 2021 · 0 comments

Comments

@jsok
Copy link

jsok commented Aug 3, 2021

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

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']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant