I'm writing a custom controller for Kubernetes in Go with the help of client-go. It is based on the sample-controller and working great so far.
The SharedIndexInformer
has the option to periodically resync all objects. (Parameter resyncPeriod
is set to 30 seconds in the sample-controller.)
Is there a way to force a resync immediately?
The code which seems to handle the periodic resync seems to call store.Resync()
. I've tried calling fooInformer.Informer().GetStore().Resync()
. The call succeeds, but the resync is not happening. What did I miss?
I'm using client-go
v0.17.2
and the server is EKS v1.14.9-eks-c0eccc
.
Upon calling fooInformer.Informer().GetStore().Resync()
you are using Resync
function/method of the Store type defined in: client-go/tools/cache/store.go
And there we can see the following:
In the Store type definition:
// Resync is meaningless in the terms appearing here but has
// meaning in some implementations that have non-trivial
// additional behavior (e.g., DeltaFIFO).
Resync() error
And in the Resync definition further below:
// Resync is meaningless for one of these
func (c *cache) Resync() error {
return nil
}
Unless you actually have some other class to do the Resync, this is supposed to really do nothing.
That is why
The call succeeds, but the resync is not happening.
Hope that helps!