-
Notifications
You must be signed in to change notification settings - Fork 36
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
Avoid retries on expired credentials #362
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add test cases in TestRetryHandlers
and awsv1shim.TestSessionRetryHandlers
to validate that the retries are cutting off when expected.
v2/awsv1shim/session.go
Outdated
@@ -145,6 +145,13 @@ func GetSession(ctx context.Context, awsC *awsv2.Config, c *awsbase.Config) (*se | |||
}) | |||
r.Retryable = aws.Bool(false) | |||
} | |||
|
|||
if r.IsErrorExpired() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a corresponding update to networkErrorShortcutter.RetryDelay
for calls using the AWS SDK for Go v2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed since V2 won't retry 403 Forbidden with standard retryer (not retryable and not in the list of errors to be retried).
259828e
to
c4d0ab0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🚀
Community Note
NOTE
Retrying 4xx errors was a bug that AWS fixed in AWS SDK for Go v2. Although this says it was fixed by #362, in reality the bulk of the problem was fixed when we moved to v2. Here, the only thing fixed involves the part of authentication that still takes place in v1, getting the session. Now, if you attempt to get a new session but receive an
Expired Token
error, it will not retry.Closes: #23
Closes: #363
Closes: hashicorp/terraform-provider-aws#6992
See also: hashicorp/terraform-provider-aws#29612 (using version with these changes)
To avoid retry/backoff causing long or terminal delays in reporting the expired credentials error, stop retrying when this error is encountered.
Note: #23 and hashicorp/terraform-provider-aws#6992 take the approach of adding a flag to avoid this retrying behavior. However, after discussions with the AWS Provider team, security, and a former AWS Provider engineer, there appears to be no situation in which an expired credential would ever become unexpired. In other words, long retrying efforts are a bug that can be fixed without adding a new flag (e.g.,
stop_on_expired_creds
).