-
Notifications
You must be signed in to change notification settings - Fork 1.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
Unreasonably big memory usage with DeferredRefreshableCredentials
#3366
Comments
Hi @Veetaha , thanks for reaching out. I might not be an expert in sessions.append(sess) However I am working on reproducing this in my account. will share updates soon. |
@Veetaha , I am also not able to find any documentation on it usage of DeferredRefreshableCredentials but any particular reason why you are using this ? I noticed this botocore/botocore/credentials.py Line 355 in 38e457e
Found some other online useful articles to use the RefreshableCredentials -
Let me know if this helps. I would also reach out to team for the insights on the workability of |
Hi, the
Yes, this is the intention. I'm using it in a script that does a lot of parallel requests into different accounts. Namely here is my script. So I create a separate session object for each AWS account my script needs to traverse. My main complaint here is the amount of memory every such session with |
DeferredRefreshableCredentials
DeferredRefreshableCredentials
Describe the bug
When you configure AssumeRole credentials programmatically via
DeferredRefreshableCredentials
, the process starts using too much memory in the specific code shown in the reproduction steps.Regression Issue
Expected Behavior
There should be no memory leaks.
Current Behavior
Memory is leaked and not cleaned up until
Session
object is unreferenced.Reproduction Steps
Paste this Python code into a file and replace
{YOUR_ACCOUNT_ID}
with your AWS account ID and{ROLE_NAME}
with the name of the role to assume.Note that in my real-world case this account ID is dynamic, as my script traverses all AWS accounts in an organization (see additional context at the bottom for details)
Run this script and you'll find that the memory usage grows rapidly. Once the script accumulates ~30 sessions, the used-up memory is half a gig.
Demo (with sound 😄):
botocore-mem-leak-demo.mp4
Possible Solution
No response
Additional Information/Context
I'm using
botocore
to write a script, that lists all accounts in an organization, and then traverses all accounts and their regions to discover all resources present in them. For this, the script usesDeferredRefreshableCredentials
to configure AssumeRole credentials dynamically for every discovered account. I haven't found any documentation on howDeferredRefereshableCredentials
must be used. There is no official way to configure the credentials provider other than by setting it directly in theSessions
_credentials
field. It looks like the official way of doing that viaSession.set_credentials
requires static credentials, which sucks, so I have to resort to the method described in this issue.Maybe there is a better way to configure AssumeRole credential provider dynamically in-memory? I'm quite inexperienced with Python and Botocore, but doing such thing in Rust AWS SDK is embarrassingly easy, and I'm surprised it's such a problem in
botocore
.SDK version used
1.36.3
Environment details (OS name and version, etc.)
22.04.5 LTS (Jammy Jellyfish)
The text was updated successfully, but these errors were encountered: