Call cancel when we try to renew the lease after an error.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
Antonio Navarro Perez 2021-03-23 14:20:14 +01:00
parent b6810f3ce7
commit 6e6eb962ee

View file

@ -66,6 +66,11 @@ func (l *leasedKV) Start(initValue string) error {
func (l *leasedKV) create(initValue string) (<-chan *clientv3.LeaseKeepAliveResponse, error) {
ctx, cancel := context.WithCancel(context.Background())
if l.cancel != nil {
l.cancel()
}
l.cancel = cancel
leaseResp, err := l.cli.Grant(ctx, l.ttlSeconds)