From 9f6aa1ba78039346e31bd586fa4548c5965e5f39 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Thu, 24 Jun 2021 16:59:31 +0000 Subject: [PATCH] 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 Auto-Submit: Raphael Kubo da Costa Reviewed-by: Edward Lesmes --- gerrit_util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gerrit_util.py b/gerrit_util.py index 1f44a799ec..dd07a23cac 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -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)