Просмотр исходного кода

autoninja: Add workaround for slow reproxy starts

Somewhere deep in the Google Cloud Go SDK is a call to user.Current() to
get the user's home directory, in order to find some configuration files
necessary for TLS Client Certificate authentication.

The user.Current() function in Go versions prior to the yet unreleased
Go 1.24 can be very slow on Windows, as it causes a network call to the
Active Directory server to be made if the machine is part of a Windows
domain.

As we don't use TLS Client Certificate at Google, we can safely disable
this code path by setting GOOGLE_API_USE_CLIENT_CERTIFICATE=false in the
environment prior to launching reproxy and other tools using the SDK.

As I'm not sure whether this would cause issues for people actually
using TLS Client Certificate auth with their REAPI backend, let's only
apply this workaround on Google corp machines. It's highly unlikely that
others are affected by this particular issue anyway, and when Go 1.24
is released in February, it will fix the underlying issue anyway.

Bug: 388195531
Change-Id: Ia9d4b74c251b303b66b19fb59957ff5a922d883b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6191410
Auto-Submit: Philipp Wollermann <philwo@google.com>
Commit-Queue: Philipp Wollermann <philwo@google.com>
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Philipp Wollermann 7 месяцев назад
Родитель
Сommit
49e10123de
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      autoninja.py

+ 7 - 0
autoninja.py

@@ -186,6 +186,13 @@ def _main_inner(input_args, build_id, should_collect_logs=False):
     # and keep workspace clean.
     # and keep workspace clean.
     if not os.environ.get("PYTHONPYCACHEPREFIX"):
     if not os.environ.get("PYTHONPYCACHEPREFIX"):
         os.environ.setdefault("PYTHONDONTWRITEBYTECODE", "1")
         os.environ.setdefault("PYTHONDONTWRITEBYTECODE", "1")
+    # Workaround for reproxy timing out on startup due to the Google Cloud
+    # Go SDK making a call to user.Current(), which can be slow on Googler
+    # machines due to go.dev/issue/68312. This can be removed once Go 1.24
+    # has been released, and reproxy + other tools have been rebuilt with
+    # that.
+    if _is_google_corp_machine():
+        os.environ.setdefault("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
     # The -t tools are incompatible with -j
     # The -t tools are incompatible with -j
     t_specified = False
     t_specified = False
     j_specified = False
     j_specified = False