botocore icon indicating copy to clipboard operation
botocore copied to clipboard

Metadata service returned non-200 response with status code of 400 for url

Open TattiQ opened this issue 7 years ago • 6 comments

Hi guys,

We have a python app that retrieves creds from IMDS via kube2iam and sometimes we encounter this issue: Metadata service returned non-200 response with status code of 400 for url: http://169.254.169.254/latest/meta-data/iam/security-credentials/{"AccessKeyId":"ID","Code":"Success","Expiration":"2019-01-29T18:06:11Z","LastUpdated":"2019-01-29T17:36:11Z","SecretAccessKey":"secret","Token":"token","Type":"AWS-HMAC"}, content body: b'400 Bad Request'

I substituted the values with dummy ones.

Then the amount of retries is exhausted and we fail with Error when retrieving credentials from iam-role: Credential refresh failed, response did not contain: access_key, secret_key, token, expiry_time

The botocore version is 1.12.86. I wonder what could be causing that 400

TattiQ avatar Jan 30 '19 11:01 TattiQ

so weirdly it looks like the actual response body is concatenated to the response.url (http://169.254.169.254/latest/meta-data/iam/security-credentials/) . we started to see this issue since updating to 1.12.86

TattiQ avatar Jan 30 '19 12:01 TattiQ

Hi, what version of botocore did you upgrade from? We added more debug information in the logs in 1.12.X ( I think somewhere around 1.12.35) which should not have affected functionality.

If I can compare what version you're upgrading from it should help track down what changes made to the instance metadata service could be affecting you.

jamesls avatar Feb 08 '19 19:02 jamesls

Hi @jamesls , thank you for the update! We upgraded from 1.10.4

TattiQ avatar Feb 10 '19 18:02 TattiQ

this seems to be reproduce only with credentials refresh in Celery. Celery uses prefork process pool by default, that could be the cause of the issue.

TattiQ avatar Apr 17 '19 10:04 TattiQ

@TattiQ - Are you still seeing this error with latest version of botocore ?

swetashre avatar Mar 24 '20 22:03 swetashre

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

no-response[bot] avatar Mar 31 '20 22:03 no-response[bot]