From 26cc96a787b8b3b597a14fb7ced986194ae2c062 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Thu, 21 Nov 2019 14:14:10 +0100 Subject: [PATCH] slack: retry 429 errors (#2112) Fix #2111 Signed-off-by: Julien Pivotto --- notify/slack/slack.go | 2 +- notify/slack/slack_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/notify/slack/slack.go b/notify/slack/slack.go index 45a08719..8d083909 100644 --- a/notify/slack/slack.go +++ b/notify/slack/slack.go @@ -49,7 +49,7 @@ func New(c *config.SlackConfig, t *template.Template, l log.Logger) (*Notifier, tmpl: t, logger: l, client: client, - retrier: ¬ify.Retrier{}, + retrier: ¬ify.Retrier{RetryCodes: []int{http.StatusTooManyRequests}}, }, nil } diff --git a/notify/slack/slack_test.go b/notify/slack/slack_test.go index 2b77e63e..b5ebe641 100644 --- a/notify/slack/slack_test.go +++ b/notify/slack/slack_test.go @@ -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)) }