Skip to content

Commit 825f52e

Browse files
Jefftreek8s-publishing-bot
authored andcommitted
Change PingTime to be persistent
Kubernetes-commit: 0c774d0b1f79b0b0a6d73102a78c84853220f036
1 parent f45c451 commit 825f52e

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

tools/leaderelection/leasecandidate.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func NewCandidate(clientset kubernetes.Interface,
103103
h, err := leaseCandidateInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
104104
UpdateFunc: func(oldObj, newObj interface{}) {
105105
if leasecandidate, ok := newObj.(*v1alpha1.LeaseCandidate); ok {
106-
if leasecandidate.Spec.PingTime != nil {
106+
if leasecandidate.Spec.PingTime != nil && leasecandidate.Spec.PingTime.After(leasecandidate.Spec.RenewTime.Time) {
107107
lc.enqueueLease()
108108
}
109109
}
@@ -177,7 +177,6 @@ func (c *LeaseCandidate) ensureLease(ctx context.Context) error {
177177
klog.V(2).Infof("lease candidate exists. Renewing.")
178178
clone := lease.DeepCopy()
179179
clone.Spec.RenewTime = &metav1.MicroTime{Time: c.clock.Now()}
180-
clone.Spec.PingTime = nil
181180
_, err = c.leaseClient.Update(ctx, clone, metav1.UpdateOptions{})
182181
if err != nil {
183182
return err

tools/leaderelection/leasecandidate_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func pollForLease(ctx context.Context, tc testcase, client *fake.Clientset, t *m
130130
if lc.Spec.BinaryVersion == tc.binaryVersion &&
131131
lc.Spec.EmulationVersion == tc.emulationVersion &&
132132
lc.Spec.LeaseName == tc.leaseName &&
133-
lc.Spec.PingTime == nil &&
134133
lc.Spec.RenewTime != nil {
135134
// Ensure that if a time is provided, the renewTime occurred after the provided time.
136135
if t != nil && t.After(lc.Spec.RenewTime.Time) {

0 commit comments

Comments
 (0)