slack: retry 429 errors (#2112)

Fix #2111

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
Julien Pivotto 2019-11-21 14:14:10 +01:00 committed by Simon Pasquier
parent 4ec53566e5
commit 26cc96a787
2 changed files with 4 additions and 2 deletions

View File

@ -49,7 +49,7 @@ func New(c *config.SlackConfig, t *template.Template, l log.Logger) (*Notifier,
tmpl: t,
logger: l,
client: client,
retrier: &notify.Retrier{},
retrier: &notify.Retrier{RetryCodes: []int{http.StatusTooManyRequests}},
}, nil
}

View File

@ -15,6 +15,7 @@ package slack
import (
"fmt"
"net/http"
"testing"
"github.com/go-kit/kit/log"
@ -35,7 +36,8 @@ func TestSlackRetry(t *testing.T) {
)
require.NoError(t, err)
for statusCode, expected := range test.RetryTests(test.DefaultRetryCodes()) {
retryCodes := append(test.DefaultRetryCodes(), http.StatusTooManyRequests)
for statusCode, expected := range test.RetryTests(retryCodes) {
actual, _ := notifier.retrier.Check(statusCode, nil)
require.Equal(t, expected, actual, fmt.Sprintf("error on status %d", statusCode))
}