fix(): actually just compare the holder identity and not the resource version
This commit is contained in:
@@ -11,9 +11,6 @@ import (
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// StartLeaseInformer starts a long-running informer watching Lease objects in the kube-system namespace.
|
||||
// It will react to Add/Update events for leases whose name starts with "cilium-l2announce" and label
|
||||
// the corresponding node.
|
||||
func StartLeaseInformer(cfg *Config, stopCh <-chan struct{}) error {
|
||||
log.WithFields(log.Fields{"Caller": "StartLeaseInformer"}).Info("Starting lease informer")
|
||||
|
||||
@@ -40,11 +37,26 @@ func StartLeaseInformer(cfg *Config, stopCh <-chan struct{}) error {
|
||||
if okNew {
|
||||
log.WithFields(log.Fields{"Caller": "lease.Update.new", "Lease": newL.Name, "RV": newL.ResourceVersion}).Debug("New lease")
|
||||
}
|
||||
// Only handle when resourceVersion changed (actual update), skip resync/identical events
|
||||
// Only handle when either:
|
||||
// - the object is not parseable as Lease (defensive), or
|
||||
// - it's an Add-like event (old not present), or
|
||||
// - HolderIdentity actually changed compared to previous object.
|
||||
if okOld && okNew {
|
||||
// If resourceVersion didn't change, skip (no real update)
|
||||
if oldL.ResourceVersion == newL.ResourceVersion {
|
||||
return
|
||||
}
|
||||
oldHolder := ""
|
||||
newHolder := ""
|
||||
if oldL.Spec.HolderIdentity != nil {
|
||||
oldHolder = *oldL.Spec.HolderIdentity
|
||||
}
|
||||
if newL.Spec.HolderIdentity != nil {
|
||||
newHolder = *newL.Spec.HolderIdentity
|
||||
}
|
||||
if oldHolder == newHolder {
|
||||
return
|
||||
}
|
||||
}
|
||||
handleLease(newObj, cfg)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user