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

Remove error wrapper from /sys/class/power_supply #308

Merged
merged 1 commit into from
Jun 14, 2020

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Jun 13, 2020

Don't wrap the error of ioutil.ReadDir() so that the error return can
be tested with os.IsNotExist(). Fixes node_exporter log noise.

caller=collector.go:161 msg="collector failed" name=powersupplyclass duration_seconds=0.00079848 err="could not get power_supply class info: error obtaining power_supply class info: failed to list power supplies at \"/sys/class/power_supply\": open /sys/class/power_supply: no such file or directory"

Signed-off-by: Ben Kochie superq@gmail.com

Don't wrap the error of `ioutil.ReadDir()` so that the error return can
be tested with `os.IsNotExist()`. Fixes node_exporter log noise.

```
caller=collector.go:161 msg="collector failed" name=powersupplyclass duration_seconds=0.00079848 err="could not get power_supply class info: error obtaining power_supply class info: failed to list power supplies at \"/sys/class/power_supply\": open /sys/class/power_supply: no such file or directory"
```

Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ
Copy link
Member Author

SuperQ commented Jun 13, 2020

This is similar to #302.

SuperQ added a commit to prometheus/node_exporter that referenced this pull request Jun 13, 2020
Handle the case when /sys/class/power_supply doesn't exist. Fixes
logging error spam.

Requires prometheus/procfs#308

Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ SuperQ requested a review from roidelapluie June 13, 2020 10:21
@roidelapluie
Copy link
Member

The node exporter is go1.14. can't we use errors.Is ?

@SuperQ
Copy link
Member Author

SuperQ commented Jun 13, 2020

Oh, I didn't know about that one. Yes, we already require Go 1.14 for https, so that should be fine.

@SuperQ
Copy link
Member Author

SuperQ commented Jun 13, 2020

I tried that out on a test build, it doesn't seem to work.

@roidelapluie
Copy link
Member

roidelapluie commented Jun 13, 2020

Indeed. It requires the fmt.Errorf to use %w instead of %v for the error. Do you think this is worth it? Would make procfs 1.13+

@SuperQ
Copy link
Member Author

SuperQ commented Jun 13, 2020

Hrm, maybe good to start using it upstream, but for now let's un-wrap the error. We want to keep procfs compatible with what client_golang needs for Go versions.

Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

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

LGTM

@SuperQ SuperQ merged commit 4486fb2 into master Jun 14, 2020
@SuperQ SuperQ deleted the superq/power_supply_error branch June 14, 2020 13:29
SuperQ added a commit to prometheus/node_exporter that referenced this pull request Jun 15, 2020
Handle the case when /sys/class/power_supply doesn't exist. Fixes
logging error spam.

Requires prometheus/procfs#308

Signed-off-by: Ben Kochie <superq@gmail.com>
remijouannet pushed a commit to remijouannet/procfs that referenced this pull request Oct 20, 2022
Don't wrap the error of `ioutil.ReadDir()` so that the error return can
be tested with `os.IsNotExist()`. Fixes node_exporter log noise.

```
caller=collector.go:161 msg="collector failed" name=powersupplyclass duration_seconds=0.00079848 err="could not get power_supply class info: error obtaining power_supply class info: failed to list power supplies at \"/sys/class/power_supply\": open /sys/class/power_supply: no such file or directory"
```

Signed-off-by: Ben Kochie <superq@gmail.com>
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
Handle the case when /sys/class/power_supply doesn't exist. Fixes
logging error spam.

Requires prometheus/procfs#308

Signed-off-by: Ben Kochie <superq@gmail.com>
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
Handle the case when /sys/class/power_supply doesn't exist. Fixes
logging error spam.

Requires prometheus/procfs#308

Signed-off-by: Ben Kochie <superq@gmail.com>
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.

2 participants