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

net_class: catch syscall.EINVAL and better handle read errors #516

Merged
merged 1 commit into from May 17, 2023

Conversation

dcbw
Copy link
Contributor

@dcbw dcbw commented May 10, 2023

#483 introduced a bug that terminates attribute reading when the returned error is syscall.Errno, which is what util.SysReadFile() will typically return. Handle that case specifically.

While doing that pull the error checking into ParseNetClassAttribute() for clarity and to allow external callers to handle errors correctly.

@SuperQ @discordianfish

@dcbw dcbw force-pushed the net-class-better-errors branch 2 times, most recently from c2cef03 to 8c34065 Compare May 10, 2023 16:01
if isFatalError(err) {
return fmt.Errorf("failed to read file %q: %w", attrPath, err)
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, what errors are we going to ignore by doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SuperQ No more errors than we ignored before... It uses the same logic, but now additionally ignores the syscall.Errno(EINVAL)

@SuperQ
Copy link
Member

SuperQ commented May 11, 2023

Maybe we should inverse this, all errors are fatal unless they're in a list of allowed non-fatal errors.

@dcbw
Copy link
Contributor Author

dcbw commented May 11, 2023

Maybe we should inverse this, all errors are fatal unless they're in a list of allowed non-fatal errors.

@SuperQ that's effectively what the code is already doing (and was doing before); but perhaps my function name is not as clear. I can reverse the meaning if you'd like.

prometheus#483 introduced a bug
that terminates attribute reading when the returned error is
syscall.Errno, which is what util.SysReadFile() will typically
return. Handle that case specifically.

While doing that pull the error checking into
ParseNetClassAttribute() for clarity and to allow external
callers to handle errors correctly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
@dcbw dcbw force-pushed the net-class-better-errors branch from 8c34065 to a12f2c5 Compare May 15, 2023 14:19
@dcbw
Copy link
Contributor Author

dcbw commented May 15, 2023

@SuperQ flipped meaning to canIgnoreError() and updated the docstring to better explain. PTAL thanks!

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

Thanks! That's more clear.

@discordianfish discordianfish merged commit 7acd99d into prometheus:master May 17, 2023
8 checks passed
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

3 participants