From 0d466d22d8e295b3ccd79629e59a13513c0176c7 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Fri, 23 Mar 2018 14:31:48 +0100 Subject: [PATCH] git cl believes I'm working inside GCE Looks like the error codes issued by python's http library might vary between versions/distros. The code tries to reach an URL which is only valid inside GCE and in the event of getting an error it assumes the user is a non-googler. At least in this case, we're seeing: third_party.httplib2.socks.HTTPError: (404, 'No such domain') Adding this exception type allows the function to work correctly. Change-Id: I08d3656b25d9046f8b2fc0da2a2b7c7a698c1d92 Reviewed-on: https://chromium-review.googlesource.com/978212 Commit-Queue: Robbie Iannucci Reviewed-by: Robbie Iannucci --- gerrit_util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gerrit_util.py b/gerrit_util.py index 6bebdea19..14455645c 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -256,7 +256,8 @@ class GceAuthenticator(Authenticator): # Based on https://cloud.google.com/compute/docs/metadata#runninggce try: resp, _ = cls._get(cls._INFO_URL) - except (socket.error, httplib2.ServerNotFoundError): + except (socket.error, httplib2.ServerNotFoundError, + httplib2.socks.HTTPError): # Could not resolve URL. return False return resp.get('metadata-flavor') == 'Google'