mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -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,
|
||||
}
|
||||
|
||||
var recErr RecoverableError
|
||||
|
||||
c := getClient(conf)
|
||||
err = c.Store(context.Background(), []byte{})
|
||||
_, ok := err.(RecoverableError)
|
||||
require.False(t, ok, "Recoverable error not expected.")
|
||||
require.False(t, errors.As(err, &recErr), "Recoverable error not expected.")
|
||||
|
||||
conf = &ClientConfig{
|
||||
URL: &config_util.URL{URL: serverURL},
|
||||
|
@ -122,8 +123,7 @@ func TestClientRetryAfter(t *testing.T) {
|
|||
|
||||
c = getClient(conf)
|
||||
err = c.Store(context.Background(), []byte{})
|
||||
_, ok = err.(RecoverableError)
|
||||
require.True(t, ok, "Recoverable error was expected.")
|
||||
require.True(t, errors.As(err, &recErr), "Recoverable error was expected.")
|
||||
}
|
||||
|
||||
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.
|
||||
backoffErr, ok := err.(RecoverableError)
|
||||
if !ok {
|
||||
var backoffErr RecoverableError
|
||||
if !errors.As(err, &backoffErr) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue