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: remove empty error wrapping #1185

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

ritwikranjan
Copy link
Contributor

@ritwikranjan ritwikranjan commented Jan 6, 2025

Description

This pull request includes changes to improve error handling in the pkg/plugin/hnsstats/vfp_counters_windows.go file. The most important changes include modifying the getVfpPortCountersRaw and listvPorts functions to ensure they return appropriate error messages when command execution fails.

Error handling improvements:

Checklist

  • I have read the contributing documentation.
  • I signed and signed-off the commits (git commit -S -s ...). See this documentation on signing commits.
  • I have correctly attributed the author(s) of the code.
  • I have tested the changes locally.
  • I have followed the project's style guidelines.
  • I have updated the documentation, if necessary.
  • I have added tests, if applicable.

Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes made.

Additional Notes

Add any additional notes or context about the pull request here.


Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.

@ritwikranjan ritwikranjan requested a review from a team as a code owner January 6, 2025 13:04
ibezrukavyi
ibezrukavyi previously approved these changes Jan 6, 2025
@rbtr
Copy link
Collaborator

rbtr commented Jan 6, 2025

Previously it used to return non-nil empty error even on success.

That's not how errors.Wrap works.

https://github.com/pkg/errors/blob/614d223910a179a466c1767a985424175c39b465/errors.go#L181-L196

// If err is nil, Wrap returns nil.

https://go.dev/play/p/vwqlw1j27tp

@ibezrukavyi ibezrukavyi self-requested a review January 6, 2025 19:05
@timraymond
Copy link
Member

Previously it used to return non-nil empty error even on success.

I'm sorry that my own misunderstanding memed this into existence, but honestly the proposed changes read better in my eyes, even if the two are isomorphic. Nothing magical is happening and the error path is neatly separated from the happy path.

@rbtr
Copy link
Collaborator

rbtr commented Jan 6, 2025

Previously it used to return non-nil empty error even on success.

I'm sorry that my own misunderstanding memed this into existence, but honestly the proposed changes read better in my eyes, even if the two are isomorphic. Nothing magical is happening and the error path is neatly separated from the happy path.

I agree, but if we observed non-nil, empty errors and thought that this was the cause - it's not. This isn't the fix and the bug is elsewhere.

Co-authored-by: Evan Baker <[email protected]>
Signed-off-by: Ritwik Ranjan <[email protected]>
@ritwikranjan ritwikranjan enabled auto-merge January 7, 2025 18:30
@ritwikranjan ritwikranjan added this pull request to the merge queue Jan 7, 2025
Merged via the queue into microsoft:main with commit b08a1bc Jan 7, 2025
28 checks passed
@ritwikranjan ritwikranjan deleted the fix/errorneous-logging branch January 7, 2025 19:17
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.

4 participants