kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
9.04k stars 2.94k forks source link

resyncPeriod=0 should imply no resync #902

Closed acmlearn closed 3 years ago

acmlearn commented 3 years ago

Tried to test SharedInformerFactory examples using the blog https://rohaan.medium.com/introduction-to-fabric8-kubernetes-java-client-informer-api-b945082d69af.

When testing with 0 resync period, it is still relisting the updates within seconds. sharedInformerFactory.sharedIndexInformerFor( Pod.class, // POJO for Pod resource PodList.class, // POJO for Pod list resource 0 * 1000L); // resync period

As per definition for ResyncPeriod: if non-zero, will re-list this often (you will get OnUpdate calls, even if nothing changed). Otherwise, re-list will be delayed as long as possible (until the upstream source closes the watch or times out, or you stop the controller). https://github.com/kubernetes/client-go/blob/fb61a7c88cb9f599363919a34b7c54a605455ffc/tools/cache/controller.go#L337

acmlearn commented 3 years ago

created it under kubernetes-client project https://github.com/fabric8io/kubernetes-client/issues/2651