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

features: remove EPERM wrapping exception, automatically wrap errors #749

Merged
merged 2 commits into from Jul 29, 2022

Conversation

ti-mo
Copy link
Collaborator

@ti-mo ti-mo commented Jul 27, 2022

In an attempt to simplify the switch blocks in all types of feature
probes, lift the arbitrary EPERM wrapping exception.

Also, move the call to fd.Close() out of the switch statement to live
closer to the call that returns the fd. The fd can always be immediately
closed.
Instead of relying on repeated calls to fmt.Errorf("...: %w", err) to ensure
we never return naked sentinels, add error wrappers at a few key locations.

This abstracts and centralizes the wrapping logic to make the probe logic
itself a bit leaner.

Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

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

I think the closure is ok here, since it's the first thing that happens in the function.

There is a small downside to this approach: wrapping happens every time Have* is called, not just once. Probably not a big issue.

Ultimately I still wonder why we're not using internal.FeatureTest here. It has this figured out + it would allow feature tests to execute concurrently.

@ti-mo
Copy link
Collaborator Author

ti-mo commented Jul 29, 2022

There is a small downside to this approach: wrapping happens every time Have* is called, not just once.

Yep, but errors are also no longer stored in wrapped form, so this trades (little) cpu for (little) memory!

I'll check if we can switch to internal.FeatureTest.

In an attempt to simplify the switch blocks in all types of feature
probes, lift the arbitrary EPERM wrapping exception.

Also, move the call to fd.Close() out of the switch statement to live
closer to the call that returns the fd. The fd can always be immediately
closed.

Signed-off-by: Timo Beckers <timo@isovalent.com>
Instead of relying on repeated calls to fmt.Errorf("...: %w", err) to ensure
we never return naked sentinels, add error wrappers at a few key locations.

This abstracts and centralizes the wrapping logic to make the probe logic
itself a bit leaner.

Signed-off-by: Timo Beckers <timo@isovalent.com>
@ti-mo ti-mo merged commit 5bd5446 into cilium:master Jul 29, 2022
@ti-mo ti-mo deleted the tb/features-wrap-errors branch July 29, 2022 12:16
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.

None yet

2 participants