-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Unable to set a TTL on a key #1097
Comments
@omribahumi by design Consul uses sessions to apply TTL's to keys in the K/V store. By creating a session, you get back a session ID, which you can pass in as the I realize its not as simple as "create a key with this TTL", but by tying key TTL's to sessions, we get some added benefits, like having multiple keys under the same session handle, and ephemeral keys. Consul doesn't impose a cap on session lifetime. The 10-3600s is just the time range in which a session renewal must happen to keep the session alive. Basically a client must renew its session within the window if it wants to extend the session expiration. You can renew with the session renew endpoint. Does that help? |
@ryanuber I see. I missed the release/delete part. What about having higher TTL values, for those cases you just want to "create a key with a TTL". Again, the use-case here is https://github.com/coreos/flannel/blob/master/subnet/registry.go#L95 |
You have 2 options there (I'm assuming you're using the Go API - it's pretty much directly translatable to HTTP if you're doing that):
Also, session->key association has nothing to do with writing data to the key, technically. You can write to a key from any node no matter what session is associated with it with |
@highlyunavailable thanks! I think this should be pointed out in the documentation. As for the options you suggested, 1 is problematic because, theoretically, the address pool might be re-assigned to another node during the time it's deleted. Why was the 1h value chosen? |
You might be able to resurrect the session by ID as long as it's on the same node. I'm not sure what the Consul authors think of that, but I know that you can send an arbitrary session ID to the renew endpoint, so as long as you recover the session ID somehow (e.g. call |
No need for that. When a node tries to write to a key for the first time, it would pass There's still a problem with the short TTL |
Closing this one. Opening a longer TTL case instead. |
Reopened as #1104 |
Unless #6828 is fixed there is still a need for being able to set a TTL on a key independent of sessions, since due to that regression it's currently impossible to do this cross-DC. |
setting TTL on the key without a session needed will be more and more convenient, maybe a little more work with the hashcorp consul developers, but less ugly noodle code we will have |
We've started working on flannel-io/flannel#233 (tl;dr - flannel uses etcd, we're adding a consul backend) and we've hit a dead-end.
According to #172, TTL should be supported with Sessions. However, the only reference to session Id we found in the KV PUT API was in
acquire
andrelease
. We just want a simple Key TTL.The line we're trying to port is:
https://github.com/coreos/flannel/blob/master/subnet/registry.go#L95
Also, flannel uses 24h TTLs, but it seems Consul session TTL is 10-3600 seconds.
The text was updated successfully, but these errors were encountered: