-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Create /path/key if-and-only-if /path exists but key does not #2857
Comments
More importantly, you might like the byte-keyspace (and atomic transactions!) of the v3 API which is underway. We're holding off on extending v2 -- but if there is a clear bug here (ie, the creation of the |
This introduces an extra GET (and potentially DELETE) into the task claim flow which is unfortunate. I don't see another way of guaranteeing a claim can't recreate a deleted task without the extra check though. Looks like we're going to have to wait for a new etcd in order to get a more efficient way of doing this: etcd-io/etcd#2857 Fixes #124
Oops, I didn't mean to repoen this with an unrelated ticket in a totally different project! Sorry! However: I don't see Create/PUT's recursive behavior documented anywhere, and other operations with recursive abilities (e.g. GET/DELETE) have the So I'd say this is a documentation "bug" and a missing feature. v3's atomic transactions is definitely a solution though, so feel free to re-close. |
Current behavior
As of etcd 2.0.11 the following creates
/path/key
iff/path/key
does not exist. However, it will create/path/key
regardless of whether or not/path
exists.Desired behavior
Have an option (
recursive=false
perhaps?) to cause PUTs to fail if the parent path component doesn't exist.Workaround
Depending on your use case the following may be a sufficient workaround:
/path
's CreatedIndex ==/path/key
's CreatedIndex, then: DELETE /path?recursive=trueObviously this method isn't an atomic operation, so it's not suitable for all cases the Desired Behavior above covers.
The text was updated successfully, but these errors were encountered: