File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -666,6 +666,29 @@ func (c *clusterCache) watchEvents(ctx context.Context, api kube.APIResourceInfo
666
666
}
667
667
}
668
668
669
+ // If the resourceVersion is still missing, watchutil.NewRetryWatcher will fail.
670
+ // https://github.com/kubernetes/client-go/blob/78d2af792babf2dd937ba2e2a8d99c753a5eda89/tools/watch/retrywatcher.go#L68-L71
671
+ // Instead, let's just check if the resourceVersion exists at the next resync ...
672
+ if resourceVersion == "" {
673
+ c .log .V (1 ).Info (fmt .Sprintf ("Ignoring watch for %s on %s due to missing resourceVersion" , api .GroupKind , c .config .Host ))
674
+
675
+ var watchResyncTimeoutCh <- chan time.Time
676
+ if c .watchResyncTimeout > 0 {
677
+ shouldResync := time .NewTimer (c .watchResyncTimeout )
678
+ defer shouldResync .Stop ()
679
+ watchResyncTimeoutCh = shouldResync .C
680
+ }
681
+
682
+ for {
683
+ select {
684
+ case <- ctx .Done ():
685
+ return nil
686
+ case <- watchResyncTimeoutCh :
687
+ return fmt .Errorf ("Resyncing %s on %s due to timeout" , api .GroupKind , c .config .Host )
688
+ }
689
+ }
690
+ }
691
+
669
692
w , err := watchutil .NewRetryWatcher (resourceVersion , & cache.ListWatch {
670
693
WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
671
694
res , err := resClient .Watch (ctx , options )
You can’t perform that action at this time.
0 commit comments