Skip to content

Commit

Permalink
Handle errors from disabled PSI subsystem
Browse files Browse the repository at this point in the history
When CONFIG_PSI_DEFAULT_DISABLED=y, the pressure system returns
"operation not supported", rather than permission denied or not
exposing the /proc/pressure files.

Fixes: #1961

Signed-off-by: Ben Kochie <superq@gmail.com>
  • Loading branch information
SuperQ committed Mar 2, 2021
1 parent e80863f commit 2841e44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* [ENHANCEMENT]
* [BUGFIX]

* [BUGFIX] Handle errors from disabled PSI subsystem

## 1.1.1 / 2021-02-12

* [BUGFIX] Fix ineffassign issue #1957
Expand Down
5 changes: 5 additions & 0 deletions collector/pressure_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"os"
"syscall"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
Expand Down Expand Up @@ -94,6 +95,10 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
return ErrNoData
}
if errors.Is(err, syscall.ENOTSUP) {
level.Debug(c.logger).Log("msg", "pressure information is disabled, add psi=1 kernel command line to enable it")
return ErrNoData
}
return fmt.Errorf("failed to retrieve pressure stats: %w", err)
}
switch res {
Expand Down

0 comments on commit 2841e44

Please sign in to comment.