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

NewInstanceCredentialsCache returns *aws.CredentialsCache #4431

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

tinnywang
Copy link
Contributor

Summary

Fix NewInstanceCredentialsCache so that it actually wraps the credentials provider in a credentials cache. This is a followup to #4424 (comment):

a9b6e6d updates the constructor to wrap the provider in a cache and renames InstanceCredentialsProvider to InstanceCredentialsCache.

As you can see in the code snippets below, the returned provider is not wrapped in a cache.

return &InstanceCredentialsCache{
providers: []aws.CredentialsProvider{
defaultCreds(options),
rotatingSharedCreds,
},
}

return &InstanceCredentialsCache{
providers: providers,
}

Implementation details

  • Rename InstanceCredentialsCache back to InstanceCredentialsProvider (but leave the constructor NewInstanceCredentialsCache because it returns a credentials cache).
  • Update NewInstanceCredentialsCache to wrap InstanceCredentialsProvider in a cache and return *aws.CredentialsCache.
return aws.NewCredentialsCache(&InstanceCredentialsProvider{...})
  • Change the type of the ecsAgent.credentialsCache field from aws.CredentialsProvider to *aws.CredentialsCache. Foresight has shown me that other parts of our codebase will use ecsAgent.credentialsCache and forcefully expire cached credentials, for which they'll need CredentialsCache.Invalidate. The aws.CredentialsProvider interface does not have an Invalidate method.

Testing

Github checks pass.

New tests cover the changes: no

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@tinnywang tinnywang marked this pull request as ready for review November 18, 2024 18:04
@tinnywang tinnywang requested a review from a team as a code owner November 18, 2024 18:04
@tinnywang tinnywang merged commit ee3bb78 into aws:dev Nov 18, 2024
40 checks passed
@tinnywang tinnywang deleted the fix-instance-creds branch November 18, 2024 21:52
prateekchaudhry added a commit to prateekchaudhry/amazon-ecs-agent that referenced this pull request Nov 18, 2024
prateekchaudhry added a commit that referenced this pull request Nov 19, 2024
JoseVillalta pushed a commit to JoseVillalta/amazon-ecs-agent that referenced this pull request Nov 21, 2024
JoseVillalta pushed a commit to JoseVillalta/amazon-ecs-agent that referenced this pull request Nov 21, 2024
tinnywang added a commit to tinnywang/amazon-ecs-agent that referenced this pull request Nov 25, 2024
tinnywang added a commit to tinnywang/amazon-ecs-agent that referenced this pull request Nov 27, 2024
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.

4 participants