elegant-beach-10818
09/08/2023, 4:19 PMself.merge_artifacts(...) we're seeing a botocore.exceptions.NoCredentialsError which based on this thread is because we're hitting the AWS Instance Metadata Service too often and exceeding the throttle limits described herevictorious-lawyer-58417
09/12/2023, 5:40 AMvictorious-lawyer-58417
09/12/2023, 5:41 AMmerge_artifacts?elegant-beach-10818
09/12/2023, 4:42 PMelegant-beach-10818
09/14/2023, 2:22 PMancient-application-36103
09/14/2023, 2:44 PMelegant-beach-10818
09/14/2023, 3:15 PMWe throttle queries to the IMDS on a per-instance basis, and we place limits on the number of simultaneous connections from an instance to the IMDS.
If you're using the IMDS to retrieve AWS security credentials, avoid querying for credentials during every transaction or concurrently from a high number of threads or processes, as this might lead to throttling. Instead, we recommend that you cache the credentials until they start approaching their expiry time. For more information about IAM role and security credentials associated with the role, see Retrieve security credentials from instance metadata.I tried getting frozen credentials and setting environment variables like below and the problem persisted:
import boto3
session = boto3.Session()
credentials = session.get_credentials()
a = credentials.get_frozen_credentials()
import os
os.environ['AWS_ACCESS_KEY_ID'] = a.access_key
os.environ['AWS_SECRET_ACCESS_KEY'] = a.secret_key
os.environ['AWS_SESSION_TOKEN'] = a.tokenelegant-beach-10818
10/05/2023, 3:46 PMelegant-beach-10818
10/05/2023, 8:46 PMDATATOOLS_DEFAULT_CLIENT_PARAMS
I save the following in a python file
import boto3
session = boto3.Session()
c = session.get_credentials().get_frozen_credentials()
print('{{ "aws_access_key_id": "{}", "aws_secret_access_key": "{}", "aws_session_token": "{}" }}'.format(c.access_key,c.secret_key,c.token))
Then when running the flow I can do:
METAFLOW_DATATOOLS_DEFAULT_CLIENT_PARAMS=$(python creds.py) python flow.py …
This has the disadvantage that my flow can’t be longer than remaining expiry time on the token.
I see in the code that it creates a new boto3 session for each and every s3 url that needs downloading which is causing the issue. I’ll create an issue to track this and try to submit a PR next week with a proposed solutionelegant-beach-10818
10/05/2023, 9:03 PM