From b7e89d24a4f37f9900f4e102369ad29c2f3fd5d9 Mon Sep 17 00:00:00 2001 From: TJ Hoplock Date: Fri, 17 May 2024 01:07:26 -0400 Subject: [PATCH] fix(template): block device queue stats path update + error checking The function will prepend the `/sys/block/` path in for us, so we don't need to use the joined path here, just the regular device name returned from the list function. Also, somehow, I wrote this so that the error log would always log, regardless of whether or not there was an error. It actually checks if the function errored now. :facepalm: --- internal/manager/system_metadata.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/manager/system_metadata.go b/internal/manager/system_metadata.go index f3d34bc..eba829d 100644 --- a/internal/manager/system_metadata.go +++ b/internal/manager/system_metadata.go @@ -218,15 +218,16 @@ func getStorageMetadata(ctx context.Context, logger *slog.Logger) storageMetadat var disks []disk for _, blockDev := range blockDevs { blockDevPath := filepath.Join(blockDevDir, blockDev) - - qStats, err := fs.SysBlockDeviceQueueStats(blockDevPath) - mdLogger.LogAttrs( - ctx, - slog.LevelError, - "Failed to get queue stats for block device", - slog.String("err", err.Error()), - slog.String("device", blockDev), - ) + qStats, err := fs.SysBlockDeviceQueueStats(blockDev) + if err != nil { + mdLogger.LogAttrs( + ctx, + slog.LevelError, + "Failed to get queue stats for block device", + slog.String("err", err.Error()), + slog.String("device", blockDev), + ) + } ssd := false if qStats.Rotational == 0 {