class_cooling_device: ignore EINVAL (etc) when reading files.#783
class_cooling_device: ignore EINVAL (etc) when reading files.#783SuperQ merged 1 commit intoprometheus:masterfrom
Conversation
Fixes: prometheus#746, fixes prometheus/node_exporter#3420 Some cooling devices return errors when attempting to read state files. When that happens, ignore the error, and skip to the next device rather than failing to return any devices. Signed-off-by: Malcolm Rowe <malcolmr@google.com>
|
|
||
| coolingDeviceStats, err = parseCoolingDeviceStats(cd) | ||
| if err != nil { | ||
| if canIgnoreError(err) { |
There was a problem hiding this comment.
This is from sysfs/net_class.go, and is already used in a few other places. Perhaps it should move to somewhere more common? (suggestions welcome, I'm not that familiar with Go).
I note that there's identical code in sysfs/class_infiniband.go, too, and similar cases in #749 and #763, at least, so maybe this is something that util.SysReadFile() should be handling, somehow?
There was a problem hiding this comment.
Good point.. Handling in SysReadFile could make sense but I'm worried we will silently ignore cases where EINVAL should raise an errror..
@SuperQ wdyt?
There was a problem hiding this comment.
Yea, we very much need to be careful about eating errors. It's code duplication, but this is basically "The way Go works". We need to be explicit at each occurrence.
There was a problem hiding this comment.
Yeah agree, no harm in handling it explicitly. If we find a pattern, we can refactor to move this to a shared function later
SuperQ
left a comment
There was a problem hiding this comment.
We can refactor the helper func later if we want.
Fixes: #746, fixes prometheus/node_exporter#3420
Some cooling devices return errors when attempting to read state files. When that happens, ignore the error, and skip to the next device rather than failing to return any devices.