concourse / pool-resource

atomically manages the state of the world (e.g. external environments)
Apache License 2.0
54 stars 36 forks source link

Add check operation #66

Closed adnankobir closed 1 year ago

adnankobir commented 1 year ago

This PR adds the functionality to check a given lock in a pool and block/wait until that lock becomes unclaimed. The rational behind it is as follows:

Given that we have multiple disparate pipelines that may trigger in any order:

The intent is to have the deploy pipelines always use the latest available output (Docker image), and if there is an active build taking place to produce said output (Docker image), then we want to wait/block until that output is ready/published.

Now we could simply use acquire across all the pipelines, but this feel clunky since we'd end up dealing with deploy pipelines acquiring the locks unnecessarily, when all we want to do is check for existence of a claimed lock by the build pipeline only. This is especially true in cases of many:1 dependency in pipelines - we want to avoid hundreds of pipelines trying to acquire a lock unnecessarily.

check details in docs:

Thanks in advance for the review!

cc @xtremerui

taylorsilva commented 1 year ago

Late but I'll take a look at this. Feels like a useful feature for this resource

taylorsilva commented 1 year ago

and of course the tests fail. I'm gonna approve this PR and make my own to fix the tests since that's a mess I made 😅