From 1176a5c7b27c6875c64fba877dcddcff4a5a8bd5 Mon Sep 17 00:00:00 2001 From: TJ Hoplock Date: Sun, 28 Jul 2024 14:54:24 -0400 Subject: [PATCH] fix: stop spamming error logs for disks without block dev queue stats not all devices have them. fixes errors such as this: ``` [root@testbox-arch /]# journalctl -ex -u mango.service --no-pager | grep -i 'no such' Jul 28 18:52:50 testbox-arch mango[79]: {"time":"2024-07-28T18:52:50.862645518Z","level":"ERROR","msg":"Failed to get queue stats for block device","hostname":{"system":"testbox-arch","inventory":"testbox-arch"},"worker":"manager","manager":{"inventory":"/opt/mango/inventory","hostname":"testbox-arch","enrolled":true,"runID":"01J3XB0DSDX99FXHCJ79JM2HGE"},"metadata_collector":"storage","err":"open /sys/block/zram0/queue/nr_requests: no such file or directory","device":"zram0"} Jul 28 18:52:52 testbox-arch mango[79]: {"time":"2024-07-28T18:52:52.922005911Z","level":"ERROR","msg":"Failed to get queue stats for block device","hostname":{"system":"testbox-arch","inventory":"testbox-arch"},"worker":"manager","manager":{"inventory":"/opt/mango/inventory","hostname":"testbox-arch","enrolled":true,"runID":"01J3XB0FSQ6BPT9FP6ZXMJ78GT"},"metadata_collector":"storage","err":"open /sys/block/zram0/queue/nr_requests: no such file or directory","device":"zram0"} Jul 28 18:52:54 testbox-arch mango[79]: {"time":"2024-07-28T18:52:54.975231863Z","level":"ERROR","msg":"Failed to get queue stats for block device","hostname":{"system":"testbox-arch","inventory":"testbox-arch"},"worker":"manager","manager":{"inventory":"/opt/mango/inventory","hostname":"testbox-arch","enrolled":true,"runID":"01J3XB0HSWH4Y8BTAWD04T4875"},"metadata_collector":"storage","err":"open /sys/block/zram0/queue/rq_affinity: no such file or directory","device":"zram0"} Jul 28 18:52:57 testbox-arch mango[79]: {"time":"2024-07-28T18:52:57.018631108Z","level":"ERROR","msg":"Failed to get queue stats for block device","hostname":{"system":"testbox-arch","inventory":"testbox-arch"},"worker":"manager","manager":{"inventory":"/opt/mango/inventory","hostname":"testbox-arch","enrolled":true,"runID":"01J3XB0KSQKTX1EK7MVDXT5VRB"},"metadata_collector":"storage","err":"open /sys/block/zram0/queue/rq_affinity: no such file or directory","device":"zram0"} ``` --- internal/manager/system_metadata.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/manager/system_metadata.go b/internal/manager/system_metadata.go index eba829d..c24460b 100644 --- a/internal/manager/system_metadata.go +++ b/internal/manager/system_metadata.go @@ -219,7 +219,8 @@ func getStorageMetadata(ctx context.Context, logger *slog.Logger) storageMetadat for _, blockDev := range blockDevs { blockDevPath := filepath.Join(blockDevDir, blockDev) qStats, err := fs.SysBlockDeviceQueueStats(blockDev) - if err != nil { + // block dev queue stats may not exist for all devices + if err != nil && !os.IsNotExist(err) { mdLogger.LogAttrs( ctx, slog.LevelError,