diff --git a/tools/leaderelection/leasecandidate.go b/tools/leaderelection/leasecandidate.go index fa07066f0..c75fc3bdf 100644 --- a/tools/leaderelection/leasecandidate.go +++ b/tools/leaderelection/leasecandidate.go @@ -103,7 +103,7 @@ func NewCandidate(clientset kubernetes.Interface, h, err := leaseCandidateInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ UpdateFunc: func(oldObj, newObj interface{}) { if leasecandidate, ok := newObj.(*v1alpha1.LeaseCandidate); ok { - if leasecandidate.Spec.PingTime != nil { + if leasecandidate.Spec.PingTime != nil && leasecandidate.Spec.PingTime.After(leasecandidate.Spec.RenewTime.Time) { lc.enqueueLease() } } @@ -177,7 +177,6 @@ func (c *LeaseCandidate) ensureLease(ctx context.Context) error { klog.V(2).Infof("lease candidate exists. Renewing.") clone := lease.DeepCopy() clone.Spec.RenewTime = &metav1.MicroTime{Time: c.clock.Now()} - clone.Spec.PingTime = nil _, err = c.leaseClient.Update(ctx, clone, metav1.UpdateOptions{}) if err != nil { return err diff --git a/tools/leaderelection/leasecandidate_test.go b/tools/leaderelection/leasecandidate_test.go index 92dc199f0..c50059180 100644 --- a/tools/leaderelection/leasecandidate_test.go +++ b/tools/leaderelection/leasecandidate_test.go @@ -130,7 +130,6 @@ func pollForLease(ctx context.Context, tc testcase, client *fake.Clientset, t *m if lc.Spec.BinaryVersion == tc.binaryVersion && lc.Spec.EmulationVersion == tc.emulationVersion && lc.Spec.LeaseName == tc.leaseName && - lc.Spec.PingTime == nil && lc.Spec.RenewTime != nil { // Ensure that if a time is provided, the renewTime occurred after the provided time. if t != nil && t.After(lc.Spec.RenewTime.Time) {