-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
aws/credentials: Fix race between credentials retrieval and expiration check #3448
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for taking the time to report and submit a change for this issue @danieler15. It looks like something in the test or run is causing the tests to get stuck and deadlock for several of the SDK versions/platforms. |
jasdel
added
the
needs-review
This issue or pull request needs review from a core team member.
label
Aug 11, 2020
Fixes aws#834 by adding read write locks to calls to the credentials provider's `IsExpired` method. Previously there was a race condition where the credentials could be refreshing, set the Provider's Expiry, while another goroutine is checking if the credentials are expired. In this case the second goroutine would receive the old credentials, incorrectly. This change also adds protection to GetWithContext that the check for if the credentials are not expired will not be blocked by the write mutex in the provider's Retrieve method. Incorporates some of the changes in aws#3563 to remove the atomic value around `creds`.
jasdel
force-pushed
the
credentials-fix
branch
from
October 20, 2020 00:31
23301b4
to
3308209
Compare
skmcgrail
approved these changes
Oct 20, 2020
jasdel
approved these changes
Oct 20, 2020
aws-sdk-go-automation
pushed a commit
that referenced
this pull request
Oct 21, 2020
=== ### Service Client Updates * `service/cloudfront`: Updates service API and documentation * CloudFront adds support for managing the public keys for signed URLs and signed cookies directly in CloudFront (it no longer requires the AWS root account). * `service/ec2`: Updates service API and documentation * instance-storage-info nvmeSupport added to DescribeInstanceTypes API * `service/globalaccelerator`: Updates service API and documentation * `service/glue`: Updates service API and documentation * AWS Glue crawlers now support incremental crawls for the Amazon Simple Storage Service (Amazon S3) data source. * `service/kendra`: Updates service API and documentation * This release adds custom data sources: a new data source type that gives you full control of the documents added, modified or deleted during a data source sync while providing run history metrics. * `service/organizations`: Updates service documentation * AWS Organizations renamed the 'master account' to 'management account'. ### SDK Bugs * `aws/credentials`: Fixed a race condition checking if credentials are expired. ([#3448](#3448)) * Fixes [#3524](#3524) * `internal/ini`: Fixes ini file parsing for cases when Right Hand Value is missed in the last statement of the ini file ([#3596](#3596)) * related to [#2800](#2800)
Merged
aws-sdk-go-automation
added a commit
that referenced
this pull request
Oct 21, 2020
Release v1.35.12 (2020-10-21) === ### Service Client Updates * `service/cloudfront`: Updates service API and documentation * CloudFront adds support for managing the public keys for signed URLs and signed cookies directly in CloudFront (it no longer requires the AWS root account). * `service/ec2`: Updates service API and documentation * instance-storage-info nvmeSupport added to DescribeInstanceTypes API * `service/globalaccelerator`: Updates service API and documentation * `service/glue`: Updates service API and documentation * AWS Glue crawlers now support incremental crawls for the Amazon Simple Storage Service (Amazon S3) data source. * `service/kendra`: Updates service API and documentation * This release adds custom data sources: a new data source type that gives you full control of the documents added, modified or deleted during a data source sync while providing run history metrics. * `service/organizations`: Updates service documentation * AWS Organizations renamed the 'master account' to 'management account'. ### SDK Bugs * `aws/credentials`: Fixed a race condition checking if credentials are expired. ([#3448](#3448)) * Fixes [#3524](#3524) * `internal/ini`: Fixes ini file parsing for cases when Right Hand Value is missed in the last statement of the ini file ([#3596](#3596)) * related to [#2800](#2800)
Thanks @jasdel for fixing this up and merging! I had spent some time trying to fix these tests awhile ago but then admittedly got distracted by other work. Glad to see this merged |
bdwyertech
added a commit
to bdwyertech/go-aws-cred-cachier
that referenced
this pull request
Oct 26, 2020
…tial expiration status - ref: aws/aws-sdk-go#3448 Signed-off-by: Brian Dwyer <Brian.Dwyer@broadridge.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I believe there is a race condition in the Credentials
GetWithContext()
method.When
Credentials
callsprovider.Retrieve()
from withinsingleRetrieve
, presumably the provider may update some internal state to reflect that the credentials it just returned fromRetrieve()
are not expired. This will cause subsequent calls toCredentials.isExpired()
to return false.However, there is a time between when
Credentials
callsprovider.Retrieve()
, and whenCredentials
actually stores the new credentials that it retrieved. If in this time, another goroutine tries toGet()
credentials, it will see that the provider is not expired, and return the old expired cached credentials. Hopefully the added test illustrates this scenario.I ran into this issue after upgrading the version of the sdk I was using. It seems that a RWMutex had been in use here but was removed in #3127