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/
linters:
- errorlint
- path: storage/
linters:
- errorlint
- path: tsdb/
linters:
- errorlint

View file

@ -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)
}
})
}

View file

@ -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
}

View file

@ -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