mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
ci(lint): enable errorlint on storage (#12935)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
6722a5bb86
commit
1ec6e407d0
|
@ -38,9 +38,6 @@ issues:
|
|||
- path: scrape/
|
||||
linters:
|
||||
- errorlint
|
||||
- path: storage/
|
||||
linters:
|
||||
- errorlint
|
||||
- path: tsdb/
|
||||
linters:
|
||||
- errorlint
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue