@@ -492,24 +492,22 @@ func (c *clusterCache) startMissingWatches() error {
492
492
493
493
err := c .processApi (client , api , func (resClient dynamic.ResourceInterface , ns string ) error {
494
494
resourceVersion , err := c .loadInitialState (ctx , api , resClient , ns , false ) // don't lock here, we are already in a lock before startMissingWatches is called inside watchEvents
495
- if err != nil {
496
- if c .isRestrictedResource (err ) {
497
- keep := false
498
- if c .respectRBAC == RespectRbacStrict {
499
- k , permErr := c .checkPermission (ctx , clientset .AuthorizationV1 ().SelfSubjectAccessReviews (), api )
500
- if permErr != nil {
501
- return fmt .Errorf ("failed to check permissions for resource %s: %w, original error=%v" , api .GroupKind .String (), permErr , err .Error ())
502
- }
503
- keep = k
504
- }
505
- // if we are not allowed to list the resource, remove it from the watch list
506
- if ! keep {
507
- delete (c .apisMeta , api .GroupKind )
508
- delete (namespacedResources , api .GroupKind )
509
- return nil
495
+ if err != nil && c .isRestrictedResource (err ) {
496
+ keep := false
497
+ if c .respectRBAC == RespectRbacStrict {
498
+ k , permErr := c .checkPermission (ctx , clientset .AuthorizationV1 ().SelfSubjectAccessReviews (), api )
499
+ if permErr != nil {
500
+ return fmt .Errorf ("failed to check permissions for resource %s: %w, original error=%v" , api .GroupKind .String (), permErr , err .Error ())
510
501
}
502
+ keep = k
503
+ }
504
+ // if we are not allowed to list the resource, remove it from the watch list
505
+ if ! keep {
506
+ delete (c .apisMeta , api .GroupKind )
507
+ delete (namespacedResources , api .GroupKind )
508
+ return nil
511
509
}
512
- return fmt . Errorf ( "failed to start watch %s: %w" , api . GroupKind . String (), err )
510
+
513
511
}
514
512
go c .watchEvents (ctx , api , resClient , ns , resourceVersion )
515
513
return nil
0 commit comments