fix(): actually just compare the holder identity and not the resource version
Some checks failed
Build and Test / Test (push) Failing after 18s
Build and Test / Build_Image_arm64 (push) Successful in 2m9s
Build and Test / Build_Image_amd64 (push) Has been cancelled

This commit is contained in:
2026-01-20 22:19:25 +01:00
parent 0365c2ff21
commit a0593f7873

View File

@@ -11,9 +11,6 @@ import (
"k8s.io/client-go/tools/cache" "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 { func StartLeaseInformer(cfg *Config, stopCh <-chan struct{}) error {
log.WithFields(log.Fields{"Caller": "StartLeaseInformer"}).Info("Starting lease informer") log.WithFields(log.Fields{"Caller": "StartLeaseInformer"}).Info("Starting lease informer")
@@ -40,11 +37,26 @@ func StartLeaseInformer(cfg *Config, stopCh <-chan struct{}) error {
if okNew { if okNew {
log.WithFields(log.Fields{"Caller": "lease.Update.new", "Lease": newL.Name, "RV": newL.ResourceVersion}).Debug("New lease") 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 okOld && okNew {
// If resourceVersion didn't change, skip (no real update)
if oldL.ResourceVersion == newL.ResourceVersion { if oldL.ResourceVersion == newL.ResourceVersion {
return 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) handleLease(newObj, cfg)
}, },