Commit 3b44ac67 authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

Reland "gerrit-util: Fix GCE check from behind proxy."

This is a reland of 9ee86e5a

Fix: s/Httplib2Error/HttpLib2Error

Original change's description:
> gerrit-util: Fix GCE check from behind proxy.
>
> Setting HTTP_PROXY or HTTPS_PROXY environment variables will cause git cl
> to fail.
>
> The behavior of an unreachable server behind proxy is different from a direct
> connection, it won't throw a httplib2.ServerNotFoundError error,
> so catch httplib2.Httplib2Error instead.
>
> Bug: 1050380
> Change-Id: I32e2220483de1fd6222c7fd6063039fb86277ef0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2050947
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

Bug: 1050380
Change-Id: I9aec01088b0b1c408a1292106d0b21e6d8997040
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2066666Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent ab9cc2c1
...@@ -288,8 +288,7 @@ class GceAuthenticator(Authenticator): ...@@ -288,8 +288,7 @@ class GceAuthenticator(Authenticator):
# Based on https://cloud.google.com/compute/docs/metadata#runninggce # Based on https://cloud.google.com/compute/docs/metadata#runninggce
try: try:
resp, _ = cls._get(cls._INFO_URL) resp, _ = cls._get(cls._INFO_URL)
except (socket.error, httplib2.ServerNotFoundError, except (socket.error, httplib2.HttpLib2Error):
httplib2.socks.HTTPError):
# Could not resolve URL. # Could not resolve URL.
return False return False
return resp.get('metadata-flavor') == 'Google' return resp.get('metadata-flavor') == 'Google'
......
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