-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Refresh AWS credentials asynchronously #2642
Conversation
@alextwoods here's the PR discussing the idea. A few questions... for some reason I had trouble getting the tests to run locally 😢 Even when I removed my code and tried to run some tests via
|
You should be able to run all of the tests with |
As a heads up - I'm working on a few other related changes that will touch some of the Refreshing Credential providers so we'll likely hold off on actually merging this until it can be incorporated with those changes. |
There are a few concerns I want to see if we can think through:
(Just to be clear - I don't expect you to answer all of those questions - I just want us to think through all of them). |
As an aside (I'll take some time to think of the things you mentioned as well above!) -- thanks for helping with the test run. I was following the doc here for running unit tests. But once I switched over to running There are other ways of doing this like |
Hey Alex, here are my thoughts (of course y'all have more handle on this than I do 🙂) I'll take some more to think and also please hijack the code if you'd like to as well.
This makes sense 👌🏽 My understanding of this credentials API is that there is latency cost based on availability. Given the worst case if the availability zones are down, I imagine that the asynchronous thread can timeout on its call to refresh depending on region. Another case: if for any reason an exception raises, this would get handled in the thread but not the main thread. In these cases we should also have a stopgap blocking mechanism, like a near-er expiration? (1 minute? not sure). For example if t1 executing the async credentials fetch What about keeping the current behavior and then having something like:
If the background thread fails to fetch a credential, we'll keep trying and failing for subsequent calls of
I think the top solution will address this, right? We kick off a background thread and if it doesn't finish in time, we'll have the synchronous process block and also make the call to fetch credentials for the initialization. To outline:
Not 100% sure -- but I think that since we are duplicating the code, we should be safe since the One spot I see a potential performance impact that I feel is hard to measure, is the initial fetch for credentials. I might have to do more thinking here, but there is a penalty to the main thread blocking just a tiny bit for the async thread to finish. That said, it's not too much since we check
I added some unit tests 🤔 but I'll try to do some more thinking as well. |
Yeah - I was thinking something along those lines - an async refresh if outside some TBD time (10 minutes seems reasonable) and sync within the current 5 minutes (to minimize impact of the change). Another edge case we need to handle correctly here - if the async process runs into an error and, for whatever reason, cannot refresh the credentials, it needs to NOT update the credentials (ie, the current ones are not expired, so don't clear them). This behavior may differ per credential provider. As an example of where this would be an issue: The |
Sounds good, I'll take a stab doing a 10 min async check, then 5 min sync check. Like I said, feel free to steamroll this whenever you want / need Alex -- don't want to block any initiatives that y'all may have. I'll commit to doing this in my spare time since I have my day job a well, but I'm happy (and learning!) along the ride 😁 It looks like some tests are failing so it's going to take me awhile to debug (gotta set up those old ruby environments!), at first glance looks like some of the requests were attempted rather than mocked 🤔
This one sounds interesting, I'll see if there's something we can do like pass a default flag into the Couple edits later...
I'll re-visit this tomorrow with some fresher thoughts -- took quite a bit to get my mac set up 🤦🏽♂️ |
I'm having a little trouble with replicating some of the tests in my local environment that are failing on CI (ruby3 tests seem to be busting on the main branch right now so ignoring those). Additionally if you had any idea on what's a good way to test the (Surprise surprise I managed to get some of them failing intermittently now 😂) |
Any setup bits we should add to the README to help others? Yeah - Ruby 3+ tests are currently failing due to rspec-mocks 3.10.3, so fair to ignore those. I can take some time today to dig into the issues. I've got a few thoughts on how to address some new issues I've come up with. I think we may want some mechanism for RefreshingCredential implementations to "opt-in" to background refresh behavior - I think there may be some cases (eg ProcessCredentials or custom, user implementations) where we don't want the async refresh, or we don't know enough about the behavior of the refresh method (ie, the behavior of InstanceProfileCredentials to set credentials to empty when it encounters an error needs to be changed for this to work). |
Sounds good.
I can probably spin up a small PR to update As for the tests -- looking closer! Last night I knew those were breaking and didn't get to address it because I needed to think through it more. I wasn't 100% sure why extra calls were being made, but my suspicion is that because we have:
the spec is exercising and doing both, however in some cases, the thread might not be finished with making its
I'll mull this over a bit and see what can be done 🙂 |
I also think we may want to ensure that the initial credential refresh/fetch is synchronous. Long term/in a new major version of the SDK, I'd love to move to a more promise/lazy evaluation of credentials, but the current SDK makes a lot of assumptions around this - I can take a stab at that change as well - and I think that should also fix a lot of the unit test issues. |
Alrighty, I tried reverting some of the changes and whatnot. Thanks as usual for having to re-run the workflow. Happy to accept feedback as usual and appreciate the time you've been taking to do this 🙂 |
Avoid creaing a thread for the background sync unless mutex is free and we're in the async window.
I pushed a small change - I tweaked the order the refreshing was checked in. It starts by first checking if we are within the sync window and then blocking (the old behavior). Otherwise, if async is supported, its inside the async window and the mutex is unlocked, we kick off the thread. This should preserve as much of the old behavior as possible and avoid creating threads unless we're actually going to refresh. Note - this also fixes some of the test changes that were required. |
Awesome - that makes sense 🙇🏽♂️ , thanks so much for helping with that last change. And appreciate the newfound knowledge of |
Yeah - I think we're pretty close on the change, but I'm also working on some other, semi-related changes that touch refreshing credentials and want to wait to merge this until that work is complete. |
@alextwoods @mullermp 🏓 -- is this PR good to merge? I don't have anymore updates, but I do see other credential PRs so just wanted to bump it again! |
@danielvdao - I think this PR is in a good place, but there are still some other refreshing credential changes in the pipeline (no PR's available for them yet) that should be completed in the next couple of weeks that I want to get in before we merge this on top of them. |
Hey @alextwoods -- no rush, but want to check back in on this PR! We're running a fork of the gem with my branch on it and there hasn't been any problems for the past two weeks now - so wondering if it's good to merge? If so, I / or maybe y'all can rebase + address any conflicts (though nothing seems too jarring). I haven't dived deeply into tail-end performance improvements, but my hypothesis is that there must be a few. |
Hey - sorry for the delay on this - the other credential related project I was working on has been delayed, so I'll look at addressing merge conflicts, doing a final review/test and merge this week. |
Perfect, thanks so much Alex. Looking forward to getting this through the line! |
Edit: other credentials work was unblocked and we were able to get the required PR out, see #2673. This changes a few things about the way IMDS credentials are refreshed and managed - I'll spend some time this week updating this PR for that change. |
Woohoo! Thanks for the update Alex. |
I've merged the other credential provider changes - I think this is about ready to go, I'm just doing a final review. |
Hey Alex, was curious on the status of this again. I know you mentioned you were reviewing though, so I'm curious if you caught anything during the review! |
Final round of testing looks good - I'll merge and release this! Great work on this, its a great improvement. |
commit ea8313d Author: AWS SDK for Ruby <[email protected]> Date: Tue Jul 26 18:06:29 2022 +0000 Updated API models and rebuilt service gems. commit 485d4a7 Author: Alex Woods <[email protected]> Date: Mon Jul 25 12:34:42 2022 -0700 Fix failing lambda integration test commit de6d938 Author: AWS SDK for Ruby <[email protected]> Date: Mon Jul 25 18:10:32 2022 +0000 Updated API models and rebuilt service gems. commit 831bd38 Author: Matt Muller <[email protected]> Date: Fri Jul 22 15:26:43 2022 -0400 Fix lambda test from breaking change commit 348270a Author: AWS SDK for Ruby <[email protected]> Date: Fri Jul 22 18:08:58 2022 +0000 Updated API models and rebuilt service gems. commit 5a52104 Author: AWS SDK for Ruby <[email protected]> Date: Thu Jul 21 18:06:02 2022 +0000 Updated API models and rebuilt service gems. commit 6ba1c69 Author: AWS SDK for Ruby <[email protected]> Date: Wed Jul 20 18:04:59 2022 +0000 Updated API models and rebuilt service gems. commit 91b7cd4 Author: AWS SDK for Ruby <[email protected]> Date: Tue Jul 19 18:03:24 2022 +0000 Updated API models and rebuilt service gems. commit b6c326b Author: Alex Woods <[email protected]> Date: Tue Jul 19 08:19:11 2022 -0700 Fix performance regression when checking if `aws-crt` is available. (#2730) commit bcea350 Author: AWS SDK for Ruby <[email protected]> Date: Mon Jul 18 18:09:51 2022 +0000 Updated API models and rebuilt service gems. commit ee96470 Author: Alex Woods <[email protected]> Date: Mon Jul 18 09:10:52 2022 -0700 Add support for serializing shapes on the body with jsonvalue members. (#2727) commit 8ee8aa0 Author: AWS SDK for Ruby <[email protected]> Date: Fri Jul 15 18:05:05 2022 +0000 Updated API models and rebuilt service gems. commit 07da11c Author: AWS SDK for Ruby <[email protected]> Date: Thu Jul 14 18:10:25 2022 +0000 Updated API models and rebuilt service gems. commit c0e5d95 Author: AWS SDK for Ruby <[email protected]> Date: Wed Jul 13 18:25:00 2022 +0000 Updated API models and rebuilt service gems. commit 397916b Author: AWS SDK for Ruby <[email protected]> Date: Tue Jul 12 18:35:09 2022 +0000 Updated API models and rebuilt service gems. commit aa557ed Author: AWS SDK for Ruby <[email protected]> Date: Mon Jul 11 18:08:56 2022 +0000 Updated API models and rebuilt service gems. commit a4e47ca Author: AWS SDK for Ruby <[email protected]> Date: Fri Jul 8 18:05:07 2022 +0000 Updated API models and rebuilt service gems. commit fb5c80a Author: Matt Muller <[email protected]> Date: Thu Jul 7 19:22:25 2022 -0400 Support jsonvalue on shapes (#2725) commit 15a9f7c Author: AWS SDK for Ruby <[email protected]> Date: Thu Jul 7 18:05:44 2022 +0000 Updated API models and rebuilt service gems. commit 1a33835 Author: AWS SDK for Ruby <[email protected]> Date: Wed Jul 6 18:03:46 2022 +0000 Updated API models and rebuilt service gems. commit 1e122b9 Author: Alex Woods <[email protected]> Date: Wed Jul 6 08:39:39 2022 -0700 Remove old redshiftserverless APIs. Service now uses "redshift-serverless" models. commit 8f40db9 Author: AWS SDK for Ruby <[email protected]> Date: Tue Jul 5 18:09:44 2022 +0000 Updated API models and rebuilt service gems. commit c2cf749 Author: AWS SDK for Ruby <[email protected]> Date: Fri Jul 1 18:05:22 2022 +0000 Updated API models and rebuilt service gems. commit d9e211e Author: AWS SDK for Ruby <[email protected]> Date: Thu Jun 30 18:06:18 2022 +0000 Updated API models and rebuilt service gems. commit 2551a64 Author: AWS SDK for Ruby <[email protected]> Date: Wed Jun 29 18:06:35 2022 +0000 Updated API models and rebuilt service gems. commit f794a0e Author: AWS SDK for Ruby <[email protected]> Date: Tue Jun 28 18:04:56 2022 +0000 Updated API models and rebuilt service gems. commit 42ece6f Author: AWS SDK for Ruby <[email protected]> Date: Mon Jun 27 18:04:07 2022 +0000 Updated API models and rebuilt service gems. commit bcec4ff Author: AWS SDK for Ruby <[email protected]> Date: Fri Jun 24 18:07:58 2022 +0000 Updated API models and rebuilt service gems. commit 1b4f65a Author: AWS SDK for Ruby <[email protected]> Date: Thu Jun 23 18:08:31 2022 +0000 Updated API models and rebuilt service gems. commit 76fb601 Author: AWS SDK for Ruby <[email protected]> Date: Wed Jun 22 18:04:14 2022 +0000 Updated API models and rebuilt service gems. commit 1de93df Author: AWS SDK for Ruby <[email protected]> Date: Tue Jun 21 18:04:18 2022 +0000 Updated API models and rebuilt service gems. commit ea8ed9f Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Jun 20 13:45:04 2022 -0700 Bump actions/dependency-review-action from 1 to 2 (#2717) commit 31ba848 Author: AWS SDK for Ruby <[email protected]> Date: Mon Jun 20 18:03:49 2022 +0000 Updated API models and rebuilt service gems. commit 2b09dc7 Author: Matt Muller <[email protected]> Date: Mon Jun 20 12:13:03 2022 -0400 Parse request_id in XML handler (#2716) commit d686636 Author: AWS SDK for Ruby <[email protected]> Date: Fri Jun 17 18:05:10 2022 +0000 Updated API models and rebuilt service gems. commit e9b64bb Author: AWS SDK for Ruby <[email protected]> Date: Thu Jun 16 19:35:59 2022 +0000 Updated API models and rebuilt service gems. commit 6957319 Author: Matt Muller <[email protected]> Date: Thu Jun 16 15:29:05 2022 -0400 Bump Redshift Serverless commit 0534b27 Author: AWS SDK for Ruby <[email protected]> Date: Thu Jun 16 18:05:17 2022 +0000 Updated API models and rebuilt service gems. commit 2a3d5ee Author: AWS SDK for Ruby <[email protected]> Date: Wed Jun 15 19:25:13 2022 +0000 Updated API models and rebuilt service gems. commit 215bd91 Author: AWS SDK for Ruby <[email protected]> Date: Tue Jun 14 18:22:41 2022 +0000 Updated API models and rebuilt service gems. commit 355b07a Author: Matt Muller <[email protected]> Date: Tue Jun 14 13:18:25 2022 -0400 Handle rip service name metadata key commit 463c054 Author: AWS SDK for Ruby <[email protected]> Date: Mon Jun 13 18:46:25 2022 +0000 Updated API models and rebuilt service gems. commit 5632933 Author: Andrey "Zed" Zaikin <[email protected]> Date: Sat Jun 11 01:16:09 2022 +0300 Update 01_filtering_by_tags_examples.rb (#2713) fix example description mismatching example code commit 513b532 Author: AWS SDK for Ruby <[email protected]> Date: Fri Jun 10 18:33:33 2022 +0000 Updated API models and rebuilt service gems. commit ef41db7 Author: Alex Woods <[email protected]> Date: Thu Jun 9 15:57:44 2022 -0700 Remove redshiftserverless (#2712) * Remove dependency on aws-sdk-redshiftserverless * Changelog/version * Remove references to redshift-serverless commit 7388657 Author: Alex Woods <[email protected]> Date: Thu Jun 9 15:38:20 2022 -0700 Remove dependency on aws-sdk-redshiftserverless (#2711) commit 60fa12f Author: AWS SDK for Ruby <[email protected]> Date: Thu Jun 9 18:08:04 2022 +0000 Updated API models and rebuilt service gems. commit 818029b Author: AWS SDK for Ruby <[email protected]> Date: Wed Jun 8 19:44:27 2022 +0000 Updated API models and rebuilt service gems. commit 5cb80a8 Author: AWS SDK for Ruby <[email protected]> Date: Tue Jun 7 18:03:27 2022 +0000 Updated API models and rebuilt service gems. commit 448a4f3 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Jun 6 14:57:41 2022 -0700 Bump aws-actions/stale-issue-cleanup from 3 to 5 (#2709) commit f349fe0 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Jun 6 14:57:30 2022 -0700 Bump actions/checkout from 2 to 3 (#2708) commit d130887 Author: Naveen <[email protected]> Date: Mon Jun 6 16:41:53 2022 -0500 chore(deps): Included dependency review (#2704) commit 0365a6b Author: Naveen <[email protected]> Date: Mon Jun 6 16:41:34 2022 -0500 chore: Included githubactions in the dependabot config (#2703) commit e07e125 Author: AWS SDK for Ruby <[email protected]> Date: Mon Jun 6 18:21:58 2022 +0000 Updated API models and rebuilt service gems. commit 584e394 Author: AWS SDK for Ruby <[email protected]> Date: Thu Jun 2 18:12:43 2022 +0000 Updated API models and rebuilt service gems. commit a325020 Author: AWS SDK for Ruby <[email protected]> Date: Wed Jun 1 18:06:27 2022 +0000 Updated API models and rebuilt service gems. commit 0234aaa Author: AWS SDK for Ruby <[email protected]> Date: Tue May 31 18:35:00 2022 +0000 Updated API models and rebuilt service gems. commit 821508e Author: neilnaveen <[email protected]> Date: Tue May 31 11:10:22 2022 -0500 chore: Set permissions for GitHub actions (#2700) Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much. - Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) Signed-off-by: neilnaveen <[email protected]> commit afb1625 Author: AWS SDK for Ruby <[email protected]> Date: Fri May 27 18:14:56 2022 +0000 Updated API models and rebuilt service gems. commit ce784b0 Author: Alex Woods <[email protected]> Date: Thu May 26 18:34:33 2022 -0700 Remove emrserverlesswebservice from services.json commit 69b0369 Author: Alex Woods <[email protected]> Date: Thu May 26 18:32:11 2022 -0700 Fix Changelog commit 386113f Author: Alex Woods <[email protected]> Date: Thu May 26 18:28:26 2022 -0700 Remove emrserverlesswebservice from gems (#2702) commit a1a7f7a Author: Alex Woods <[email protected]> Date: Thu May 26 18:23:42 2022 -0700 Remove emrserverlesswebservice gem from resources. (#2701) commit 11e1933 Author: AWS SDK for Ruby <[email protected]> Date: Thu May 26 18:05:27 2022 +0000 Updated API models and rebuilt service gems. commit 00bcccd Author: AWS SDK for Ruby <[email protected]> Date: Wed May 25 18:06:57 2022 +0000 Updated API models and rebuilt service gems. commit 49c6072 Author: AWS SDK for Ruby <[email protected]> Date: Tue May 24 18:05:25 2022 +0000 Updated API models and rebuilt service gems. commit 85e39d6 Author: AWS SDK for Ruby <[email protected]> Date: Mon May 23 18:07:05 2022 +0000 Updated API models and rebuilt service gems. commit 96f2252 Author: AWS SDK for Ruby <[email protected]> Date: Fri May 20 18:14:08 2022 +0000 Updated API models and rebuilt service gems. commit 3058e8b Author: Matt Muller <[email protected]> Date: Fri May 20 08:48:02 2022 -0700 Bump jmespath version (#2699) commit 07a942b Author: AWS SDK for Ruby <[email protected]> Date: Thu May 19 18:17:26 2022 +0000 Updated API models and rebuilt service gems. commit 62c48f3 Author: AWS SDK for Ruby <[email protected]> Date: Wed May 18 18:04:46 2022 +0000 Updated API models and rebuilt service gems. commit 0c39b0b Author: AWS SDK for Ruby <[email protected]> Date: Tue May 17 18:03:24 2022 +0000 Updated API models and rebuilt service gems. commit 24b4999 Author: AWS SDK for Ruby <[email protected]> Date: Mon May 16 18:04:51 2022 +0000 Updated API models and rebuilt service gems. commit 78393ae Author: AWS SDK for Ruby <[email protected]> Date: Fri May 13 18:05:00 2022 +0000 Updated API models and rebuilt service gems. commit 08b284d Author: AWS SDK for Ruby <[email protected]> Date: Thu May 12 18:07:23 2022 +0000 Updated API models and rebuilt service gems. commit 3e71011 Author: AWS SDK for Ruby <[email protected]> Date: Wed May 11 18:04:38 2022 +0000 Updated API models and rebuilt service gems. commit da976e6 Author: AWS SDK for Ruby <[email protected]> Date: Tue May 10 18:03:28 2022 +0000 Updated API models and rebuilt service gems. commit a9e468b Author: AWS SDK for Ruby <[email protected]> Date: Mon May 9 18:05:29 2022 +0000 Updated API models and rebuilt service gems. commit f423c23 Author: AWS SDK for Ruby <[email protected]> Date: Fri May 6 18:05:39 2022 +0000 Updated API models and rebuilt service gems. commit ba46932 Author: AWS SDK for Ruby <[email protected]> Date: Thu May 5 18:31:05 2022 +0000 Updated API models and rebuilt service gems. commit f3be4c2 Author: AWS SDK for Ruby <[email protected]> Date: Wed May 4 18:04:48 2022 +0000 Updated API models and rebuilt service gems. commit cc1292c Author: AWS SDK for Ruby <[email protected]> Date: Tue May 3 20:59:01 2022 +0000 Updated API models and rebuilt service gems. commit b539e47 Author: AWS SDK for Ruby <[email protected]> Date: Mon May 2 18:04:45 2022 +0000 Updated API models and rebuilt service gems. commit cc85c8c Author: Matt Muller <[email protected]> Date: Mon May 2 09:16:07 2022 -0700 Parse region from a queue url more strictly (#2697) commit d2c17e0 Author: AWS SDK for Ruby <[email protected]> Date: Fri Apr 29 18:03:51 2022 +0000 Updated API models and rebuilt service gems. commit 7a92598 Author: AWS SDK for Ruby <[email protected]> Date: Thu Apr 28 18:06:16 2022 +0000 Updated API models and rebuilt service gems. commit 28a08b1 Author: AWS SDK for Ruby <[email protected]> Date: Wed Apr 27 18:07:40 2022 +0000 Updated API models and rebuilt service gems. commit 257415e Author: AWS SDK for Ruby <[email protected]> Date: Tue Apr 26 18:07:15 2022 +0000 Updated API models and rebuilt service gems. commit dedfbdc Author: Matt Muller <[email protected]> Date: Mon Apr 25 13:54:20 2022 -0700 Improve credential documentation and expired token error raising (#2694) commit c57a693 Author: AWS SDK for Ruby <[email protected]> Date: Mon Apr 25 18:04:35 2022 +0000 Updated API models and rebuilt service gems. commit 2f8c918 Author: Alex Woods <[email protected]> Date: Mon Apr 25 09:40:18 2022 -0700 Remove puts commit 2bd88e8 Author: Alex Woods <[email protected]> Date: Mon Apr 25 09:32:51 2022 -0700 Fix duplicated bytes in streaming retries (#2693) commit 13f7aaa Author: AWS SDK for Ruby <[email protected]> Date: Fri Apr 22 18:08:30 2022 +0000 Updated API models and rebuilt service gems. commit f5c29fc Author: Alex Woods <[email protected]> Date: Thu Apr 21 13:09:13 2022 -0700 Remove before_refresh from client construction in RefreshingCredentials (#2691) commit 0ac3d0a Author: AWS SDK for Ruby <[email protected]> Date: Thu Apr 21 18:05:20 2022 +0000 Updated API models and rebuilt service gems. commit 7859eee Author: AWS SDK for Ruby <[email protected]> Date: Wed Apr 20 18:05:31 2022 +0000 Updated API models and rebuilt service gems. commit c9d2151 Author: Alex Woods <[email protected]> Date: Wed Apr 20 08:42:02 2022 -0700 Add CRT Signers to aws-sigv4 (#2688) commit 70e0e6a Author: AWS SDK for Ruby <[email protected]> Date: Tue Apr 19 18:06:52 2022 +0000 Updated API models and rebuilt service gems. commit 20468f1 Author: AWS SDK for Ruby <[email protected]> Date: Fri Apr 15 18:06:25 2022 +0000 Updated API models and rebuilt service gems. commit 386f077 Author: AWS SDK for Ruby <[email protected]> Date: Thu Apr 14 18:04:27 2022 +0000 Updated API models and rebuilt service gems. commit efcd8f2 Author: AWS SDK for Ruby <[email protected]> Date: Wed Apr 13 18:04:01 2022 +0000 Updated API models and rebuilt service gems. commit b85d044 Author: AWS SDK for Ruby <[email protected]> Date: Tue Apr 12 18:53:06 2022 +0000 Updated API models and rebuilt service gems. commit 2c58c2a Author: Ashique P S <[email protected]> Date: Tue Apr 12 23:57:35 2022 +0530 Fixed the invocation of refresh! method on SharedCredentials (#2686) commit 3e79476 Author: AWS SDK for Ruby <[email protected]> Date: Mon Apr 11 18:03:52 2022 +0000 Updated API models and rebuilt service gems. commit ccfb26b Author: AWS SDK for Ruby <[email protected]> Date: Fri Apr 8 18:05:43 2022 +0000 Updated API models and rebuilt service gems. commit f22e986 Author: AWS SDK for Ruby <[email protected]> Date: Thu Apr 7 18:10:30 2022 +0000 Updated API models and rebuilt service gems. commit 1efcbec Author: Alex Woods <[email protected]> Date: Thu Apr 7 09:37:39 2022 -0700 Eventbridge multiregion (#2683) commit 9b1f540 Author: AWS SDK for Ruby <[email protected]> Date: Wed Apr 6 18:05:48 2022 +0000 Updated API models and rebuilt service gems. commit 3d215b3 Author: AWS SDK for Ruby <[email protected]> Date: Tue Apr 5 18:04:18 2022 +0000 Updated API models and rebuilt service gems. commit 0de0594 Author: AWS SDK for Ruby <[email protected]> Date: Mon Apr 4 18:07:27 2022 +0000 Updated API models and rebuilt service gems. commit ca7a502 Author: Tom Keller <[email protected]> Date: Mon Apr 4 10:08:02 2022 -0700 feat: Standardize issue templates for discussions (#2682) commit 09f32a4 Author: AWS SDK for Ruby <[email protected]> Date: Fri Apr 1 18:04:12 2022 +0000 Updated API models and rebuilt service gems. commit 7ed4c83 Author: AWS SDK for Ruby <[email protected]> Date: Thu Mar 31 18:11:17 2022 +0000 Updated API models and rebuilt service gems. commit e206882 Author: AWS SDK for Ruby <[email protected]> Date: Wed Mar 30 18:06:53 2022 +0000 Updated API models and rebuilt service gems. commit 44593ed Author: AWS SDK for Ruby <[email protected]> Date: Tue Mar 29 18:18:40 2022 +0000 Updated API models and rebuilt service gems. commit 60cdf69 Author: AWS SDK for Ruby <[email protected]> Date: Mon Mar 28 18:05:23 2022 +0000 Updated API models and rebuilt service gems. commit bd5ba09 Author: AWS SDK for Ruby <[email protected]> Date: Fri Mar 25 18:06:51 2022 +0000 Updated API models and rebuilt service gems. commit 16bf874 Author: AWS SDK for Ruby <[email protected]> Date: Thu Mar 24 18:04:35 2022 +0000 Updated API models and rebuilt service gems. commit 0573488 Author: AWS SDK for Ruby <[email protected]> Date: Wed Mar 23 18:04:21 2022 +0000 Updated API models and rebuilt service gems. commit ba1c8cf Author: AWS SDK for Ruby <[email protected]> Date: Tue Mar 22 18:52:27 2022 +0000 Updated API models and rebuilt service gems. commit cc64f10 Author: AWS SDK for Ruby <[email protected]> Date: Mon Mar 21 18:08:43 2022 +0000 Updated API models and rebuilt service gems. commit 62e0113 Author: AWS SDK for Ruby <[email protected]> Date: Fri Mar 18 18:04:47 2022 +0000 Updated API models and rebuilt service gems. commit eb03128 Author: AWS SDK for Ruby <[email protected]> Date: Wed Mar 16 18:50:25 2022 +0000 Updated API models and rebuilt service gems. commit a8eab3e Author: AWS SDK for Ruby <[email protected]> Date: Tue Mar 15 20:18:50 2022 +0000 Updated API models and rebuilt service gems. commit 4e1260c Author: AWS SDK for Ruby <[email protected]> Date: Mon Mar 14 18:16:24 2022 +0000 Updated API models and rebuilt service gems. commit 009c62f Author: AWS SDK for Ruby <[email protected]> Date: Fri Mar 11 19:04:47 2022 +0000 Updated API models and rebuilt service gems. commit 2bf61bf Author: Daniel Dao <[email protected]> Date: Fri Mar 11 10:37:50 2022 -0800 Refresh AWS credentials asynchronously (#2642) commit 16b4e18 Author: Alex Woods <[email protected]> Date: Thu Mar 10 14:52:30 2022 -0800 Add x-amz-region-set to list of headers deleted for re-sign (#2680) commit 2086a3b Author: AWS SDK for Ruby <[email protected]> Date: Thu Mar 10 19:05:10 2022 +0000 Updated API models and rebuilt service gems. commit 881740c Author: Alex Woods <[email protected]> Date: Wed Mar 9 16:05:09 2022 -0800 Make stubs thread safe by adding a mutex per stubbed request (#2679) commit f072efb Author: AWS SDK for Ruby <[email protected]> Date: Wed Mar 9 19:08:43 2022 +0000 Updated API models and rebuilt service gems. commit 9cf431c Author: AWS SDK for Ruby <[email protected]> Date: Tue Mar 8 19:08:16 2022 +0000 Updated API models and rebuilt service gems. commit 6dcd0c9 Author: Alex Woods <[email protected]> Date: Mon Mar 7 13:50:24 2022 -0800 Implement support for cases when IMDS is unable to refresh credentials (#2673) commit d124069 Author: AWS SDK for Ruby <[email protected]> Date: Mon Mar 7 19:38:16 2022 +0000 Updated API models and rebuilt service gems. commit b58ff39 Author: Jean byroot Boussier <[email protected]> Date: Mon Mar 7 17:48:21 2022 +0100 Refactor PageableResponse to avoid busting Ruby's constant cache (#2670) commit fc7a332 Author: AWS SDK for Ruby <[email protected]> Date: Fri Mar 4 19:17:08 2022 +0000 Updated API models and rebuilt service gems. commit 800b234 Author: AWS SDK for Ruby <[email protected]> Date: Thu Mar 3 19:09:28 2022 +0000 Updated API models and rebuilt service gems. commit 1efdc0b Author: AWS SDK for Ruby <[email protected]> Date: Wed Mar 2 19:18:25 2022 +0000 Updated API models and rebuilt service gems. commit 025cb82 Author: AWS SDK for Ruby <[email protected]> Date: Tue Mar 1 19:06:51 2022 +0000 Updated API models and rebuilt service gems. commit 1409d5c Author: AWS SDK for Ruby <[email protected]> Date: Mon Feb 28 19:04:03 2022 +0000 Updated API models and rebuilt service gems. commit 7af8a09 Author: AWS SDK for Ruby <[email protected]> Date: Fri Feb 25 19:08:26 2022 +0000 Updated API models and rebuilt service gems. commit e969f29 Author: AWS SDK for Ruby <[email protected]> Date: Thu Feb 24 19:09:10 2022 +0000 Updated API models and rebuilt service gems. commit 9da4853 Author: Alex Woods <[email protected]> Date: Thu Feb 24 10:24:53 2022 -0800 Flexible Checksums Pt2 (#2668) commit 7a6a0b4 Author: Alex Woods <[email protected]> Date: Wed Feb 23 12:35:28 2022 -0800 Add support for HttpChecksum trait - support flexible checksums. (#2667) commit 3cf469c Author: AWS SDK for Ruby <[email protected]> Date: Wed Feb 23 19:04:37 2022 +0000 Updated API models and rebuilt service gems. commit deb8d5c Author: AWS SDK for Ruby <[email protected]> Date: Tue Feb 22 19:04:07 2022 +0000 Updated API models and rebuilt service gems. commit 785412a Author: AWS SDK for Ruby <[email protected]> Date: Mon Feb 21 19:04:50 2022 +0000 Updated API models and rebuilt service gems. commit 418f318 Author: Yuki Kurihara <[email protected]> Date: Tue Feb 22 02:43:17 2022 +0900 Small documentation fixes (#2666) commit 4f3404c Author: AWS SDK for Ruby <[email protected]> Date: Fri Feb 18 19:45:56 2022 +0000 Updated API models and rebuilt service gems. commit c2f6dd9 Author: Matt Muller <[email protected]> Date: Fri Feb 18 11:40:40 2022 -0800 Update flakey test to read utf8 commit 0529c54 Author: AWS SDK for Ruby <[email protected]> Date: Thu Feb 17 19:04:48 2022 +0000 Updated API models and rebuilt service gems. commit 26157a9 Author: Yuki Kurihara <[email protected]> Date: Fri Feb 18 03:19:33 2022 +0900 Add missing documentation for PresignedPost (#2664) commit 02effe9 Author: AWS SDK for Ruby <[email protected]> Date: Wed Feb 16 19:08:19 2022 +0000 Updated API models and rebuilt service gems. commit 65245bb Author: Alex Woods <[email protected]> Date: Tue Feb 15 11:10:00 2022 -0800 Add a before_refresh callback to AssumeRoleCredentials (#2663) commit 533a0f9 Author: Alex Woods <[email protected]> Date: Mon Feb 14 14:51:19 2022 -0800 Fix ruby3 specs for rspec-mocks 3.10.3 change (#2652) commit 7103ad1 Author: Matt Muller <[email protected]> Date: Mon Feb 14 12:32:52 2022 -0800 Raise an error when credentials or config path does not exist (#2662) commit a8aea9d Author: AWS SDK for Ruby <[email protected]> Date: Mon Feb 14 19:04:41 2022 +0000 Updated API models and rebuilt service gems. commit 1d23850 Author: Alex Woods <[email protected]> Date: Mon Feb 14 10:40:28 2022 -0800 Set token create time before the request (#2650) commit a72e1f9 Author: Yuki Kurihara <[email protected]> Date: Tue Feb 15 02:21:55 2022 +0900 [docs] chunk_size should be Integer instead of String. (#2660) commit 2765532 Author: Yuki Kurihara <[email protected]> Date: Tue Feb 15 02:21:45 2022 +0900 Fix documentation for progress_callback in example. (#2658) commit 63008a6 Author: AWS SDK for Ruby <[email protected]> Date: Fri Feb 11 19:03:51 2022 +0000 Updated API models and rebuilt service gems. commit da02146 Author: AWS SDK for Ruby <[email protected]> Date: Thu Feb 10 19:04:11 2022 +0000 Updated API models and rebuilt service gems. commit fed3977 Author: Matt Muller <[email protected]> Date: Wed Feb 9 16:03:33 2022 -0800 Remove ox version restriction commit c8182e5 Author: AWS SDK for Ruby <[email protected]> Date: Wed Feb 9 19:06:20 2022 +0000 Updated API models and rebuilt service gems. commit 94aca0a Author: AWS SDK for Ruby <[email protected]> Date: Tue Feb 8 19:04:24 2022 +0000 Updated API models and rebuilt service gems. commit 5c0b516 Author: AWS SDK for Ruby <[email protected]> Date: Mon Feb 7 19:05:14 2022 +0000 Updated API models and rebuilt service gems.
Specifically, version 3.130 changed the method signature of the `near_expiration?` method used internally to refresh credentials, so we need to update our own use of that method in response. See: - aws/aws-sdk-ruby#2642 - https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-core/CHANGELOG.md#31300-2022-03-11
Context
Relates to issue #2641
When an AWS client instance is using EKS pods or requires refreshing the AWS token, they refresh the token on the main execution thread. Credential providers have to acquire a mutex and call their respective
#refresh
implementation, contributing to spikes in runtime latency during expiration time.The worst case of this is that on the hour, an application running multiple threads will each try to refresh credentials (making a network request), each waiting to acquire the mutex, thereby blocking one another's execution. This can cause periodic latency spikes (see article here for an example Go implementation).
Proposed solution
This PR kicks off a background thread to check whether or not to refresh a token when the credential is about to expire. By doing this async, refreshing doesn't affect the main thread's runtime and doesn't acquire a mutex on the main thread, thus not getting blocked.
Another option was considered where we have a client-side configuration, but that wasn't the best approach as it allows clients to spawn threads unintentionally.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
To make sure we include your contribution in the release notes, please make sure to add description entry for your changes in the "unreleased changes" section of the
CHANGELOG.md
file (at corresponding gem). For the description entry, please make sure it lives in one line and starts withFeature
orIssue
in the correct format.For generated code changes, please checkout below instructions first:
https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
Thank you for your contribution!