Skip to content

Commit cac515a

Browse files
committed
revert error
Signed-off-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com>
1 parent d858cd6 commit cac515a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

pkg/cache/cluster.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,24 +492,22 @@ func (c *clusterCache) startMissingWatches() error {
492492

493493
err := c.processApi(client, api, func(resClient dynamic.ResourceInterface, ns string) error {
494494
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())
510501
}
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
511509
}
512-
return fmt.Errorf("failed to start watch %s: %w", api.GroupKind.String(), err)
510+
513511
}
514512
go c.watchEvents(ctx, api, resClient, ns, resourceVersion)
515513
return nil

0 commit comments

Comments
 (0)