-
Notifications
You must be signed in to change notification settings - Fork 316
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
net_class: catch syscall.EINVAL and better handle read errors #516
Conversation
c2cef03
to
8c34065
Compare
sysfs/net_class.go
Outdated
if isFatalError(err) { | ||
return fmt.Errorf("failed to read file %q: %w", attrPath, err) | ||
} | ||
return nil |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
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>
8c34065
to
a12f2c5
Compare
@SuperQ flipped meaning to |
There was a problem hiding this 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.
#483 introduced a bug that terminates attribute reading when the returned error is
syscall.Errno
, which is whatutil.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