From 6f4a0b4c9adbfb4bf1af248f4a8adfd33cf898eb Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Wed, 30 Apr 2025 14:47:28 +0100 Subject: [PATCH 1/2] Quick and dirty fix for duplicate volume metrics Same fix as in https://github.com/stackhpc/redfish_exporter/pull/6 --- collector/system_collector.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/collector/system_collector.go b/collector/system_collector.go index 9da3c70..ee2199c 100755 --- a/collector/system_collector.go +++ b/collector/system_collector.go @@ -242,6 +242,7 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { } else if storages == nil { systemLogContext.WithField("operation", "system.Storage()").Info("no storage data found") } else { + processed := make(map[string]bool) for _, storage := range storages { if volumes, err := storage.Volumes(); err != nil { systemLogContext.WithField("operation", "system.Volumes()").WithError(err).Error("error getting storage data from system") @@ -249,7 +250,18 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { wg3.Add(len(volumes)) for _, volume := range volumes { + _, exists := processed[volume.Name] + if exists { + systemLogContext.WithField("operation", + "system.Storage()").Info(fmt.Sprintf("Ignoring "+ + "duplicate storage volume: %s. Please check whether this "+ + "volume is returning duplicate data and report to the vendor.", + volume.Name)) + wg3.Done() + continue + } go parseVolume(ch, systemHostName, volume, wg3) + processed[volume.Name] = true } } @@ -347,7 +359,7 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { } else if simpleStorages == nil { systemLogContext.WithField("operation", "system.SimpleStorages()").Info("no simple storage data found") } else { - processed := make(map[string]bool) + processed := make(map[string]bool) for _, simpleStorage := range simpleStorages { devices := simpleStorage.Devices wg8.Add(len(devices)) @@ -355,14 +367,14 @@ func (s *SystemCollector) Collect(ch chan<- prometheus.Metric) { _, exists := processed[device.Name] if exists { systemLogContext.WithField("operation", - "system.SimpleStorages()").Info(fmt.Sprintf("Ignoring " + - "duplicate storage device: %s. Please check whether this " + - "device is returning duplicate data and report to the vendor.", - device.Name)) + "system.SimpleStorages()").Info(fmt.Sprintf("Ignoring "+ + "duplicate storage device: %s. Please check whether this "+ + "device is returning duplicate data and report to the vendor.", + device.Name)) wg8.Done() continue } - go parseDevice(ch, systemHostName, device, wg8) + go parseDevice(ch, systemHostName, device, wg8) processed[device.Name] = true } } From d56a725d9fd09af005fb47b81772506368fbc67d Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Wed, 30 Apr 2025 15:47:21 +0100 Subject: [PATCH 2/2] Bump golang version Builds were failing with the rc-bullseye release: 0.525 /go/src/github.com/stackhpc/redfish_exporter/go.mod:5: unknown directive: toolchain 0.526 make: *** [Makefile:35: build] Error 1 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a3d68b..a4a6232 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:rc-bullseye AS builder +FROM golang:1.24.2 AS builder LABEL maintainer="Jennings Liu " @@ -17,7 +17,7 @@ RUN mkdir -p /go/src/github.com/ && \ cd /go/src/github.com/jenningsloy318/redfish_exporter && \ make build -FROM golang:rc-bullseye +FROM golang:1.24.2 COPY --from=builder /go/src/github.com/jenningsloy318/redfish_exporter/build/redfish_exporter /usr/local/bin/redfish_exporter RUN mkdir /etc/prometheus