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

Avoid retries on expired credentials #362

Merged
merged 5 commits into from
Feb 22, 2023
Merged

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented Feb 14, 2023

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

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).

@YakDriver YakDriver requested a review from a team as a code owner February 14, 2023 17:03
Copy link
Contributor

@gdavison gdavison left a 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 Show resolved Hide resolved
servicemocks/mock.go Outdated Show resolved Hide resolved
@@ -145,6 +145,13 @@ func GetSession(ctx context.Context, awsC *awsv2.Config, c *awsbase.Config) (*se
})
r.Retryable = aws.Bool(false)
}

if r.IsErrorExpired() {
Copy link
Contributor

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

Copy link
Member Author

@YakDriver YakDriver Feb 17, 2023

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).

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Should not retry expired credentials
2 participants