mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34: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/
|
- path: scrape/
|
||||||
linters:
|
linters:
|
||||||
- errorlint
|
- errorlint
|
||||||
- path: storage/
|
|
||||||
linters:
|
|
||||||
- errorlint
|
|
||||||
- path: tsdb/
|
- path: tsdb/
|
||||||
linters:
|
linters:
|
||||||
- errorlint
|
- errorlint
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue