From db44be5ca67f60b41040cf83e48e19a9cf83f995 Mon Sep 17 00:00:00 2001 From: Julian Knutsen Date: Wed, 7 Oct 2026 09:57:27 +0000 Subject: [PATCH] ci(bazel): go_test_offline runs on the fork tier, where actions are already offline bd_managed_local_test (#7326) fails on every fork PR's proxied lane: the rbe-west fork tier forbids nested namespaces, so unshare exits with ENOSPC, but that tier already runs every action loopback only. When unshare is unavailable, run the binary directly after the same outbound probe proves the network is absent; a host with network and no namespaces still fails. Co-Authored-By: Claude Opus 5.5 (1M context) --- tools/bazel/go_test_offline.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/bazel/go_test_offline.sh b/tools/bazel/go_test_offline.sh index b0718fe52..726cb053c 100755 --- a/tools/bazel/go_test_offline.sh +++ b/tools/bazel/go_test_offline.sh @@ -8,8 +8,23 @@ # code under test needs no outbound network. The workers allow unprivileged # user namespaces; a host that does not fails here rather than running the # test with the network it is meant to be without. +# +# The rbe-west fork tier forbids nested namespaces (unshare fails with ENOSPC) +# but already runs every action loopback only. There, and anywhere else +# unshare is unavailable, the binary runs as is, but only after the same +# outbound probe proves the network is absent; a host with network and no +# namespaces still fails. set -euo pipefail export GO_TEST_RUN_FROM_BAZEL=1 +if ! unshare --user --map-root-user --net -- true 2>/dev/null; then + if timeout 3 bash -c "exec 3<>/dev/tcp/1.1.1.1/443" 2>/dev/null; then + echo "go_test_offline: no network namespace available (unshare failed) and outbound network is reachable" >&2 + exit 1 + fi + bin="$1" + shift + exec "./$bin" "$@" +fi exec unshare --user --map-root-user --net -- bash -euc ' ip link set lo up # Prove the namespace really has no outbound network before trusting