@@ -251,8 +251,6 @@ type DataGathererDynamic struct {
251251 informer k8scache.SharedIndexInformer
252252 dynamicSharedInformer dynamicinformer.DynamicSharedInformerFactory
253253 nativeSharedInformer informers.SharedInformerFactory
254- informerCtx context.Context
255- informerCancel context.CancelFunc
256254
257255 // isInitialized is set to true when data is first collected, prior to
258256 // this the fetch method will return an error
@@ -266,21 +264,13 @@ func (g *DataGathererDynamic) Run(stopCh <-chan struct{}) error {
266264 return fmt .Errorf ("informer was not initialized, impossible to start" )
267265 }
268266
269- // starting a new ctx for the informer
270- // WithCancel copies the parent ctx and creates a new done() channel
271- informerCtx , cancel := context .WithCancel (g .ctx )
272- g .informerCtx = informerCtx
273- g .informerCancel = cancel
274-
275267 // attach WatchErrorHandler, it needs to be set before starting an informer
276268 err := g .informer .SetWatchErrorHandler (func (r * k8scache.Reflector , err error ) {
277269 if strings .Contains (fmt .Sprintf ("%s" , err ), "the server could not find the requested resource" ) {
278270 log .Printf ("server missing resource for datagatherer of %q " , g .groupVersionResource )
279271 } else {
280272 log .Printf ("datagatherer informer for %q has failed and is backing off due to error: %s" , g .groupVersionResource , err )
281273 }
282- // cancel the informer ctx to stop the informer in case of error
283- cancel ()
284274 })
285275 if err != nil {
286276 return fmt .Errorf ("failed to SetWatchErrorHandler on informer: %s" , err )
@@ -312,7 +302,6 @@ func (g *DataGathererDynamic) WaitForCacheSync(stopCh <-chan struct{}) error {
312302// informer
313303func (g * DataGathererDynamic ) Delete () error {
314304 g .cache .Flush ()
315- g .informerCancel ()
316305 return nil
317306}
318307
0 commit comments