Skip to content
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

Merged
merged 6 commits into from
Aug 23, 2017

Conversation

liyanhui1228
Copy link
Contributor

For #3622. This fixes the get_default_handler() method to let it return the ContainerEngineHandler when in GKE environment using the cluster_name attribute from the metadata server. If this attribute exists, it should be in GKE environment.

@liyanhui1228 liyanhui1228 added the api: logging Issues related to the Cloud Logging API. label Aug 23, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 23, 2017
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.

This comment was marked as spam.

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.


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.

@liyanhui1228
Copy link
Contributor Author

@dhermes Danny could you please do a final pass for this and merge if looks good?

@theacodes
Copy link
Contributor

LGTM, will merge once CI completes.

@theacodes theacodes merged commit 0dd7249 into googleapis:master Aug 23, 2017
@dhermes
Copy link
Contributor

dhermes commented Aug 23, 2017

Thanks @jonparrott!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the Cloud Logging API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants