etcd3 icon indicating copy to clipboard operation
etcd3 copied to clipboard

Obtain the lease id of a key, either via lease.put() or via separate api

Open pdykes opened this issue 4 years ago • 2 comments

Thanks for much for your work.

One of our challenges debugging lease issues is not being able to correlate the created key via the lease put command.

a) For logging purposes, be useful to print out the lease id (visible later via etcdctl) of the lease used to create the item with the put command. b) It would be useful if the lease creation provide the id of the lease that etcdctl sees, or had an api to get the key of a lease the key is associated with after the fact. c) Lastly, it would be useful if etcdctl get command extracted the lease id with etcdctl if this could be passed on.

Thanks

pdykes avatar Jun 06 '21 20:06 pdykes

For (a) and (b), you can use the lease.grant() method on the lease. This'll return the Id of the lease once the grant goes through.

I'm not clear what you're looking for in (c), can you explain a bit more?

connor4312 avatar Jun 07 '21 16:06 connor4312

Hi, sorry, was out on vacation. For c):

Be great if etcdctl is used with the get operator, and the variable is based against a lease, the following extra values other than the value be really nice (getting variables tied to leases is painful command sequence, especially for many of them):

Normal get:

etcdctl get /space/cache_testing/values/foo

/space/cache_testing/values/foo 99

(items in > are what etcdctl would return)

With extra function to show lease data, if variable created under lease:

etcdctl get /space/cache_testing/values/foo

/space/cache_testing/values/foo 99 lease: 3d524a18b6d14a5c time to live: 250

Does that help?

Thanks!

pdykes avatar Jun 30 '21 16:06 pdykes