Match CI temp layout in the preflight worker and isolate agent helper tests

go test places t.TempDir under GOTMPDIR, and the preflight worker nested that
under its per-run directory, so unix socket fixtures in cmd/pulse-agent-helper,
internal/agenthelper, and internal/dockeragent exceeded the 108-byte sun_path
limit and failed with "bind: invalid argument". GitHub runners leave GOTMPDIR
unset, and the longest rootless Podman fixture sits exactly at the limit under
/tmp, so the worker now leaves GOTMPDIR unset by default and only honours an
explicit PULSE_RELEASE_PREFLIGHT_GO_TMP_DIR override.

Two cmd/pulse-agent helper tests ran without a state directory, so the agent
consulted the platform default /var/lib/pulse-agent. On a host where that
path exists as a private directory the pending-update handoff lookup fails
with permission denied. Give those tests an isolated state directory.
This commit is contained in:
rcourtman
2026-09-01 22:33:00 +01:00
parent 020eb11edb
commit 813c2b6837
2 changed files with 16 additions and 4 deletions
+2
View File
@@ -1779,6 +1779,7 @@ func TestRunConfiguresTypedPrivilegeHelperFromInstallerEnvironment(t *testing.T)
"-enable-docker=false",
"-enable-kubernetes=false",
"-health-addr", "",
"-state-dir", t.TempDir(),
}, func(string) string { return "" })
if err != nil && !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) {
t.Fatalf("run returned error: %v", err)
@@ -1839,6 +1840,7 @@ func TestRunRejectsUnhealthyTypedPrivilegeHelper(t *testing.T) {
"-enable-docker=false",
"-enable-kubernetes=false",
"-health-addr", "",
"-state-dir", t.TempDir(),
}, func(string) string { return "" })
if err == nil || !strings.Contains(err.Error(), "verify typed privilege helper protocol") {
t.Fatalf("run error = %v", err)
+14 -4
View File
@@ -35,7 +35,13 @@ CACHE_DIR="${WORKER_ROOT}/cache"
RECEIPT_DIR="${WORKER_ROOT}/receipts"
RUN_ID="$(date -u +%Y%m%dT%H%M%SZ)-${SOURCE_SHA:0:12}-${PROFILE}"
RUN_DIR="${WORKER_ROOT}/tmp/${RUN_ID}"
GO_TMP_DIR="${RUN_DIR}/go-tmp"
# Go places test temp directories under GOTMPDIR, and several packages bind
# unix sockets under t.TempDir at the 108-byte sun_path limit. GitHub runners
# leave GOTMPDIR unset so those fixtures resolve under /tmp; the worker must
# match that layout exactly or the socket tests fail with "bind: invalid
# argument". Set PULSE_RELEASE_PREFLIGHT_GO_TMP_DIR only for a deliberately
# isolated, equally short directory.
GO_TMP_DIR="${PULSE_RELEASE_PREFLIGHT_GO_TMP_DIR:-}"
TIMINGS_FILE="${RUN_DIR}/timings.tsv"
TEST_DATA_DIR="${WORKER_ROOT}/test-data/${PROFILE}"
@@ -67,7 +73,6 @@ mkdir -p \
"$CACHE_DIR/npm" \
"$RECEIPT_DIR" \
"$RUN_DIR" \
"$GO_TMP_DIR" \
"$(dirname "$TEST_DATA_DIR")"
exec 9>"${WORKER_ROOT}/worker.lock"
@@ -83,7 +88,10 @@ unset GH_TOKEN GITHUB_TOKEN PULSE_LICENSE_PRIVATE_KEY PULSE_UPDATE_SIGNING_KEY
export GOCACHE="$CACHE_DIR/go-build"
export GOMODCACHE="$CACHE_DIR/go-mod"
export GOTMPDIR="$GO_TMP_DIR"
if [ -n "$GO_TMP_DIR" ]; then
mkdir -p "$GO_TMP_DIR"
export GOTMPDIR="$GO_TMP_DIR"
fi
export npm_config_cache="$CACHE_DIR/npm"
# Match the canonical workflow's isolated single-repository checkout. Tests
# that explicitly require private sibling repositories use this signal to
@@ -105,7 +113,9 @@ phase() {
}
cleanup() {
rm -rf "$GO_TMP_DIR"
if [ -n "$GO_TMP_DIR" ]; then
rm -rf "$GO_TMP_DIR"
fi
if [ -d "$REPOSITORY_DIR/tests/integration" ]; then
(
cd "$REPOSITORY_DIR/tests/integration"