From b87cbf0294398738ccd60dbdd3754abc9f7f8726 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Mon, 25 Aug 2025 17:37:02 +0200 Subject: [PATCH] Fixup err nil checks Cleanup double `if` statements for errors being nil / not-nil. Signed-off-by: SuperQ --- tsdb/head.go | 3 +-- tsdb/head_wal.go | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tsdb/head.go b/tsdb/head.go index cd0f771f96..e3142e15a1 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -704,8 +704,7 @@ func (h *Head) Init(minValidTime int64) error { snapshotLoaded = true chunkSnapshotLoadDuration = time.Since(start) h.logger.Info("Chunk snapshot loading time", "duration", chunkSnapshotLoadDuration.String()) - } - if err != nil { + } else { snapIdx, snapOffset = -1, 0 refSeries = make(map[chunks.HeadSeriesRef]*memSeries) diff --git a/tsdb/head_wal.go b/tsdb/head_wal.go index 9b0982423f..b9fb992723 100644 --- a/tsdb/head_wal.go +++ b/tsdb/head_wal.go @@ -1443,12 +1443,10 @@ func (h *Head) performChunkSnapshot() error { startTime := time.Now() stats, err := h.ChunkSnapshot() elapsed := time.Since(startTime) - if err == nil { - h.logger.Info("chunk snapshot complete", "duration", elapsed.String(), "num_series", stats.TotalSeries, "dir", stats.Dir) - } if err != nil { return fmt.Errorf("chunk snapshot: %w", err) } + h.logger.Info("chunk snapshot complete", "duration", elapsed.String(), "num_series", stats.TotalSeries, "dir", stats.Dir) return nil }