Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk v2: Set RetryMaxAttempts on root config instead client options #1115

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions pkg/clients/v2/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func NewFactory(cfg config.ScrapeConf, fips bool, logger logging.Logger) (*Cachi
options = append(options, aws_config.WithUseFIPSEndpoint(aws.FIPSEndpointStateEnabled))
}

options = append(options, aws_config.WithRetryMaxAttempts(5))

c, err := aws_config.LoadDefaultConfig(context.TODO(), options...)
if err != nil {
return nil, fmt.Errorf("failed to load default aws config: %w", err)
Expand Down Expand Up @@ -272,6 +274,8 @@ func (c *CachingFactory) createCloudwatchClient(regionConfig *aws.Config) *cloud
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

// Setting an explicit retryer will override the default settings on the config
options.Retryer = retry.NewStandard(func(options *retry.StandardOptions) {
options.MaxAttempts = 5
options.MaxBackoff = 3 * time.Second
Comment on lines +277 to 281
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is not impacted by the upstream bug since it's using Retryer instead of RetryMaxAttempts but it's really hard to test if that's true.

Expand All @@ -284,8 +288,6 @@ func (c *CachingFactory) createTaggingClient(regionConfig *aws.Config) *resource
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -294,8 +296,6 @@ func (c *CachingFactory) createAutoScalingClient(assumedConfig *aws.Config) *aut
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -304,8 +304,6 @@ func (c *CachingFactory) createEC2Client(assumedConfig *aws.Config) *ec2.Client
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -314,8 +312,6 @@ func (c *CachingFactory) createDMSClient(assumedConfig *aws.Config) *databasemig
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -324,8 +320,6 @@ func (c *CachingFactory) createAPIGatewayClient(assumedConfig *aws.Config) *apig
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -334,8 +328,6 @@ func (c *CachingFactory) createAPIGatewayV2Client(assumedConfig *aws.Config) *ap
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -344,8 +336,6 @@ func (c *CachingFactory) createStorageGatewayClient(assumedConfig *aws.Config) *
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -354,8 +344,6 @@ func (c *CachingFactory) createPrometheusClient(assumedConfig *aws.Config) *amp.
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand All @@ -364,7 +352,6 @@ func (c *CachingFactory) createStsClient(awsConfig *aws.Config) *sts.Client {
if c.stsRegion != "" {
options.Region = c.stsRegion
}
options.RetryMaxAttempts = 5
})
}

Expand All @@ -373,8 +360,6 @@ func (c *CachingFactory) createShieldClient(awsConfig *aws.Config) *shield.Clien
if c.logger.IsDebugEnabled() {
options.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody
}

options.RetryMaxAttempts = 5
})
}

Expand Down