Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: swallowed error in startMissingWatches #605

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agaudreault
Copy link
Member

@agaudreault agaudreault commented Jul 11, 2024

If loadInitialState returns an error, it is possible to still call watchEvents and loadInitialState again when the resource type in error is not restricted.

}
return fmt.Errorf("failed to start watch %s: %w", api.GroupKind.String(), err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be wrapped in an else to avoid throwing an error when the resource is just restricted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it makes sense to call c.watchEvents if resourceVersion is nil and there is an error.

If keep is true, that means the resource is restricted (k8sErrors.IsForbidden(err) || k8sErrors.IsUnauthorized(err)), but the controller has permissions... it sounds like it should never happens.

And there is another codepath here that has a a different logic, so I think both should be the same. @gdsoumya can you give more insights on what should be happening.

if err != nil {
if c.isRestrictedResource(err) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants