mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
remote: Convert to RecoverableError using errors.As (#12103)
In storage/remote, try converting to RecoverableError using errors.As, instead of through direct casting. Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
9afbb23d4a
commit
435b500de7
|
@ -109,10 +109,11 @@ func TestClientRetryAfter(t *testing.T) {
|
||||||
RetryOnRateLimit: false,
|
RetryOnRateLimit: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var recErr RecoverableError
|
||||||
|
|
||||||
c := getClient(conf)
|
c := getClient(conf)
|
||||||
err = c.Store(context.Background(), []byte{})
|
err = c.Store(context.Background(), []byte{})
|
||||||
_, ok := err.(RecoverableError)
|
require.False(t, errors.As(err, &recErr), "Recoverable error not expected.")
|
||||||
require.False(t, ok, "Recoverable error not expected.")
|
|
||||||
|
|
||||||
conf = &ClientConfig{
|
conf = &ClientConfig{
|
||||||
URL: &config_util.URL{URL: serverURL},
|
URL: &config_util.URL{URL: serverURL},
|
||||||
|
@ -122,8 +123,7 @@ func TestClientRetryAfter(t *testing.T) {
|
||||||
|
|
||||||
c = getClient(conf)
|
c = getClient(conf)
|
||||||
err = c.Store(context.Background(), []byte{})
|
err = c.Store(context.Background(), []byte{})
|
||||||
_, ok = err.(RecoverableError)
|
require.True(t, errors.As(err, &recErr), "Recoverable error was expected.")
|
||||||
require.True(t, ok, "Recoverable error was expected.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRetryAfterDuration(t *testing.T) {
|
func TestRetryAfterDuration(t *testing.T) {
|
||||||
|
|
|
@ -1569,8 +1569,8 @@ func sendWriteRequestWithBackoff(ctx context.Context, cfg config.QueueConfig, l
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the error is unrecoverable, we should not retry.
|
// If the error is unrecoverable, we should not retry.
|
||||||
backoffErr, ok := err.(RecoverableError)
|
var backoffErr RecoverableError
|
||||||
if !ok {
|
if !errors.As(err, &backoffErr) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue