Skip to content

Commit

Permalink
git cl believes I'm working inside GCE
Browse files Browse the repository at this point in the history
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 <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
  • Loading branch information
svillar authored and Commit Bot committed Mar 31, 2018
1 parent 8271d22 commit 0d466d2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gerrit_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ def _test_is_gce(cls):
# 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'
Expand Down

0 comments on commit 0d466d2

Please sign in to comment.