<p dir="auto">When I stress-test PersistentVolume controller I sometimes get (correct) "PersistentVolumeClaim deleted" event followed by (wrong) "PersistentVolumeClaim added". This happens very rarely (&lt;0.01%) when I delete a PersistentVolumeClaim and the controller is under heavy load.</p>
<p dir="auto">I use <code class="notranslate">framework.NewInformer</code> (<a href="https://github.com/jsafrane/kubernetes/blob/master/pkg/controller/framework/controller.go#L213">link</a> ) like everybody else. Reading its code, what happens when the controller is processing 'PVC deleted' event at line <a href="https://github.com/jsafrane/kubernetes/blob/master/pkg/controller/framework/controller.go#L251">251</a>, i.e just <strong>before</strong> <code class="notranslate">Delete()</code> is called and at the same time periodic sync starts? The PVC that is being deleted is still in the cache and a 'PVC Sync' will be added into <code class="notranslate">Queue</code> and my controller gets  <code class="notranslate">OnDelete()</code> callback followed by <code class="notranslate">OnAdd()</code>.</p>
<p dir="auto">My PersistentVolume controller then sees an old claim and tries to do stuff with it and sometimes it updates the claim in etcd. So the claim gets 'resurrected' in etcd even though user deleted it.</p>
<p dir="auto">It is possible that my controller does something terribly wrong - I checked it twice, but it's pretty complicated piece of code. I am 100% sure that <code class="notranslate">OnAdd()</code> is called as reaction to <code class="notranslate">cache.Sync</code> event, I did a debug log in <code class="notranslate">Process</code> function of Informer.</p>
<p dir="auto">When I stress-test PersistentVolume controller I sometimes get (correct) "PersistentVolumeClaim deleted" event followed by (wrong) "PersistentVolumeClaim added". This happens very rarely (&lt;0.01%) when I delete a PersistentVolumeClaim and the controller is under heavy load.</p>
<p dir="auto">I use <code class="notranslate">framework.NewInformer</code> (<a href="https://github.com/jsafrane/kubernetes/blob/master/pkg/controller/framework/controller.go#L213">link</a> ) like everybody else. Reading its code, what happens when the controller is processing 'PVC deleted' event at line <a href="https://github.com/jsafrane/kubernetes/blob/master/pkg/controller/framework/controller.go#L251">251</a>, i.e just <strong>before</strong> <code class="notranslate">Delete()</code> is called and at the same time periodic sync starts? The PVC that is being deleted is still in the cache and a 'PVC Sync' will be added into <code class="notranslate">Queue</code> and my controller gets  <code class="notranslate">OnDelete()</code> callback followed by <code class="notranslate">OnAdd()</code>.</p>
<p dir="auto">My PersistentVolume controller then sees an old claim and tries to do stuff with it and sometimes it updates the claim in etcd. So the claim gets 'resurrected' in etcd even though user deleted it.</p>
<p dir="auto">It is possible that my controller does something terribly wrong - I checked it twice, but it's pretty complicated piece of code. I am 100% sure that <code class="notranslate">OnAdd()</code> is called as reaction to <code class="notranslate">cache.Sync</code> event, I did a debug log in <code class="notranslate">Process</code> function of Informer.</p>