concourse / pool-resource

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

Read lock name from file #43

Open dvianello opened 5 years ago

dvianello commented 5 years ago

Hello,

we have a use-case in which we'd like to (independently from this resource) scan the locks repository, pick a lock based on a condition and then provide the lock name to the resource from a file or is some other run-time way.

Is this supported by this resource?

Cheers, Dario

aegershman commented 5 years ago

I am not a maintainer or anything like that, but just out of curiosity, could you expand more on your use-case? If not, no big deal, I'm just intrigued.

dvianello commented 5 years ago

Hi @aegershman,

we have a requirement for removing environments after a certain TTL defined at deployment time.

At the moment, we're storing the expiry time in the lock, and we move an "expired" lock with an out-of-band process from claimed to unclaimed once their TTL is over. Another job picks at random a lock from the unclaimed folder every 15 minutes and destroys that environment. However, as you can imagine, especially when the number of locks increases, it might take hours to "randomly pick" the expired locks with environments still attached to them.

What we'd like to do is to scan the "unclaimed" folder for a particular flag that states if the corresponding environment has been removed or not, and then pass the lock to the destroy pipeline, which will lock the environment while it removes it. Right now we're forced to let entropy rule the game :-)

Cheers, Dario