diff --git a/.golangci.yml b/.golangci.yml index 6e46812c8f..be24a6d25d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,9 +38,6 @@ issues: - path: scrape/ linters: - errorlint - - path: storage/ - linters: - - errorlint - path: tsdb/ linters: - errorlint diff --git a/storage/remote/client_test.go b/storage/remote/client_test.go index 9217e1c7e2..33ae7e4686 100644 --- a/storage/remote/client_test.go +++ b/storage/remote/client_test.go @@ -136,7 +136,7 @@ func TestClientRetryAfter(t *testing.T) { err = c.Store(context.Background(), []byte{}, 0) require.Equal(t, tc.expectedRecoverable, errors.As(err, &recErr), "Mismatch in expected recoverable error status.") if tc.expectedRecoverable { - require.Equal(t, tc.expectedRetryAfter, err.(RecoverableError).retryAfter) + require.Equal(t, tc.expectedRetryAfter, recErr.retryAfter) } }) } diff --git a/storage/remote/read_handler.go b/storage/remote/read_handler.go index e2702c9f77..3a99e3360c 100644 --- a/storage/remote/read_handler.go +++ b/storage/remote/read_handler.go @@ -15,6 +15,7 @@ package remote import ( "context" + "errors" "net/http" "strings" "sync" @@ -169,7 +170,8 @@ func (h *readHandler) remoteReadSamples( } return nil }(); err != nil { - if httpErr, ok := err.(HTTPError); ok { + var httpErr HTTPError + if errors.As(err, &httpErr) { http.Error(w, httpErr.Error(), httpErr.Status()) return } @@ -241,7 +243,8 @@ func (h *readHandler) remoteReadStreamedXORChunks(ctx context.Context, w http.Re } return nil }(); err != nil { - if httpErr, ok := err.(HTTPError); ok { + var httpErr HTTPError + if errors.As(err, &httpErr) { http.Error(w, httpErr.Error(), httpErr.Status()) return } diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index 6c0cd8a29b..a0dd3940e2 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -66,9 +66,9 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } err = h.write(r.Context(), req) - switch err { - case nil: - case storage.ErrOutOfOrderSample, storage.ErrOutOfBounds, storage.ErrDuplicateSampleForTimestamp: + switch { + case err == nil: + case errors.Is(err, storage.ErrOutOfOrderSample), errors.Is(err, storage.ErrOutOfBounds), errors.Is(err, storage.ErrDuplicateSampleForTimestamp): // Indicated an out of order sample is a bad request to prevent retries. http.Error(w, err.Error(), http.StatusBadRequest) return @@ -222,9 +222,9 @@ func (h *otlpWriteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Timeseries: prwMetrics, }) - switch err { - case nil: - case storage.ErrOutOfOrderSample, storage.ErrOutOfBounds, storage.ErrDuplicateSampleForTimestamp: + switch { + case err == nil: + case errors.Is(err, storage.ErrOutOfOrderSample), errors.Is(err, storage.ErrOutOfBounds), errors.Is(err, storage.ErrDuplicateSampleForTimestamp): // Indicated an out of order sample is a bad request to prevent retries. http.Error(w, err.Error(), http.StatusBadRequest) return