This repository was archived by the owner on Nov 8, 2025. It is now read-only.
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
666666 }
667667 }
668668
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+
669692 w , err := watchutil .NewRetryWatcher (resourceVersion , & cache.ListWatch {
670693 WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
671694 res , err := resClient .Watch (ctx , options )
You can’t perform that action at this time.
0 commit comments