🐛 fix: Clear credential cache on InvalidClientTokenId to allow retry on next reconcile - #6124
Conversation
|
@omargallob: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
|
|
Welcome @omargallob! |
|
Hi @omargallob. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
782eb7e to
7299254
Compare
7299254 to
2bf4d58
Compare
355ccd1 to
aa89ed0
Compare
aa89ed0 to
0a5438d
Compare
|
/kind bug |
|
@omargallob: the DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
what are the next steps? |
| } | ||
| return p.credentials.Retrieve(ctx) | ||
| result, err := p.credentials.Retrieve(ctx) | ||
| if err != nil && IsInvalidClientTokenIDError(err) { |
There was a problem hiding this comment.
So we'd still get an error in the logs but at least the cache is cleared and on the next reconcile it would work.
|
/test ? |
|
/test pull-cluster-api-provider-aws-e2e-eks |
9ee0702 to
61b50a9
Compare
61b50a9 to
b0e3966
Compare
b0e3966 to
9864e4e
Compare
9864e4e to
9878097
Compare
|
/test pull-cluster-api-provider-aws-e2e-eks |
|
Giving it a little bit more thought, I realized, while related my proposal is independent of this PR. I will create my own, to not polute this one. |
Which issue(s) this PR fixes (optional, in fixes #(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #6123
What this PR does
Clears the cached
*aws.CredentialsCacheinAWSRolePrincipalTypeProvider.Retrieve()when the error isInvalidClientTokenId, allowing the next controller-runtime reconcile loop to create a fresh credentials cache and retry theAssumeRolecall.Why this is needed
After the AWS SDK v1→v2 migration,
aws.NewCredentialsCachecaches failedAssumeRoleresults. When a freshly-created IAM access key has not yet propagated through AWS IAM eventual consistency, the firstAssumeRolecall fails withInvalidClientTokenId. Unlike SDK v1 whereIsExpired()returned true after failure (triggering a fresh attempt on the next reconcile), SDK v2'sCredentialsCacheretains the error.This causes the CAPA controller to be unable to recover from a transient IAM propagation delay for the lifetime of the provider instance (~50 minutes observed in production until KubeadmControlPlane timeout).
How it works
This restores the pre-SDK-migration behavior with minimal change.
Testing
InvalidClientTokenIdand subsequentRetrieve()succeedsIsInvalidClientTokenIDErrorhelper with typed and string-match cases/kind bug
AI Usage:
Checklist: