Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lance6716 committed Feb 2, 2021
1 parent 41ec924 commit 387d9e1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/ha/keepalive.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func KeepAlive(ctx context.Context, cli *clientv3.Client, workerName string, kee
return nil
case newTTL := <-KeepAliveUpdateCh:
// create a new lease with new TTL, and overwrite original KV
oldLeaseID := leaseID
leaseID, err = grantAndPutKV(k, workerEventJSON, newTTL)
if err != nil {
keepAliveCancel() // make go vet happy
Expand All @@ -161,8 +162,13 @@ func KeepAlive(ctx context.Context, cli *clientv3.Client, workerName string, kee
return err
}
log.L().Info("dynamically changed keepalive TTL to", zap.Int64("ttl in seconds", newTTL))

// after new keepalive is succeed, we cancel the old keepalive
oldCancel()
_, err2 := revokeLease(cli, oldLeaseID)
if err2 != nil {
log.L().Warn("fail to revoke lease", zap.Error(err))
}
}
}
}
Expand Down

0 comments on commit 387d9e1

Please sign in to comment.