-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
logging/tests/unit/test__helpers.py
Outdated
|
||
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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@dhermes Danny could you please do a final pass for this and merge if looks good? |
LGTM, will merge once CI completes. |
Thanks @jonparrott! |
For #3622. This fixes the
get_default_handler()
method to let it return theContainerEngineHandler
when in GKE environment using thecluster_name
attribute from the metadata server. If this attribute exists, it should be in GKE environment.