mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-12 13:25:29 +00:00
set the timeout to Get method
Kubernetes-commit: 300c7b815a2eb9598c53c0b386715650f5052804
This commit is contained in:
committed by
Kubernetes Publisher
parent
be4c8bc002
commit
e36950929b
@@ -307,9 +307,10 @@ func (le *LeaderElector) renew(ctx context.Context) {
|
||||
// release attempts to release the leader lease if we have acquired it.
|
||||
func (le *LeaderElector) release() bool {
|
||||
ctx := context.Background()
|
||||
|
||||
timeoutCtx, timeoutCancel := context.WithTimeout(ctx, le.config.RenewDeadline)
|
||||
defer timeoutCancel()
|
||||
// update the resourceVersion of lease
|
||||
oldLeaderElectionRecord, _, err := le.config.Lock.Get(ctx)
|
||||
oldLeaderElectionRecord, _, err := le.config.Lock.Get(timeoutCtx)
|
||||
if err != nil {
|
||||
if !errors.IsNotFound(err) {
|
||||
klog.Errorf("error retrieving resource lock %v: %v", le.config.Lock.Describe(), err)
|
||||
@@ -329,9 +330,6 @@ func (le *LeaderElector) release() bool {
|
||||
RenewTime: now,
|
||||
AcquireTime: now,
|
||||
}
|
||||
|
||||
timeoutCtx, timeoutCancel := context.WithTimeout(ctx, le.config.RenewDeadline)
|
||||
defer timeoutCancel()
|
||||
if err := le.config.Lock.Update(timeoutCtx, leaderElectionRecord); err != nil {
|
||||
klog.Errorf("Failed to release lock: %v", err)
|
||||
return false
|
||||
|
Reference in New Issue
Block a user