prometheus / procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Apache License 2.0
769 stars 319 forks source link

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

Closed dcbw closed 1 year ago

dcbw commented 1 year ago

https://github.com/prometheus/procfs/pull/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

SuperQ commented 1 year ago

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

dcbw commented 1 year ago

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.

dcbw commented 1 year ago

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