concourse / pool-resource

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

Add atomic update operation #34

Closed EleanorRigby closed 6 years ago

EleanorRigby commented 6 years ago

If the existing lock is in the unclaimed state we will update it with the contents of the metadata file. If no such lock is present in either the claimed or unclaimed state we add a new lock to the pool in the unclaimed state. If the lock is in the claimed state we will wait for it to be unclaimed and proceed to update it as above.

pivotal-issuemaster commented 6 years ago

@EleanorRigby Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

pivotal-issuemaster commented 6 years ago

@EleanorRigby Thank you for signing the Contributor License Agreement!

EleanorRigby commented 6 years ago

@tobocop : Can you review this?

jwntrs commented 6 years ago

@EleanorRigby This looks good. Just curious, whats your use case for wanting this?

EleanorRigby commented 6 years ago

@pivotal-jwinters : We wanted to update the metadata in lock file. There is no way to do that atomically. Update = [Remove-->Add] done atomically

jwntrs commented 6 years ago

@EleanorRigby I'm more curious about the flow of the lock file, and when/how the metadata needs to get updated in your use-case. We've seen cases where people move locks to different folders representing different states (e.g. clean vs dirty env), and I'm just wondering if your use case is similar.

EleanorRigby commented 6 years ago

@pivotal-jwinters : It has been a while since I worked on it but if I recall correctly, we had two jobs, one for initialization of an existing/non-existing environment with new repository changes. And other was to just recreate a non-existing environment (removed by a health check job). These two jobs were causing some inconsistent state in absence of an atomic update.

@ktchen14 : can you provide more info here?