From a6a88a8114bc2dcbe2aa1906c31be538bf277065 Mon Sep 17 00:00:00 2001 From: Chris Broglie Date: Wed, 5 Jul 2017 16:01:03 -0700 Subject: [PATCH] Add retries for Kinesis throttling exceptions Ideally the AWS SDK would automatically retry these transient throttling exceptions, but it is currently unable to b/c the service is incorrectly using LimitExceededException for throttling. See https://github.com/aws/aws-sdk-go/issues/1376 for additional details. --- builtin/providers/aws/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index dd1149b910f4..91e571c1c655 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -382,6 +382,20 @@ func (c *Config) Client() (interface{}, error) { client.wafconn = waf.New(sess) client.wafregionalconn = wafregional.New(sess) + // Workaround for https://github.com/aws/aws-sdk-go/issues/1376 + client.kinesisconn.Handlers.Retry.PushBack(func(r *request.Request) { + if !strings.HasPrefix(r.Operation.Name, "Describe") && !strings.HasPrefix(r.Operation.Name, "List") { + return + } + err, ok := r.Error.(awserr.Error) + if !ok || err == nil { + return + } + if err.Code() == kinesis.ErrCodeLimitExceededException { + r.Retryable = aws.Bool(true) + } + }) + return &client, nil }