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: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/gerrit_util.py b/gerrit_util.py
index 1f44a79..dd07a23 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -315,7 +315,8 @@
"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)