@@ -251,8 +251,6 @@ type DataGathererDynamic struct {
251
251
informer k8scache.SharedIndexInformer
252
252
dynamicSharedInformer dynamicinformer.DynamicSharedInformerFactory
253
253
nativeSharedInformer informers.SharedInformerFactory
254
- informerCtx context.Context
255
- informerCancel context.CancelFunc
256
254
257
255
// isInitialized is set to true when data is first collected, prior to
258
256
// this the fetch method will return an error
@@ -266,21 +264,13 @@ func (g *DataGathererDynamic) Run(stopCh <-chan struct{}) error {
266
264
return fmt .Errorf ("informer was not initialized, impossible to start" )
267
265
}
268
266
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
-
275
267
// attach WatchErrorHandler, it needs to be set before starting an informer
276
268
err := g .informer .SetWatchErrorHandler (func (r * k8scache.Reflector , err error ) {
277
269
if strings .Contains (fmt .Sprintf ("%s" , err ), "the server could not find the requested resource" ) {
278
270
log .Printf ("server missing resource for datagatherer of %q " , g .groupVersionResource )
279
271
} else {
280
272
log .Printf ("datagatherer informer for %q has failed and is backing off due to error: %s" , g .groupVersionResource , err )
281
273
}
282
- // cancel the informer ctx to stop the informer in case of error
283
- cancel ()
284
274
})
285
275
if err != nil {
286
276
return fmt .Errorf ("failed to SetWatchErrorHandler on informer: %s" , err )
@@ -312,7 +302,6 @@ func (g *DataGathererDynamic) WaitForCacheSync(stopCh <-chan struct{}) error {
312
302
// informer
313
303
func (g * DataGathererDynamic ) Delete () error {
314
304
g .cache .Flush ()
315
- g .informerCancel ()
316
305
return nil
317
306
}
318
307
0 commit comments