Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Julian Knutsen
db44be5ca6 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) <noreply@anthropic.com>
2026-10-07 09:57:27 +00:00

View file

@ -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