From 57d4742bbb10a6d885a4ff4ea44e3703ca36116b Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Fri, 6 Mar 2020 20:43:07 +0000 Subject: [PATCH] git-cl: Tell users to set SKIP_GCE_AUTH_FOR_GIT=1 when running on cloudtop. Bug: 1059141 Change-Id: I0a4501946014bd567548fb5396c3dd761606a9bf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2091584 Commit-Queue: Edward Lesmes Reviewed-by: Anthony Polito --- gerrit_util.py | 6 ++++++ git_cl.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gerrit_util.py b/gerrit_util.py index 457a6de96..2c7901826 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -101,6 +101,8 @@ class Authenticator(object): # which then must use it. if LuciContextAuthenticator.is_luci(): return LuciContextAuthenticator() + # TODO(crbug.com/1059384): Automatically detect when running on cloudtop, + # and use CookiesAuthenticator instead. if GceAuthenticator.is_gce(): return GceAuthenticator() return CookiesAuthenticator() @@ -465,6 +467,10 @@ def ReadHttpResponse(conn, accept_statuses=frozenset([200])): host = auth_match.group(1) if auth_match else conn.req_host print('Authentication failed. Please make sure your .gitcookies ' 'file has credentials for %s.' % host) + # TODO(crbug.com/1059384): Automatically detect when running on cloudtop. + if isinstance(Authenticator.get(), GceAuthenticator): + print('If you\'re on a cloudtop instance, export ' + 'SKIP_GCE_AUTH_FOR_GIT=1 in your env.') print('Try:\n git cl creds-check') reason = '%s: %s' % (response.reason, contents) diff --git a/git_cl.py b/git_cl.py index 6a691e9bb..e306baf57 100755 --- a/git_cl.py +++ b/git_cl.py @@ -3396,14 +3396,16 @@ def CMDcreds_check(parser, args): # Code below checks .gitcookies. Abort if using something else. authn = gerrit_util.Authenticator.get() if not isinstance(authn, gerrit_util.CookiesAuthenticator): - if isinstance(authn, gerrit_util.GceAuthenticator): - DieWithError( - 'This command is not designed for GCE, are you on a bot?\n' - 'If you need to run this on GCE, export SKIP_GCE_AUTH_FOR_GIT=1 ' - 'in your env.') - DieWithError( + message = ( 'This command is not designed for bot environment. It checks ' '~/.gitcookies file not generally used on bots.') + # TODO(crbug.com/1059384): Automatically detect when running on cloudtop. + if isinstance(authn, gerrit_util.GceAuthenticator): + message += ( + '\n' + 'If you need to run this on GCE or a cloudtop instance, ' + 'export SKIP_GCE_AUTH_FOR_GIT=1 in your env.') + DieWithError(message) checker = _GitCookiesChecker() checker.ensure_configured_gitcookies()