Commit 9f6aa1ba authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by LUCI CQ

gerrit_util: Make GceAuthenticator also consider proxy errors in httplib2

Some HTTP proxies may return an HTTP error such as 503 when DNS
resolution fails for GceAuthenticator._INFO_URL
(http://metadata.google.internal), which causes e.g. git-cl to throw an
exception rather than falling back to checking for .netrc or
.gitcookies.

Make GceAuthenticator._get() also consider an httplib2 proxy error a
sign that the code is not running in GCE.

Change-Id: Icc094829f9b044176be44e51f3cad49d4a374f25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2982611
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent cf60c0af
......@@ -315,7 +315,8 @@ class GceAuthenticator(Authenticator):
"Don't know how to work with protocol '%s'" % protocol)
try:
resp, contents = httplib2.Http().request(url, 'GET', **kwargs)
except (socket.error, httplib2.HttpLib2Error) as e:
except (socket.error, httplib2.HttpLib2Error,
httplib2.socks.ProxyError) as e:
LOGGER.debug('GET [%s] raised %s', url, e)
return None, None
LOGGER.debug('GET [%s] #%d/%d (%d)', url, i+1, TRY_LIMIT, resp.status)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment