From 46d0a0813fa3cfed871088c7d20376e35cbe460a Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 1 Mar 2021 19:44:21 +0100 Subject: [PATCH] Handle errors from disabled PSI subsystem 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: https://github.com/prometheus/node_exporter/issues/1961 Signed-off-by: Ben Kochie --- CHANGELOG.md | 2 ++ collector/pressure_linux.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fff87d73..2cf6ec33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * [ENHANCEMENT] * [BUGFIX] +* [BUGFIX] Handle errors from disabled PSI subsystem #1983 + ## 1.1.1 / 2021-02-12 * [BUGFIX] Fix ineffassign issue #1957 diff --git a/collector/pressure_linux.go b/collector/pressure_linux.go index bd660451..ad81ad73 100644 --- a/collector/pressure_linux.go +++ b/collector/pressure_linux.go @@ -19,6 +19,7 @@ import ( "errors" "fmt" "os" + "syscall" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" @@ -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 {