@@ -49,14 +49,19 @@ type InformersOpts struct {
49
49
Selector Selector
50
50
Transform cache.TransformFunc
51
51
UnsafeDisableDeepCopy bool
52
+ WatchErrorHandler cache.WatchErrorHandler
52
53
}
53
54
54
55
// NewInformers creates a new InformersMap that can create informers under the hood.
55
56
func NewInformers (config * rest.Config , options * InformersOpts ) * Informers {
56
57
newInformer := cache .NewSharedIndexInformer
58
+ watchErrorHandler := cache .DefaultWatchErrorHandler
57
59
if options .NewInformer != nil {
58
60
newInformer = * options .NewInformer
59
61
}
62
+ if options .WatchErrorHandler != nil {
63
+ watchErrorHandler = options .WatchErrorHandler
64
+ }
60
65
return & Informers {
61
66
config : config ,
62
67
httpClient : options .HTTPClient ,
@@ -76,6 +81,7 @@ func NewInformers(config *rest.Config, options *InformersOpts) *Informers {
76
81
transform : options .Transform ,
77
82
unsafeDisableDeepCopy : options .UnsafeDisableDeepCopy ,
78
83
newInformer : newInformer ,
84
+ watchErrorHandler : watchErrorHandler ,
79
85
}
80
86
}
81
87
@@ -159,6 +165,8 @@ type Informers struct {
159
165
160
166
// NewInformer allows overriding of the shared index informer constructor for testing.
161
167
newInformer func (cache.ListerWatcher , runtime.Object , time.Duration , cache.Indexers ) cache.SharedIndexInformer
168
+
169
+ watchErrorHandler cache.WatchErrorHandler
162
170
}
163
171
164
172
// Start calls Run on each of the informers and sets started to true. Blocks on the context.
@@ -323,6 +331,12 @@ func (ip *Informers) addInformerToMap(gvk schema.GroupVersionKind, obj runtime.O
323
331
cache .NamespaceIndex : cache .MetaNamespaceIndexFunc ,
324
332
})
325
333
334
+ // Set WatchErrorHandler on SharedIndexInformer
335
+ err = sharedIndexInformer .SetWatchErrorHandler (ip .watchErrorHandler )
336
+ if err != nil {
337
+ return nil , false , err
338
+ }
339
+
326
340
// Check to see if there is a transformer for this gvk
327
341
if err := sharedIndexInformer .SetTransform (ip .transform ); err != nil {
328
342
return nil , false , err
0 commit comments