<p>I'm writing a custom controller for Kubernetes in Go with the help of <a href="https://github.com/kubernetes/client-go/" rel="nofollow noreferrer">client-go</a>.
It is based on the <a href="https://github.com/kubernetes/sample-controller" rel="nofollow noreferrer">sample-controller</a> and working great so far.</p>

<p>The <code>SharedIndexInformer</code> has the option to periodically resync all objects. (<a href="https://github.com/kubernetes/client-go/blob/203d909765c952c466d36786ec7adf13d40f2281/tools/cache/shared_informer.go#L170" rel="nofollow noreferrer">Parameter <code>resyncPeriod</code></a> is set to 30 seconds in the <a href="https://github.com/kubernetes/sample-controller/blob/d90ced32cf661b9821ecb20b08502ad62377a035/main.go#L63" rel="nofollow noreferrer">sample-controller</a>.)</p>

<p><em>Is there a way to force a resync immediately?</em></p>

<p>The code which seems to handle the periodic resync seems to call <a href="https://github.com/kubernetes/client-go/blob/203d909765c952c466d36786ec7adf13d40f2281/tools/cache/reflector.go#L332" rel="nofollow noreferrer"><code>store.Resync()</code></a>.
I've tried calling <code>fooInformer.Informer().GetStore().Resync()</code>. The call succeeds, but the resync is not happening. What did I miss?</p>

<hr>

<p>I'm using <code>client-go</code> <code>v0.17.2</code> and the server is EKS <code>v1.14.9-eks-c0eccc</code>.</p>

Leonhard Wimmer
<p>This is not possible.</p>
<p>The <code>cache.Store</code> that does the periodic resync is instantiated in <code>newInformer</code> in <code>k8s.io/client-go/tools/cache/controller.go</code> as a <code>cache.DeltaFIFO</code> queue:</p>
<pre><code>    // This will hold incoming changes. Note how we pass clientState in as a
    // KeyLister, that way resync operations will result in the correct set
    // of update/delete deltas.
    fifo := NewDeltaFIFOWithOptions(DeltaFIFOOptions{
        KnownObjects:          clientState,
        EmitDeltaTypeReplaced: true,
    })
</code></pre>
<p>This is returned by <code>cache.New()</code> as an unexported field <code>cache.controller{}.config.Queue</code>, which there is no exported function for accessing- so no way to manually call <code>Resync()</code>.</p>
