Skip to content

Commit 5869613

Browse files
authored
Merge pull request #361 from hashicorp/b-authentication-retry
Removes no-op retryer for authentication
2 parents 1f80358 + b71623d commit 5869613

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

aws_config.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,31 @@ func GetAwsConfig(ctx context.Context, c *Config) (context.Context, aws.Config,
6565
if err != nil {
6666
return ctx, aws.Config{}, err
6767
}
68+
69+
// The providers set `MaxRetries` to a very large value.
70+
// Add retries here so that authentication has a reasonable number of retries
71+
if c.MaxRetries != 0 {
72+
loadOptions = append(
73+
loadOptions,
74+
config.WithRetryMaxAttempts(c.MaxRetries),
75+
)
76+
}
77+
6878
loadOptions = append(
6979
loadOptions,
7080
config.WithCredentialsProvider(credentialsProvider),
7181
)
82+
7283
if initialSource == ec2rolecreds.ProviderName {
7384
loadOptions = append(
7485
loadOptions,
7586
config.WithEC2IMDSRegion(),
7687
)
7788
}
89+
7890
awsConfig, err := config.LoadDefaultConfig(baseCtx, loadOptions...)
7991
if err != nil {
80-
return ctx, awsConfig, fmt.Errorf("loading configuration: %w", err)
92+
return ctx, aws.Config{}, fmt.Errorf("loading configuration: %w", err)
8193
}
8294

8395
resolveRetryer(baseCtx, &awsConfig)
@@ -225,13 +237,6 @@ func commonLoadOptions(ctx context.Context, c *Config) ([]func(*config.LoadOptio
225237
config.WithEC2IMDSClientEnableState(c.EC2MetadataServiceEnableState),
226238
}
227239

228-
if c.MaxRetries != 0 {
229-
loadOptions = append(
230-
loadOptions,
231-
config.WithRetryMaxAttempts(c.MaxRetries),
232-
)
233-
}
234-
235240
if !c.SuppressDebugLog {
236241
loadOptions = append(
237242
loadOptions,

credentials.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ func getCredentialsProvider(ctx context.Context, c *Config) (aws.CredentialsProv
2626
}
2727
loadOptions = append(
2828
loadOptions,
29-
// Bypass retries when validating authentication
30-
config.WithRetryer(func() aws.Retryer {
31-
return aws.NopRetryer{}
32-
}),
3329
// The endpoint resolver is added here instead of in commonLoadOptions() so that it
3430
// is not included in the aws.Config returned to the caller
3531
config.WithEndpointResolverWithOptions(credentialsEndpointResolver(ctx, c)),

0 commit comments

Comments
 (0)