Skip to content

Commit

Permalink
Disabling GCE environ check since we know we're on App Engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Dec 30, 2014
1 parent 4457b2f commit 365d512
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions application/vendor/oauth2client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,24 +930,7 @@ def _detect_gce_environment(urlopen=None):
Boolean indicating whether or not the current environment is Google
Compute Engine.
"""
urlopen = urlopen or urllib.request.urlopen
# Note: the explicit `timeout` below is a workaround. The underlying
# issue is that resolving an unknown host on some networks will take
# 20-30 seconds; making this timeout short fixes the issue, but
# could lead to false negatives in the event that we are on GCE, but
# the metadata resolution was particularly slow. The latter case is
# "unlikely".
try:
response = urlopen('http://metadata.google.internal/', timeout=1)
return any('Metadata-Flavor: Google' in header
for header in response.info().headers)
except socket.timeout:
logger.info('Timeout attempting to reach GCE metadata service.')
return False
except urllib.error.URLError as e:
if isinstance(getattr(e, 'reason', None), socket.timeout):
logger.info('Timeout attempting to reach GCE metadata service.')
return False
return False


def _get_environment(urlopen=None):
Expand Down

0 comments on commit 365d512

Please sign in to comment.