-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Failures in deferred calls not captured #4586
Comments
Doesn't the linter complain if the error is ignored? |
@vincepri No, at least not yet. Although I'm not sure if there's a linter we could enable via golangci-lint Errors in defer calls are pretty frequently ignored (not sure why), especially for things like file.Close. Hm strange I think
The search is not ideal, but even at a first glance we have a few occurences of ignored errors in defer Close statements: https://github.com/kubernetes-sigs/cluster-api/search?q=defer+Close |
/milestone Next |
@vincepri: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Apparently we have a linter for it. gosec finding G307 detects some of these cases. The findings we have there seem reasonable: |
@sbueringer Is there any action items we have as part of this issue? If we can rework it to be more specific and provide a potential solution, we can also mark it as good-first-issue |
@vincepri In my opinion we have two options depending on if we want to fix
I think option 1 might not be worth it to flag it as good-first-issue as it's just moving one line in the linter config. Option 2 would be good for good-first-issue. We just should decide first :) |
I'm ok to leave that as-is for now, file closure failure are usually a sign for other things failing way earlier, although if we want to fix it that's also fine |
Same for me. Let's see if @CecileRobertMichon or @fabriziopandini have a strong opinion on that. Otherwise I would adjust the linter config and close the issue. |
+1 to leave as it is |
What steps did you take and what happened:
Great suggestion from Stefan in #4499 (comment)
I think it would be a good idea to use something like that to be able to capture failure information in deferred calls.
What did you expect to happen:
It would be great to capture failure information rather than silently swallowing problems.
Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]
Environment:
kubectl version
):/etc/os-release
):/kind bug
/assign
The text was updated successfully, but these errors were encountered: