ci(lint): enable errorlint on storage (#12935)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL 2023-10-31 12:15:30 +01:00 committed by GitHub
parent 6722a5bb86
commit 1ec6e407d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View file

@ -38,9 +38,6 @@ issues:
- path: scrape/ - path: scrape/
linters: linters:
- errorlint - errorlint
- path: storage/
linters:
- errorlint
- path: tsdb/ - path: tsdb/
linters: linters:
- errorlint - errorlint

View file

@ -136,7 +136,7 @@ func TestClientRetryAfter(t *testing.T) {
err = c.Store(context.Background(), []byte{}, 0) err = c.Store(context.Background(), []byte{}, 0)
require.Equal(t, tc.expectedRecoverable, errors.As(err, &recErr), "Mismatch in expected recoverable error status.") require.Equal(t, tc.expectedRecoverable, errors.As(err, &recErr), "Mismatch in expected recoverable error status.")
if tc.expectedRecoverable { if tc.expectedRecoverable {
require.Equal(t, tc.expectedRetryAfter, err.(RecoverableError).retryAfter) require.Equal(t, tc.expectedRetryAfter, recErr.retryAfter)
} }
}) })
} }

View file

@ -15,6 +15,7 @@ package remote
import ( import (
"context" "context"
"errors"
"net/http" "net/http"
"strings" "strings"
"sync" "sync"
@ -169,7 +170,8 @@ func (h *readHandler) remoteReadSamples(
} }
return nil return nil
}(); err != nil { }(); err != nil {
if httpErr, ok := err.(HTTPError); ok { var httpErr HTTPError
if errors.As(err, &httpErr) {
http.Error(w, httpErr.Error(), httpErr.Status()) http.Error(w, httpErr.Error(), httpErr.Status())
return return
} }
@ -241,7 +243,8 @@ func (h *readHandler) remoteReadStreamedXORChunks(ctx context.Context, w http.Re
} }
return nil return nil
}(); err != nil { }(); err != nil {
if httpErr, ok := err.(HTTPError); ok { var httpErr HTTPError
if errors.As(err, &httpErr) {
http.Error(w, httpErr.Error(), httpErr.Status()) http.Error(w, httpErr.Error(), httpErr.Status())
return return
} }

View file

@ -66,9 +66,9 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
err = h.write(r.Context(), req) err = h.write(r.Context(), req)
switch err { switch {
case nil: case err == nil:
case storage.ErrOutOfOrderSample, storage.ErrOutOfBounds, storage.ErrDuplicateSampleForTimestamp: 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. // Indicated an out of order sample is a bad request to prevent retries.
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
@ -222,9 +222,9 @@ func (h *otlpWriteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Timeseries: prwMetrics, Timeseries: prwMetrics,
}) })
switch err { switch {
case nil: case err == nil:
case storage.ErrOutOfOrderSample, storage.ErrOutOfBounds, storage.ErrDuplicateSampleForTimestamp: 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. // Indicated an out of order sample is a bad request to prevent retries.
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return