Instead of blocking the whole reconcile, we should block after the reconciler calling informer.HasSynced and before reading the reconciler. This will avoid the deadlock issue as the reconciler will not wait for any lock when the informer is also blocked.
Besides we use only one lock to coordinate between the informer and the reconciler:
everytime before reading the object, the reconciler needs to grab the lock. After reading the object, the lock will be released
when seeing the crucial event (to make the reconciler miss), the informer will try to grab the same lock. This ensures that the crucial event is only written to the indexer while no one is reading the indexer. And after that since the lock is held by the informer the reconciler will not be able to see the crucial event
when a following cancelling event comes the informer will release the lock. After that, the reconciler can continue w/o seeing the crucial event.
Instead of blocking the whole reconcile, we should block after the reconciler calling
informer.HasSynced
and before reading the reconciler. This will avoid the deadlock issue as the reconciler will not wait for any lock when the informer is also blocked. Besides we use only one lock to coordinate between the informer and the reconciler: