From 75d94466d4e0f391f4006e80fc70b6e63f15f793 Mon Sep 17 00:00:00 2001 From: "shenpeng.sp0916" Date: Thu, 14 May 2026 16:51:25 +0800 Subject: [PATCH] fix(collector): handle EINVAL errors from thermal_zone gracefully When running node_exporter in Docker on some embedded devices, reading thermal_zone temp files can return EINVAL (invalid argument) errors. These were previously not handled, causing the entire thermal_zone collector to fail. Add syscall.EINVAL to the list of errors that cause the collector to return ErrNoData instead of failing entirely. Fixes #2980 Signed-off-by: shenpeng.sp0916 --- collector/thermal_zone_linux.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/collector/thermal_zone_linux.go b/collector/thermal_zone_linux.go index a50278e998..c7c58c29b3 100644 --- a/collector/thermal_zone_linux.go +++ b/collector/thermal_zone_linux.go @@ -20,6 +20,7 @@ import ( "fmt" "log/slog" "os" + "syscall" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/procfs/sysfs" @@ -71,7 +72,7 @@ func NewThermalZoneCollector(logger *slog.Logger) (Collector, error) { func (c *thermalZoneCollector) Update(ch chan<- prometheus.Metric) error { thermalZones, err := c.fs.ClassThermalZoneStats() if err != nil { - if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrInvalid) { + if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrInvalid) || errors.Is(err, syscall.EINVAL) { c.logger.Debug("Could not read thermal zone stats", "err", err) return ErrNoData }