Skip to content
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

Renew lease #8719

Closed
marcovc opened this issue Oct 19, 2017 · 7 comments
Closed

Renew lease #8719

marcovc opened this issue Oct 19, 2017 · 7 comments

Comments

@marcovc
Copy link
Contributor

marcovc commented Oct 19, 2017

This is a question, not a bug.

I have the following workflow (in pseudo code):

while true
    lease = etcdctl lease grant ttl
    if test
        etcdctl put --lease=lease key value
    else
        etcdctl del key
    endif
    sleep ttl/2

The idea is to have a key in the etcd2 meaning that a periodic test succeeds. The ttl exists to ensure that if the program is interrupted the key is cleared.

My ttl is small (like 5 seconds), meaning that I'm creating a new lease every 5 seconds. This seems to be hurting the etcd2 cluster performance, so I'm guessing this is not the intended use of leases.

What I would like to do is more like:

lease = etcdctl lease grant ttl
while true
    if test
        etcdctl put --lease=lease key value
    else
        etcdctl del key
    endif
    sleep ttl/2
    etcdctl renew lease <--- this would reset the lease ttl to the original value

But I can't find a command for renewing the lease. Also, I'm aware of the keepalive command, but I don't know how to use that with a test.

Can anyone point me in the right direction please?

Thanks!
Marco

@xiang90
Copy link
Contributor

xiang90 commented Oct 24, 2017

keepalive is a blocking call. probably you want something like keepalive --once, which only sends one renew call?

@marcovc
Copy link
Contributor Author

marcovc commented Oct 24, 2017

Yes, that would work. It is not there yet, right?

@marcovc marcovc closed this as completed Oct 24, 2017
@marcovc marcovc reopened this Oct 24, 2017
@xiang90
Copy link
Contributor

xiang90 commented Oct 24, 2017

@marcovc no it is not. would like to help to add the feature?

@marcovc
Copy link
Contributor Author

marcovc commented Oct 24, 2017

Sure, I'll do it. Thanks

@marcovc
Copy link
Contributor Author

marcovc commented Oct 26, 2017

@xiang90, here is my attempt at this:

#8775

Never wrote go code before, so please look at it twice.

Thanks

@xiang90
Copy link
Contributor

xiang90 commented Oct 27, 2017

@marcovc thanks for the contribution. and go is really easy to get started :P

@marcovc
Copy link
Contributor Author

marcovc commented Oct 27, 2017

Thank you for all the work. This was a simple one 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants