-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SharedIndexInformer EventHandler sees double updates at resync interval #2812
Comments
We should compare what happens in the analogous operation for client-go. |
I tried this on client-go and it doesn't look like they also get double updates. So a code like this: func (c *PodLoggingController) podAdd(obj interface{}) {
pod := obj.(*v1.Pod)
klog.Infof("POD CREATED: %s/%s", pod.Namespace, pod.Name)
}
func (c *PodLoggingController) podUpdate(old, new interface{}) {
oldPod := old.(*v1.Pod)
newPod := new.(*v1.Pod)
klog.Infof(
"POD UPDATED. %s/%s %s",
oldPod.Namespace, oldPod.Name, newPod.Status.Phase,
)
}
func (c *PodLoggingController) podDelete(obj interface{}) {
pod := obj.(*v1.Pod)
klog.Infof("POD DELETED: %s/%s", pod.Namespace, pod.Name)
}
// NewPodLoggingController creates a PodLoggingController
func NewPodLoggingController(informerFactory informers.SharedInformerFactory) *PodLoggingController {
podInformer := informerFactory.Core().V1().Pods()
c := &PodLoggingController{
informerFactory: informerFactory,
podInformer: podInformer,
}
podInformer.Informer().AddEventHandler(
// Your custom resource event handlers.
cache.ResourceEventHandlerFuncs{
// Called on creation
AddFunc: c.podAdd,
// Called on resource update and every resyncPeriod on existing resources.
UpdateFunc: c.podUpdate,
// Called on resource deletion.
DeleteFunc: c.podDelete,
},
)
return c
} This seems to produce the following output:
But similar code on Fabric8 Kubernetes Client seem to be generating double updates on resync intervals:
I think somehow we're updating the cache twice during resync intervals |
I think we're triggering cache update at these two places here: In Controller, we are scheduling execution for Line 103 in 5e57327
In Line 144 in 5e57327
I think if we remove one of them, we'll be able to see correct behavior. |
Looks like client-go
Right now we're having that in memory resync too(which is |
Given that the In understand that users using this feature assume that the behavior will be the same as if the same logic was implemented using go. |
…tes at resync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
…tes at resync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
…tes at resync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
…tes at resync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
…tes at resync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
Here is a reference to Client Go's reflector.Run(): tools/cache/reflector.go#L218 This is where resync seems to be called: reflector.go#L382 which delegates to delta_fifo's Resync(): tools/cache/delta_fifo.go#L651 |
…tes at resync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
…sync interval + Remove scheduleAtFixedDelay execution of Reflector#resyncAndList(), resync should happen in memory without contacting the apiserver just like client go implementation + Added logic for watch.close() when Reflector#stop() is called
Creating an informer with an Eventhandler similar to this:
Results in the onUpdate method being called twice for every resource on the resync interval. Is that expected?
The text was updated successfully, but these errors were encountered: