client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Remove event handler from SharedIndexInformer at runtime

Open makkes opened this issue 2 years ago • 0 comments

I would love to be able to use a SharedIndexInformer without my process leaking goroutines and eventually crashing.

Background: I'm using controller-runtime to spin up a controller that in turn will create controllers at runtime based on custom resources being created. Now each new controller created by the parent controller eventually results in a call to AddEventHandlerWithResyncPeriod on the same SharedIndexInformer. As soon as the child controller is stopped, though, the event handler is not removed because SharedIndexInformer doesn't provide a method to do so. This in turn leads to goroutines leaking because for each new handler added through AddEventHandlerWithResyncPeriod several (2?) goroutines are spawned here. Those goroutines are only stopped when the whole sharedProcessor is stopped here.

Now if SharedIndexInformer had a way to remove an event handler and stopping its goroutines I would be able to use a SharedIndexInformer without it leaking goroutines over time.

makkes avatar Oct 04 '22 16:10 makkes