Skip to content

Commit 9f29a65

Browse files
committed
Ensure all WatchFunc enable watch and boomarks
AllowWatchBookmarks is generally pretty safe to enable as it has been available in Kuberentes for a long while, and the server ignores the flag if it doesn't implement it (per docs). Signed-off-by: Vince Prignano <[email protected]>
1 parent e3347b5 commit 9f29a65

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/cache/internal/informers.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ func (ip *Informers) addInformerToMap(gvk schema.GroupVersionKind, obj runtime.O
361361
return listWatcher.ListFunc(opts)
362362
},
363363
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
364-
ip.selector.ApplyToList(&opts)
365364
opts.Watch = true // Watch needs to be set to true separately
365+
opts.AllowWatchBookmarks = true
366+
367+
ip.selector.ApplyToList(&opts)
366368
return listWatcher.WatchFunc(opts)
367369
},
368370
}, obj, calculateResyncPeriod(ip.resync), cache.Indexers{
@@ -444,6 +446,9 @@ func (ip *Informers) makeListWatcher(gvk schema.GroupVersionKind, obj runtime.Ob
444446
},
445447
// Setup the watch function
446448
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
449+
opts.Watch = true // Watch needs to be set to true separately
450+
opts.AllowWatchBookmarks = true
451+
447452
if namespace != "" {
448453
return resources.Namespace(namespace).Watch(ip.ctx, opts)
449454
}
@@ -486,6 +491,9 @@ func (ip *Informers) makeListWatcher(gvk schema.GroupVersionKind, obj runtime.Ob
486491
},
487492
// Setup the watch function
488493
WatchFunc: func(opts metav1.ListOptions) (watcher watch.Interface, err error) {
494+
opts.Watch = true // Watch needs to be set to true separately
495+
opts.AllowWatchBookmarks = true
496+
489497
if namespace != "" {
490498
watcher, err = resources.Namespace(namespace).Watch(ip.ctx, opts)
491499
} else {
@@ -527,6 +535,9 @@ func (ip *Informers) makeListWatcher(gvk schema.GroupVersionKind, obj runtime.Ob
527535
},
528536
// Setup the watch function
529537
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
538+
opts.Watch = true // Watch needs to be set to true separately
539+
opts.AllowWatchBookmarks = true
540+
530541
// Build the request.
531542
req := client.Get().Resource(mapping.Resource.Resource).VersionedParams(&opts, ip.paramCodec)
532543
if namespace != "" {

0 commit comments

Comments
 (0)