Uh oh!
There was an error while loading. Please reload this page.
Use metadata server to detect GKE environment - #3856
Conversation
| try: | ||
| response = requests.get(url, headers=METADATA_HEADERS) | ||
| if response.status_code == requests.codes.ok: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| See: https://cloud.google.com/compute/docs/storing-retrieving-metadata | ||
| :type metadata_key: str | ||
| :param metadata_key: Key of the metadata which will form the url. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_request_exception(self): | ||
| metadata_key = 'test_url_cannot_connect' | ||
| metadata_url = 'invalid_url' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
liyanhui1228
commented
Aug 23, 2017
@dhermes Danny could you please do a final pass for this and merge if looks good? |
theacodes
commented
Aug 23, 2017
LGTM, will merge once CI completes. |
dhermes
commented
Aug 23, 2017
Thanks @jonparrott! |
For #3622. This fixes the
get_default_handler()method to let it return theContainerEngineHandlerwhen in GKE environment using thecluster_nameattribute from the metadata server. If this attribute exists, it should be in GKE environment.