Skip to content

fix(ci): retry browser smoke server ports to stop ephemeral-collision flake - #497

Merged
haiyuan-eng-google merged 4 commits into
GoogleCloudPlatform:mainfrom
caohy1988:audit/ci-flake-20260927
Sep 28, 2026
Merged

haiyuan-eng-google merged 4 commits into
GoogleCloudPlatform:mainfrom
caohy1988:audit/ci-flake-20260927

Conversation

@caohy1988

Copy link
Copy Markdown
Collaborator

Evidence — this is a real CI flake

The red run. CI run 35760370644 on main @ 1908eb0 (the #491 squash merge, 2026-09-22 17:23Z) failed only the Configurator browser smoke job:

browser smoke: server did not become ready on port 37368 (occupied by another process, or failed to start)

All five Test (Python 3.10–3.14) matrix jobs, Format check, and Build package were green in the same run — and each Test job runs this exact script twice (test_configurator_loads_in_a_real_browser + test_browser_smoke_negative_fixtures_are_detected), so the script had already passed ten times inside that very run before failing once.

Same tree, different outcome. Six minutes earlier, CI run 35759731437 on the PR #491 branch (audit/ci-flake-slow-20260922 @ c982e51) passed the same job. Both commits carry the identical tree object edb9c6b0 (verified with git cat-file -p): same code, passing at 17:17, failing at 17:23. The failed run was attempt 1 and was never re-run; every later main run is green.

Timing signature. The failing step started at 17:24:07.65 and failed at 17:24:08.22 — 0.56 s. The readiness loop polls every 0.5 s and bails the moment kill -0 "$SERVER_PID" sees the child is dead, so the server process died ~instantly: a bind failure, not a slow server.

Root cause

dashboard/looker_studio/tools/browser_smoke.sh picked its local server port with a single random draw:

PORT="${SMOKE_PORT:-$((20000 + RANDOM % 20000))}"
  • [20000, 40000) overlaps the runner's ephemeral port span — Ubuntu 22.04's default net.ipv4.ip_local_port_range is 32768 60999 — which the kernel hands out as source ports for outbound connections of any process on the VM. Port 37368 from the failing run sits inside that overlap.
  • The script has zero tolerance for a collision: when the drawn port is taken, python3 -m http.server exits immediately (Address already in use), the readiness loop notices the dead child, and the whole check hard-fails.
  • One colliding socket anywhere in a 20,000-wide range = a red run on a fully green commit.

Fix

Bounded retry, nothing else — one file, a CI test helper under dashboard/ (no src/ change, no product code):

  • Draw up to five random candidates; every attempt still has to pass the existing nonce round-trip, so "the server is provably ours" is enforced per attempt and a stranger's server can never satisfy readiness.
  • Happy path identical: first draw free → single server spawn, no extra sleep, no added latency.
  • SMOKE_PORT-pinned runs stay single-attempt on purpose: self-test 2 (occupied/stale port is detected) requires a pinned occupied port to FAIL — retrying would let it silently pass on a different port and destroy the negative fixture.
  • No assertion loosened, no timeout raised, no fixture deleted; the failure message is byte-identical.

Before / after

Port-pressure harness: a squatter process holds 800 random ports inside the pick range (~4% pressure, mimicking a busy runner), 200 runs each with CHROME_BIN=/bin/false so every run ends right after the server phase; identical squatter seed across both measurements.

build runs server phase OK port-collision failures
before (pristine HEAD script) 200 193 7 (3.5%)
after (this PR) 200 200 0

Deterministic repro (before): holding port 37368 and running the pristine script pinned to it reproduces the CI failure byte-for-byte (browser smoke: server did not become ready on port 37368 (…), exit 1). After the fix the pinned-port behavior is deliberately unchanged (still fails — the negative fixture requires it); the random path is what becomes collision-proof.

Regression checks after the fix (local):

  • bash dashboard/looker_studio/tools/browser_smoke.sh --self-test — all 9 negative fixtures still fail as required.
  • Real headless-Chrome run — browser smoke OK: module initialized, zero page-level errors, pristine first load.
  • pytest tests/test_looker_studio_dashboard.py -q — 29 passed.
  • Full unit suite pytest -q — 5274 passed / 83 skipped; identical to the pre-change baseline except 3 pre-existing failures in tests/test_grafana_local_runner.py that only fail under this Mac's process-list sandbox (ps is blocked locally; they pass in CI and are unrelated to this change).
  • Format gate exactly as CI runs it: pyink 25.12.0 (below CI's <26 pin) + isort via autoformat.sh → 366 files unchanged; git diff --exit-code src/ tests/ examples/ scripts/ dashboards/ clean.
  • Verified under bash 3.2.57 (macOS) as well as the bash 5 constructs used by ubuntu-22.04.

Out of scope (observed, not fixed here)

The two pytest gates around this script are also the suite's slowest tests (test_browser_smoke_negative_fixtures_are_detected ≈ 76 s, test_configurator_loads_in_a_real_browser ≈ 18 s locally). That is real Chrome launch time per fixture and needs a separate, larger change; flagged for a follow-up rather than bundled into this single-concern fix.

…(nightly)

The Configurator browser smoke job picks its local server port with a
single random draw from [20000, 40000). That range overlaps the Linux
ephemeral port span (32768-60999 on the ubuntu-22.04 runner), so any
concurrent socket can occupy the drawn port; python http.server then
dies on bind, the readiness loop notices the dead child, and an
otherwise-green commit goes red. Observed once on main: run 35760370644
@ 1908eb0 failed only this job with 'server did not become ready on
port 37368' while the same tree had passed the same job six minutes
earlier (run 35759731437) and all other jobs stayed green.

Draw up to five random candidates instead, each still gated by the
nonce round-trip so a stranger's server can never satisfy readiness.
An explicitly pinned SMOKE_PORT stays single-attempt so the
occupied-port negative fixture keeps failing exactly as it must. No
assertion, timeout, or fixture changed.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST_CHANGES

Independent blind review by Astra (Codex) of 448d0231b2c05e5af00d4103a3284082e3a51f19 against a51c39a2dfaa6d863a0e16597f7b1b191b86effb. Submitted with the COMMENT event as requested.

P0

None.

P1

Retry only confirmed address-in-use failures. At dashboard/looker_studio/tools/browser_smoke.sh:381–392, every unsuccessful readiness attempt advances to another port: both a dead server and an exhausted readiness poll. There is no collision classification. Server stderr is discarded at line 372, and wait discards the failed child's exit status at line 390. Consequently, an intermittent server failure unrelated to binding can disappear behind a later successful attempt, violating the explicit no-masking requirement.

I reproduced this with the complete base and tip scripts and real Chrome. A temporary python3 PATH shim delegates instrumentation normally, verifies the selected port is free, then injects a non-bind startup error (status 42) on only the first -m http.server invocation; later invocations execute the real server. Base: exit 1 after one spawn. PR tip: exit 0 after two spawns, with browser smoke OK. The nonce proves ownership of the eventual server; it does not classify the earlier failure.

Suggested fix: retain each attempt's server diagnostic and status, retry only a positively identified EADDRINUSE bind failure, and fail immediately for other server exits or readiness/nonce timeouts. Preserve the five-attempt cap and single-attempt pinned path. Add deterministic coverage for a real collision followed by success, retry exhaustion, and a non-bind failure followed by a potentially healthy server that must still fail.

P2

None beyond the P1 issue.

Independent validation

  • Read the PR description, GitHub diff and full file, local full file and base, and repository callers. GitHub's file at the requested tip matches the worktree byte-for-byte. Scope is exactly one file (+31/−13); the worktree remains clean.
  • Retry limit is five; nonempty SMOKE_PORT restricts it to one (lines 364–371). The occupied-port negative fixture at lines 101–116 is byte-identical to base. Base/tip pinned occupied runs each spawned once, exited 1, and produced byte-identical diagnostics. Pinned free runs each reached /bin/false Chrome once and failed with the same browser-status diagnostic. The new path additionally reaps a failed server before reporting failure.
  • Deterministic Mac/Bash 3.2 harness: a dual-stack listening socket forced a real Python Address already in use error; tip recovered on attempt two and passed with real Chrome. Persistent injected startup failure stopped after exactly five attempts, exit 1. CHROME_BIN=/bin/false failed after one server spawn, with no retry. All nine completed harness cases removed their temporary sites and left no recorded server PID alive.
  • Browser execution, status handling, DOM/page-error assertions, and the EXIT cleanup trap are byte-identical to base and remain outside the retry loop (lines 395–488). Pre-server setup errors also remain hard failures under set -e.
  • bash -n dashboard/looker_studio/tools/browser_smoke.sh and git diff --check a51c39a2dfaa6d863a0e16597f7b1b191b86effb HEAD passed.
  • env -u SMOKE_PORT -u CHROME_BIN -u SMOKE_DOCS_DIR bash dashboard/looker_studio/tools/browser_smoke.sh --self-test passed all nine negative fixtures with the installed Chrome.
  • Callers are .github/workflows/ci.yml:102,105 and tests/test_looker_studio_dashboard.py:1024,1042; the latter exercise normal smoke and all negative fixtures within the Python matrix.
  • gh pr checks 497 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK: all executed checks passed, including Python 3.10–3.14, Configurator browser smoke, formatting and build; four zizmor jobs were skipped. CI run.

Evidence limits: I did not rerun the author's probabilistic 200-before/200-after pressure test. The historical failed CI run independently confirms the reported generic startup failure on port 37368, but its suppressed server stderr cannot establish EADDRINUSE as that incident's cause. No vault, dual-review peer files, or existing PR reviews/comments were read before this review.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Blind review by Fable (Claude) on caohy1988's behalf. Scope: tip 448d023 vs base a51c39a, one file, dashboard/looker_studio/tools/browser_smoke.sh. Sources: PR description, diff, full script, callers (tests/test_looker_studio_dashboard.py:1023-1027, 1041-1045; .github/workflows/ci.yml:102,105), CI status, plus local runs on macOS (bash 3.2.57, Python 3.13.7, curl 8.7.1, Google Chrome). No P0/P1 found.

What I verified

  • Bounded retry. ATTEMPTS=5 (L364), for _ in $(seq 1 "$ATTEMPTS") (L370), fresh random draw per attempt (L371). Pinned SMOKE_PORT forces ATTEMPTS=1 (L365-367).

  • Pinned path unchanged. Held port 37368 with a decoy http.server and ran base and PR pinned to it: both exit 1 in ~0.6 s with byte-identical stderr (browser smoke: server did not become ready on port 37368 (occupied by another process, or failed to start)). Self-test 2 (L101-116) depends on exactly this and still passes.

  • No masking of real failures. READY is only ever set by the nonce round-trip (L376-379), so a stranger's server can never satisfy readiness, and the Chrome phase plus every DOM assertion (L401-486) is untouched. With a python3 shim that refuses every -m http.server launch, the PR script exits 1 after 5 refusals in 0.2 s with the same message (base: 1 refusal, 0.06 s). A shim that refuses the first 4 launches and allows the 5th reaches the browser phase normally.

  • Cleanup and exit codes. Trap and fail unchanged (L45-55). Failed attempts kill their server and blank SERVER_PID (L389-391), so the trap never targets a stale pid; on success SERVER_PID stays set and the trap kills the live server as before. bash -n and shellcheck -S warning are clean.

  • Collision harness (independent of the author's numbers). Squatter holding 998 listening sockets in [20000,30000), CHROME_BIN=/bin/false, 150 runs per build:

    build runs server phase OK port-collision failures
    base a51c39a 150 140 10
    PR 448d023 150 150 0

    Every PR run ended at the expected browser exited with status 1; no leftover http.server processes after either loop.

  • Real Chrome. --self-test 9/9 OK (76 s) and the main check OK (12 s), both with empty stderr.

  • CI. All checks green on 448d023: Configurator browser smoke (21 s), Test 3.10-3.14, Format check, Build package, scan-pr, cla/google.

P0

None.

P1

None.

P2 (non-blocking)

  1. The retry is not specific to the collision signature (L386-391). The outer loop retries whenever READY is empty, which includes a child that is alive but never served the nonce (all 20 probes exhausted). A bind collision always presents as a dead child (L381-383 breaks in well under 1 s), so the alive-but-unreachable case (proxy env without no_proxy, broken curl hidden by || true, loopback firewall) is never a collision, yet it now costs up to 5x the old budget (~53-254 s instead of ~10-51 s) before the same message. Neither pytest caller passes a timeout=. Not a green/red change, but it blurs the diagnosis this PR itself relied on. Suggested fix, which also removes item 2:

      if [ -n "$READY" ]; then
        break
      fi
      if kill -0 "$SERVER_PID" 2>/dev/null; then
        # Alive but never served the nonce: not a collision. Leave SERVER_PID
        # set so the EXIT trap kills it, and fall through to fail below.
        break
      fi
      SERVER_PID=""
    done
  2. wait "$SERVER_PID" after disown is a no-op (L390). Measured on bash 3.2.57: wait on a disowned, still-running pid returns 0 after 13 ms with the process alive. bash >= 4 records exit status 0 in its bgpids table at disown time and wait returns that, so the ubuntu-22.04 runner behaves the same. Harmless today (the next attempt draws a fresh port; same-port redraw is ~1/20000) but the line reads as "reap before retry" and does not. Drop it, or disown only after READY so wait can actually reap the killed attempts.

  3. Successful retries are silent and the final message names only the last port (L389-393). "First 4 launches die, 5th OK" produced zero bytes of output. Five deaths produce server did not become ready on port NNNNN (...) with python's stderr discarded (L372), so a systematic failure on a runner reads exactly like five collisions. One stderr line per failed attempt (echo "browser smoke: port $PORT not ready (attempt $attempt/$ATTEMPTS), retrying" >&2, using a counter instead of _) plus the attempted-port list in the final fail would keep the residual flake rate measurable. Self-test children run with >/dev/null 2>&1, so this adds no noise there; the pytest wrapper only surfaces child output on failure.

  4. Follow-ups outside this hunk (pre-existing; not for this PR).

    • python3 -m http.server "$PORT" binds all interfaces (L372; decoy at L107). With --bind 127.0.0.1, a stranger's ephemeral socket on the NIC address no longer conflicts on Linux (distinct specific addresses do not collide; the wildcard does), removing most of the collision class at the source and no longer exposing the smoke server on every runner interface. If done, bind the decoy to 127.0.0.1 too, otherwise self-test 2 breaks on macOS/BSD, where SO_REUSEADDR lets a specific-address bind coexist with a wildcard listener. Not verified on Linux in this session.
    • DECOY_PID (L108) is not in cleanup() (L45-49), so an abnormal exit during self-test 2 leaks an http.server bound on all interfaces on persistent machines; the retry now silently tolerates such a leaked decoy instead of surfacing it. Two-line fix: initialize DECOY_PID="" and kill it in the trap.
    • The env docs at L35 could note that SMOKE_PORT disables the retry (the in-code comment at L359-361 says it; the header does not).

Notes on the PR description

  • Claims checked out: bounded 5-draw retry; happy path unchanged (single spawn, no added sleep); pinned path single-attempt; failure message byte-identical; before/after numbers reproduced in kind (10/150 -> 0/150 here vs the author's 7/200 -> 0/200).
  • Minor: RANDOM % 20000 draws ports 20000-32767 twice as often as 32768-39999, so about 22% of draws (not ~36%) land in the 32768-60999 ephemeral span. The fix works either way.
… conflicts

The retry loop added in 448d023 retried on EVERY readiness failure, so an
intermittent real startup failure — the server exiting once with a
non-bind error — was masked by a later successful spawn: the base script
failed such a run, the tip passed it. The server stderr was discarded and
the child exit status was unused, so the real failure never surfaced.

Each attempt now captures the server output to a per-attempt file, and a
retry is admissible only when the dead child own output positively
identifies a bind conflict (EADDRINUSE / "Address already in use") — the
one failure a fresh port can cure. Every other failure (a non-bind exit,
a readiness timeout with the child still alive, or anything unidentified)
fails the check immediately on that attempt, with the reaped exit status
and the captured server output in the diagnostic, so a real startup
failure can never be masked. The unpinned path keeps the five-attempt
cap; a pinned SMOKE_PORT stays single-attempt with the pre-retry
diagnostic byte-for-byte.

Also fixes the review P2 items: the retry is gated on kill -0, so an
alive-but-unready child fails instead of retrying; the disown that made
the post-kill wait a silent no-op is dropped and the EXIT trap now kills
and reaps (which also suppresses bash stray "Terminated" job report), so
the child true exit status is finally used; each retry logs one stderr
line with the attempt number, port, and reason; and the header notes that
SMOKE_PORT disables the retry.

Four deterministic fixtures join the self-test, driven by a test-only
python3 shim (no probabilistic squatting): the shim really occupies the
drawn port, so the first http.server dies with a genuine EADDRINUSE and
the check must retry and pass with exactly two server spawns (fixture
10); the shim fails once with a non-bind error and would serve on the
second spawn, and the check must fail on attempt 1 with no retry and the
captured output surfaced (11); a pinned port stays single-attempt under
the same collision with the unchanged diagnostic (12); and an
alive-but-unready server fails immediately (13). Fixture 2 additionally
pins the pinned-port diagnostic text byte-for-byte.

Evidence with the same shim, docs, and Chrome: a non-bind first-spawn
failure fails at the base and on this change (exit 1, one spawn) but
passes at 448d023 (exit 0 — masked); a real bind collision fails at the
base and is retried to a pass here and at 448d023; and a 120-run
collision loop (CHROME_BIN=/bin/false, squatters holding both stacks on
3000 ports inside the draw range) shows 0/120 readiness failures with
24 positively identified, retried, and recovered collisions.
@caohy1988

Copy link
Copy Markdown
Collaborator Author

Review fix: retry only on positively identified port-in-use (+ P2 cleanup) — pushed as 81be299.

P1 — the retry loop no longer masks real startup failures. The tip's loop retried on every readiness failure, so an intermittent real startup failure (a non-bind server exit) was swallowed by a later lucky spawn. Now each attempt captures the server's output to a per-attempt file (server-attempt-N.log), and a retry is admissible only when the dead child's own output positively identifies a bind conflict (EADDRINUSE / Address already in use). Every other failure fails the check immediately on that attempt, with the child's real exit status and the captured server output in the diagnostic:

  • non-bind exit → browser smoke: server exited with status 7 on port P (attempt 1 of 5); server output: …
  • readiness timeout with the child still alive → fail immediately, captured output included
  • anything unidentified (incl. empty output) → fail immediately with (no server output captured)

The unpinned path keeps the five-attempt cap. The pinned SMOKE_PORT path stays a single attempt with the pre-retry diagnostic byte-for-byte — fixture 2 now pins that wording, and fixture 12 pins single-attempt via a spawn counter.

P2 — all four items fixed, none deferred:

  • retry is gated on kill -0: an alive-but-unready child never triggers a retry, it fails immediately;
  • disown dropped so wait genuinely reaps the child (on bash 3.2, wait after disown returns 0 immediately — it was a silent no-op); the child's exit status is now actually used in the non-bind diagnostic;
  • one stderr line per retry with attempt number, port, and reason (fixture 10 asserts exactly one such line);
  • the header comment now notes that a pinned SMOKE_PORT disables the retry.

(The disown removal would have let bash print a stray Terminated job report at exit; the EXIT trap now kills and reaps, which keeps stderr clean and collects the children.)

New deterministic fixtures (in --self-test, so they run in the standalone smoke job and the required Test matrix via test_browser_smoke_negative_fixtures_are_detected):

  • 10 (positive): a test-only python3 shim really holds the drawn port with live listeners, so the first http.server dies with a genuine Address already in use on its own bind attempt; the check must retry and fully pass — exactly two server spawns (collision + recovery) and exactly one retry line.
  • 11: the shim exits 7 with a non-bind error on the first spawn and would serve normally on the second — the check must fail ON attempt 1 (spawn counter == 1) with the captured output in the diagnostic. This is the masking regression: at 448d023 the identical scenario passes the whole check.
  • 12: pinned SMOKE_PORT + the collision shim: fails single-attempt (counter == 1) with the unchanged diagnostic.
  • 13: the shim stays alive without serving: a readiness timeout with a live child fails immediately (counter == 1).

No probabilistic port-squatting is used as proof anywhere — every fixture is forced by the shim.

Before/after evidence (same shim, docs, and Chrome across three script versions):

  • Non-bind startup failure once (the shim fails attempt 1, serves attempt 2): base a51c39a fails (exit 1, honest); 448d023 passes — the real failure is masked (exit 0, 2 spawns); new tip fails on attempt 1 (exit 1, 1 spawn, server exited with status 7 … ; server output: shim: synthetic non-bind startup failure …).
  • Real bind collision once: base a51c39a fails (the original ephemeral-collision flake, reproduced deterministically); 448d023 retries and passes; new tip retries and passes (now with the one-line retry log).
  • Squatter collision loop on the new tip: 3,000 ports (20000–22999, 15% of the [20000, 40000) draw range) held with both-stack listeners (a v4-only listener lets macOS SO_REUSEADDR double-bind and starve instead of dying with EADDRINUSE; the both-stack hold reproduces the Linux CI conflict faithfully), N=120 runs with CHROME_BIN=/bin/false and SMOKE_DOCS_DIR set: 0/120 readiness failures — 24 real kernel bind collisions occurred, every one positively identified and retried on a fresh port, and every run failed only at the expected browser stage (browser exited with status 1).

CI on the new tip (81be299): all checks green — Test (Python 3.10/3.11/3.12/3.13/3.14), Configurator browser smoke (now 44s with the four new fixtures), Format check, Build package, check-changes, scan-pr, cla/google (zizmor-* skipping, as on the previous tip).

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Independent blind round-2 review by Astra (Codex), on behalf of caohy1988, of 81be29989e48a8fe87966c3eb1501e1144bf8121 against a51c39a2dfaa6d863a0e16597f7b1b191b86effb. COMMENT event only. The round-1 P1 failure-masking issue is resolved. One nonblocking P2 diagnostic-compatibility issue remains.

P0

None.

P1

None. My finding in review 5330023093 is resolved: the script now captures each attempt's output, requires the child to be dead before classifying a collision, and fails immediately on non-bind exits and live-child readiness timeouts. The browser phase remains outside the retry loop.

P2

Pinned startup diagnostics are not unchanged for non-bind failures or timeouts. At dashboard/looker_studio/tools/browser_smoke.sh:652 and line 667, the new diagnostic branches also apply when SMOKE_PORT is pinned. With the same pinned port and first-spawn shim, base prints server did not become ready on port P (occupied by another process, or failed to start); tip instead prints server exited with status 7 on port P (attempt 1 of 1); server output: .... A live-but-unready child likewise gets a different message. Both versions still exit 1 after exactly one spawn on the specified port, and the occupied-port negative fixture's diagnostic is byte-identical, so this does not block the collision fix. It does fall short of the stated blanket byte-for-byte pinned-path guarantee.

Suggested fix: retain the legacy diagnostic for pinned startup failures in both branches, keeping the detailed diagnostics on the unpinned path, and add exact stderr comparisons for pinned non-bind and live-but-unready cases. Current fixtures 2 and 12 check a substring of the collision diagnostic only.

Independent verification

  • Read the PR description, full base-to-tip diff, full 448d0231b2c05e5af00d4103a3284082e3a51f19..81be29989e48a8fe87966c3eb1501e1144bf8121 delta, complete script, my own round-1 review, and the permitted author fix comment. GitHub's script at this tip matches the worktree byte-for-byte. Scope is the smoke helper plus explanatory comments in its existing pytest caller; no product code changes.
  • Collision classification and cap: lines 609–667 permit another attempt only after a dead child's per-attempt output matches EADDRINUSE or Address already in use. Deterministically forcing a real dual-stack bind collision on every spawn produced exactly 5 spawns, 4 retry messages, exit 1. A real collision followed by a non-bind exit stopped on spawn 2 and surfaced status 42. Silent exits with status 42 and status 0 each failed on spawn 1, with no retry.
  • Pinned behavior: base and tip each used the requested port once for collision, non-bind, live-but-unready, and free-port/browser-failure cases. Complete stderr was byte-identical for collision and the /bin/false browser case; the other two differences are the P2 above.
  • Cleanup and exit codes: the EXIT trap remains installed, now kills and waits for children (lines 56–69); failed startup children are reaped and their PID cleared before retry/failure. All 13 additional startup-path cases exited 1 as expected, removed their temporary sites, and left none of the recorded server PIDs alive. CHROME_BIN=/bin/false failed after one server spawn, without retry. The complete browser execution/status/DOM assertion section at lines 671–764 is byte-identical to base; setup errors remain hard failures under set -e.

Regression fixtures tested against deliberate regressions

I extracted each new fixture unchanged into a temporary runner and tested it against complete temporary script copies; the worktree was never edited. All four fixtures passed against the tip and failed against their targeted mutation:

Fixture Deliberate regression Observed rejection
10, real collision then success (line 403) Disable retries Collision was not retried to success
11, non-bind fail-fast (line 429) Retry all dead-child failures Healthy second spawn masked the failure; fixture rejected the success
12, pinned port (line 454) Allow five pinned attempts Spawn counter detected 2 instead of 1
13, live-but-unready (line 480) Continue after readiness timeout Spawn counter detected 2 instead of 1

Commands and CI

  • env -u SMOKE_PORT -u CHROME_BIN -u SMOKE_DOCS_DIR -u SMOKE_SHIM_REAL -u SMOKE_SHIM_MODE -u SMOKE_SHIM_COUNTER PYTHONDONTWRITEBYTECODE=1 python3 -m pytest -p no:cacheprovider tests/test_looker_studio_dashboard.py -q -s — 29 passed in 151.43s, including normal real-Chrome smoke and all 13 self-test fixtures, on macOS/Bash 3.2/Python 3.13.5.
  • bash -n dashboard/looker_studio/tools/browser_smoke.sh and git diff --check a51c39a2dfaa6d863a0e16597f7b1b191b86effb HEAD — passed.
  • Repository search confirmed callers at .github/workflows/ci.yml:102,105 and tests/test_looker_studio_dashboard.py:1024,1048; the required Python test matrix therefore executes the new fixtures too.
  • gh pr checks 497 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK — every executed check passed; four zizmor jobs skipped. CI run 36321396326 is completed/success at the exact reviewed tip, including Python 3.10–3.14, Configurator browser smoke, format, and build.
  • Final HEAD remains 81be29989e48a8fe87966c3eb1501e1144bf8121; tracked/untracked status and staged/unstaged diffs are clean. No branch modification, push, or merge.

Evidence limits: I did not rerun the author's probabilistic 7/200-before versus 0/200-after measurement; the conclusions above use deterministic real bind failures and independent executions. No vault files, dual-review result files, or peer reviews/comments were read. The only existing review/comment read were the two explicitly permitted IDs (5330023093 and 5856179724).

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST_CHANGES

Blind re-review (round 2) by Fable (Claude) on caohy1988's behalf. Scope: tip 81be299 vs base a51c39a, round-2 delta 448d023..81be299; files dashboard/looker_studio/tools/browser_smoke.sh and tests/test_looker_studio_dashboard.py. Sources: PR description, diffs, full script in a detached worktree, my own round-1 review (5330118293), the author's fix comment (5856179724), CI status, callers (tests/test_looker_studio_dashboard.py:1024,1048; .github/workflows/ci.yml:102,105), and local runs on macOS (bash 3.2.57, Python 3.13.7, curl 8.7.1, Google Chrome). One P1 (two-line fix in a new fixture), no P0. Everything else in the spec checks out; details below.

Round-1 items

  • P2.1 retry not specific to a collision — resolved. A retry now requires a dead child (kill -0 false at L645) and an EADDRINUSE|Address already in use match in that attempt's captured output (L658). Alive-but-unready fails immediately at L652; any other death fails at L667 with the real exit status and the captured output.
  • P2.2 wait after disown was a no-op — resolved. disown dropped (L629-630); wait genuinely reaps at L650/L656 (the harness below shows the child's real status 7 surfacing), and the trap kills and reaps (L59-66).
  • P2.3 silent retries / last-port-only message — resolved. One stderr line per retry with attempt, cap, port and reason (L661); fixture 10 asserts it.
  • P2.4 follow-ups — header doc done (L44-46). --bind 127.0.0.1 and putting DECOY_PID (L130) in cleanup() (L56-68) remain open, as agreed out of scope.

Spec verification (independent)

  • Retry only on a positively identified port-in-use failure. L656-667: the classification runs only after the child is confirmed dead; the grep at L658 is the sole retry gate; the continue at L662 is the only retry path. Non-bind exit 7 via the shim: exit 1, 1 spawn, server exited with status 7 on port … (attempt 1 of 5); server output: shim: synthetic non-bind startup failure …. Alive-but-unready: exit 1, 1 spawn, 11 s, (server still running, never answered the readiness nonce).

  • 5-attempt cap kept. L609, L626, L660-664. A shim that collides on every spawn: 5 spawns, 4 retry lines, then the original server did not become ready on port … (occupied by another process, or failed to start), exit 1, 3 s.

  • Pinned SMOKE_PORT = one unchanged attempt. L610-612 forces ATTEMPTS=1. Held a decoy http.server on a port and ran base a51c39a and the tip pinned to it: both exit 1, stderr byte-identical (cmp). Pinned + collision shim: 1 spawn, original wording (fixture 12 pins it; fixture 2 now pins it too at L139). Only difference: a pinned non-bind death or alive-but-unready child now gets the more specific message (exit code unchanged) — see P2.1.

  • Cleanup, traps, exit codes. Trap (L56-69) and fail (L71-74) keep their semantics. SERVER_PID is blanked on every failed attempt (L651, L657) so the trap never targets a stale pid, and on the continue path before the next spawn. No leftover http.server/sleep processes after any run; empty stderr on the real self-test and main check, so dropping disown did not surface a stray Terminated. bash -n and shellcheck -S style clean.

  • Fixtures catch their regressions. I extracted make_shim (L295-391) verbatim and ran each fixture's exact environment against other script versions from /tmp (worktree untouched):

    scenario script exit spawns retry lines fixture outcome
    F10 collide-first tip 0 2 1 pass
    F10 collide-first base a51c39a 1 1 0 would FAIL at L414 — catches "no retry"
    F11 nonbind-first 448d023 0 2 0 would FAIL at L439 — catches masking (confirms the author's claim)
    F11 nonbind-first tip 1 1 0 pass
    F12 pinned + collide tip 1 1 0 pass, original wording
    F12 pinned + collide tip with ATTEMPTS=1 removed 1 2 1 would FAIL at L470 and L472 — catches a retrying pinned path
    F13 alive-unready tip 1 1 0 pass, 11 s
    F13 alive-unready 448d023 1 2 0 would FAIL at L494 — catches retry-on-timeout
  • Real runs. --self-test 13/13 OK in 101 s, empty stderr; main check OK in 12 s, empty stderr; pytest tests/test_looker_studio_dashboard.py -k "browser or gate" 4 passed in 152 s with the main venv interpreter.

  • CI on 81be299. All green: Test 3.10-3.14, Configurator browser smoke (44 s), Format check, Build package, check-changes, scan-pr, cla/google; zizmor-* skipped as before.

  • Scope. Product path change is still ~40 lines (L607-669); the rest is self-test fixtures plus a comment in the pytest gate. No unrelated changes.

P0

None.

P1

  1. Fixture 10 re-introduces the collision flake this PR fixes (L416-421). The main loop absorbs up to four genuine collisions, but fixture 10 asserts COLLIDE_SPAWNS = 2 (L417) and RETRY_LINES = 1 (L420). Attempt 2 of that fixture is a plain random draw with zero tolerance: if it lands on a port a stranger holds, the script correctly retries and passes, and the fixture goes red with expected exactly 2 server spawns (collision + recovery), got 3. Verified deterministically with a shim that collides on spawns 1 and 2 (a genuine collision on the recovery draw): script exit 0, 3 spawns, 2 retry lines; both assertions fail. Exposure: the self-test runs in the smoke job and in all five Test jobs, so the PR reduces the zero-tolerance draws per CI run from 54 to 6 instead of to 0 — inside a required check, with a message that reads like a bug in the retry loop. The fixture is not deterministic in the sense the round-2 spec asks for. Two-line fix that keeps the proof exact (fixtures 11 and 13 already prove a retry happens only on EADDRINUSE, so every extra spawn is a genuine collision and must be matched 1:1 by a retry line):

    COLLIDE_SPAWNS="$(grep -c '' "$COLLIDE_COUNT" || true)"
    [ "$COLLIDE_SPAWNS" -ge 2 ] && [ "$COLLIDE_SPAWNS" -le 5 ] ||
      fail "self-test 10 FAILED: expected 2-5 server spawns (forced collision, any genuine collisions, recovery), got $COLLIDE_SPAWNS"
    RETRY_LINES="$(grep -c 'already in use; retrying on a fresh port' "$COLLIDE_ERR" || true)"
    [ "$RETRY_LINES" = "$((COLLIDE_SPAWNS - 1))" ] ||
      fail "self-test 10 FAILED: expected one retry line per failed spawn ($((COLLIDE_SPAWNS - 1))), got $RETRY_LINES"

    Also update the fixture comment (L397, "exactly two server spawns") and the header (L34-35) to match.

P2

  1. Pinned-path wording changed for non-bind deaths (L652, L667). Base: server did not become ready on port P (occupied by another process, or failed to start); tip: server exited with status 7 on port P (attempt 1 of 1); server output: …. Exit code unchanged, and the bind-conflict wording that fixtures 2 and 12 depend on is byte-identical. This is better diagnostics, not a regression; the PR description's "failure message is byte-identical" and "one file, nothing else" just no longer describe the tip — refresh the description before merge so the squash message is accurate.
  2. L669 is unreachable. Every non-READY path inside the loop now fails or continues, and the last EADDRINUSE attempt fails at L664. Keep it as a guard or drop it; if kept, a one-line comment saves the next reader from hunting for the path that reaches it.
  3. Carried-over follow-ups, not for this PR. DECOY_PID (L130) still leaks on an abnormal self-test exit; --bind 127.0.0.1 for the server (L629) and the decoy (L129) would remove most of the collision class at the source.
  4. Cost. Fixture 13 spends ~10 s in the 20-probe loop and fixture 10 adds a full Chrome run; the smoke job went 21 s → 44 s and each Test job pays the same. Fine for a required gate; noting it because the author already flagged the suite's slowest tests for a separate change.

Blind-review disclosure

Read only: the PR description, diffs, worktree code, CI status, my own round-1 review 5330118293, and the author's comment 5856179724. No other review, review comment, or issue comment on #497 was read.

Fixture 10 asserted exactly two server spawns and exactly one retry
line, but the recovery port draw is random: a genuine second collision
on a recovery draw makes the check correctly retry again within its
five-attempt cap, and the fixture then failed a healthy run — the
fixture, not the script, was flaky.

The assertion now pins the contract instead of one draw outcome: 2-5
server spawns (the first attempt collided — the shim only injects on
spawn 1 — with at least one recovery, inside the five-attempt cap) and
one retry line per spawn past the first. A genuine environmental
collision on a recovery draw now passes with spawns=3 and two retry
lines; a dropped or duplicated retry line, or a run past the cap, still
fails. The header, self-test preamble, and fixture comments are updated
to match.

No behavior change: a retry still requires a positively identified
port-in-use, non-bind failures and alive-but-unready servers still fail
fast, the unpinned path keeps the five-attempt cap, and a pinned
SMOKE_PORT stays a single attempt with unchanged diagnostic text.

Evidence: bash -n; the full --self-test passes; a probe injecting a
genuine second collision on the recovery draw passes with spawns=3 and
two retry lines; the collision fixture (exercised by the whole
--self-test, 50 consecutive runs, 0 failures) holds.
@caohy1988

Copy link
Copy Markdown
Collaborator Author

Round 2 — fixture 10 robustness (e207fa1, on top of 81be299): the round-1 fixture was itself flaky. It pinned exactly two server spawns and exactly one retry line, but the recovery port draw is random — a genuine second collision on a recovery draw makes the script correctly retry again within its five-attempt cap, and the fixture then failed that healthy run.

What changed (only dashboard/looker_studio/tools/browser_smoke.sh — fixture 10 plus its comments): the assertion now pins the contract instead of one draw outcome: 2 <= spawns <= 5 (the first attempt collided — the shim injects only on spawn 1 — with at least one recovery, inside the five-attempt cap) and retry_lines == spawns - 1 (every retry logged exactly one line, the final spawn served). The header, self-test preamble, and fixture-10 comments are updated to match. No behavior change: a retry still requires a positively identified port-in-use; non-bind failures and alive-but-unready servers still fail fast; the unpinned path keeps the five-attempt cap; a pinned SMOKE_PORT stays single-attempt with unchanged diagnostic text.

Why robust: spawns >= 2 proves attempt 1 collided and was retried; spawns <= 5 proves the cap held; retry_lines == spawns - 1 catches a dropped or duplicated retry line while tolerating any number of genuine recovery-draw collisions. Verified directly with a probe that injects a genuine second collision on the recovery draw: the check passes with spawns=3 / retry_lines=2 — exactly the healthy run the old exact 2/1 assertion rejected.

Local evidence (macOS, arm64): bash -n clean; the full --self-test passes (13/13 fixtures); tests/test_looker_studio_dashboard.py 29/29 passed; the collision fixture 50/50 consecutive full --self-test runs with 0 failures (fixture 10 cannot run alone — the self-test has no fixture selector); pyink --check (25.12.0, <26 as CI pins) and isort --check-only clean on the autoformat paths (no Python touched).

CI on e207fa1: all green — Configurator browser smoke (1m10s), Format check, Test (Python 3.10–3.14), Build package, check-changes, scan-pr, cla/google; zizmor jobs skip as usual for non-workflow changes.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Independent blind round-3 re-review by Astra (Codex), on behalf of caohy1988, of e207fa1593e6e933e848b1bc4c71c753e83bb55a against a51c39a2dfaa6d863a0e16597f7b1b191b86effb. COMMENT event only. The round-3 fixture change is sound. My round-1 blocking finding remains resolved; my round-2 nonblocking diagnostic finding remains open.

P0

None.

P1

None. The round-1 failure-masking finding is resolved: the script fails immediately for live-but-unready children and non-bind exits, and retries only after reaping a dead child whose own per-attempt log identifies EADDRINUSE or Address already in use (browser_smoke.sh:652, 665, 674). Browser execution and assertions remain outside the retry loop.

P2

Still open from my round-2 review: pinned non-bind/timeout diagnostics differ from base. At browser_smoke.sh:659 and 674, the new diagnostics also apply to pinned SMOKE_PORT runs. Independent base/tip executions with the same pinned port confirm that non-bind exits and live-child timeouts produce different stderr. Both versions still fail with exit 1 after exactly one spawn on that port. Occupied-port and browser-exit diagnostics are byte-identical. Thus the negative fixture's contract is preserved, but the blanket claim that the pinned path is byte-for-byte unchanged is not.

Suggested fix: retain the legacy startup diagnostic for pinned runs in these two branches, and add exact stderr comparisons for pinned non-bind and live-timeout cases. Current fixtures 2, line 141 and 12, line 478 check only the collision diagnostic, using substring matching. This remains nonblocking; round 3 does not introduce it.

Round-3 fixture verification

The new assertions at browser_smoke.sh:423–428 tolerate additional collisions while requiring recovery within five spawns and exactly one log line per retry. I tested the extracted fixture assertions against complete temporary copies of the script, without editing the worktree:

  • Injected 1, 2, 3, and 4 consecutive genuine dual-stack bind collisions on the script's randomly drawn ports, three repetitions each in shuffled order: 12/12 passed, with 2–5 spawns. Injection held real listening sockets and invoked the real Python HTTP server; it did not fabricate collision text.
  • Restoring round 2's exact-count assertions rejected the healthy three-spawn recovery after two collisions. Round 3 accepts that case.
  • Five consecutive collisions correctly exhaust the real cap: exit 1, 5 spawns, 4 retry messages. Tolerance is bounded; the fixture correctly fails if all five candidates collide.
  • All four startup fixtures passed against the tip with real Chrome available. Their targeted mutations were rejected as follows:
Deliberate regression in a temporary copy Fixture outcome
Disable retries 10 fails because the first collision cannot recover
Reduce cap to three, inject three collisions 10 fails because recovery needs a fourth spawn
Allow six attempts, inject five collisions 10 rejects six spawns
Drop or duplicate retry logging 10 rejects incorrect retry-line count
Retry a non-bind startup failure 11 rejects the masked success on spawn 2
Retry a pinned collision 12 rejects two spawns
Retry a live-child readiness timeout 13 rejects two spawns

The repeated collision and several mutation probes used a healthy DOM browser stub to isolate server/retry behavior; the complete pytest run and reference fixture 10 used real Chrome. The fixture assertion blocks were unchanged in these probes; the temporary injection shim was extended to force the specified number of real collisions and record child PIDs/site paths.

Other verification

  • Read the PR description, full base-to-tip diff, complete script, 81be29989e48a8fe87966c3eb1501e1144bf8121..e207fa1593e6e933e848b1bc4c71c753e83bb55a delta, both permitted own reviews, and both permitted author comments. GitHub's script matches this worktree byte-for-byte.
  • Round 3 changes only fixture 10's assertions and related comments. The main check is byte-identical to round 2; browser execution/status/DOM checks are byte-identical to base. The Python test file's executable AST is identical to base. Scope remains two focused test/helper files.
  • The runtime cap is five, or one for nonempty SMOKE_PORT (lines 616–619). A collision followed by a non-bind error stopped on spawn 2; non-bind exits with status 0 and 42 each failed on spawn 1. A /bin/false browser failed without server retry. The EXIT trap remains installed, now killing and waiting for children; failed startup children are reaped before retry/failure. The completed probes left no recorded server child alive or temporary site behind.
  • env -u SMOKE_PORT -u CHROME_BIN -u SMOKE_DOCS_DIR -u SMOKE_SHIM_REAL -u SMOKE_SHIM_MODE -u SMOKE_SHIM_COUNTER PYTHONDONTWRITEBYTECODE=1 python3 -m pytest -p no:cacheprovider tests/test_looker_studio_dashboard.py -q -s — 29 passed in 152.73s, including normal real-Chrome smoke and all 13 self-test fixtures, on macOS/Bash 3.2/Python 3.13.5.
  • bash -n dashboard/looker_studio/tools/browser_smoke.sh and git diff --check a51c39a2dfaa6d863a0e16597f7b1b191b86effb HEAD passed. Repository rg confirmed callers in .github/workflows/ci.yml:102,105 and tests/test_looker_studio_dashboard.py:1024,1048, including the required Python matrix gate and occupied-port negative fixture.
  • gh pr checks 497 --repo GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK — every executed check passed; four zizmor jobs skipped. CI run 36330693997 is completed/success at the exact reviewed tip, including Python 3.10–3.14, Configurator browser smoke, formatting, and build.

I did not rerun the author's 7/200-before versus 0/200-after measurement or the claimed 50 full self-tests. No vault files, dual-review result files, or peer review material were read. Existing reviews/comments accessed were only IDs 5330023093, 5330464675, 5856179724, and 5857382194. The detached worktree remains clean at the requested tip; no branch modification, push, or merge.

@caohy1988 caohy1988 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Blind re-review (round 3) by Fable (Claude) on caohy1988's behalf. Scope: tip e207fa1 vs base a51c39a, round-3 delta 81be299..e207fa1; files dashboard/looker_studio/tools/browser_smoke.sh and tests/test_looker_studio_dashboard.py. Sources: PR description, diffs, full script in a detached worktree at the tip, my own round-1/round-2 reviews (5330118293, 5330501026), the author's fix comments (5856179724, 5857382194), CI status, callers (tests/test_looker_studio_dashboard.py:1024,1048; .github/workflows/ci.yml:102,105), and local runs on macOS (bash 3.2.57, Python 3.13.7, curl 8.7.1, Google Chrome). No P0/P1. The round-2 P1 is fixed as specified and the fix is verified independently below; the remaining items are P2.

Round-2 items

  • P1 — fixture 10 pinned exactly 2 spawns / 1 retry line and re-introduced the flake — resolved. L424-428 now assert 2 <= spawns <= 5 and retry lines == spawns - 1; the fixture comment (L399-405), self-test preamble (L93-95) and header (L31-35) match. Verified against a forced second collision on the recovery draw and under real port pressure (tables below).
  • P2.1 description drift ("failure message is byte-identical", "one file") — unchanged; still description-only (tip touches two files; a pinned non-bind death gets the more specific message at L674, exit code unchanged).
  • P2.2 L676 unreachable — unchanged, harmless guard.
  • P2.3 carried-over follow-ups (DECOY_PID L132 not in cleanup() L57-69; --bind 127.0.0.1) — unchanged, out of scope as agreed.

Round-3 delta: no behavior change

git diff 81be299 e207fa1 is one file, +16/-9: header comment (L31-35), self-test preamble comment (L93-95), fixture-10 comment (L399-405) and the two fixture-10 assertions (L424-428). The main check (L614-676), cleanup()/fail (L57-75), fixtures 1-9 and 11-13, and the pytest gate are byte-identical to 81be299. bash -n and shellcheck -S style clean.

Independent verification

Fixture 10 catches regressions and tolerates genuine collisions. I extracted the tip's own shim (L299-391) verbatim with two lines parameterised (inject on spawns 1..K instead of spawn 1 only; log the port per spawn, so the line count the fixture reads is unchanged) and ran each script variant's main check with real Chrome under fixture 10's exact environment, then applied both the new (e207fa1) and the old (81be299) assertions. Variants live in /tmp; the worktree was not modified.

variant K (forced collisions) script exit spawns retry lines new assertions old assertions
tip 1 0 2 1 pass pass
tip, genuine 2nd collision on the recovery draw 2 0 3 2 pass FAIL (spawns=3) — the round-2 flake
tip 4 0 5 4 pass (upper bound) FAIL
tip, cap exhausted 5 1 5 4 FAIL at L415 (if !) — correct: L671 fires with the original wording FAIL
base a51c39a (no retry) 1 1 1 0 FAIL at L415 FAIL
448d023 (retry-everything, no log line) 1 0 2 0 FAIL at L427 FAIL
tip with the retry line (L668) dropped 1 0 2 0 FAIL at L427 FAIL
tip with the retry line duplicated 1 0 2 2 FAIL at L427 FAIL
tip with ATTEMPTS=6 (L616) 5 0 6 5 FAIL at L424 FAIL
tip with ATTEMPTS=6 1 0 2 1 pass (see P2.2) pass
tip with the draw (L634) hoisted out of the loop 1 0 2 (same port twice) 1 pass (see P2.1) pass

Tolerance under repeated random collisions. A squatter held 3000 random ports in [20000, 40000) with both-stack listeners (15% pressure, seed fixed), and fixture 10's environment ran 100 times against the tip with CHROME_BIN=/bin/false (every run must end at browser exited with status 1). Per run I checked: no server-phase failure text, 2 <= spawns <= 5, retry lines == spawns - 1, and that every retried port after the forced first was actually a squatted port.

runs ok spawns=2 spawns=3 spawns=4 genuine recovery-draw collisions retries on a non-squatted port
100 100 89 9 2 13 0

The old exact assertions would have failed 11 of these 100 runs. Under the same squatter the full --self-test (real Chrome) passed twice, 13/13, in 102 s and 108 s, with empty stderr; without the squatter 13/13 in 100 s, empty stderr. No leftover http.server/sleep processes after any run.

Fixtures 11-13 still catch their regressions (unchanged since round 2, re-run on this tip): non-bind first spawn — tip exit 1 / 1 spawn with server exited with status 7 … server output: shim: synthetic non-bind …, 448d023 exit 0 / 2 spawns (fixture 11 would fail at L449); pinned + collision — tip exit 1 / 1 spawn / original wording, tip with the ATTEMPTS=1 gate (L617-619) removed → 2 spawns (fixture 12 would fail at L476); alive-but-unready — tip exit 1 / 1 spawn / 10 s, 448d023 → 2 spawns (fixture 13 would fail at L500).

Pinned path byte-identical. Held a decoy http.server on port 31408 and ran base a51c39a and the tip pinned to it: both exit 1 in 0.6 s, stdout and stderr cmp-identical (browser smoke: server did not become ready on port 31408 (occupied by another process, or failed to start)).

Failure masking (unchanged from round 2, re-read at the tip). A retry needs a dead child (L644/L652) and an EADDRINUSE|Address already in use match in that attempt's captured output (L665); continue at L669 is the only retry path. Alive-but-unready fails at L659, any other death at L674 with the real exit status and captured output, cap exhaustion at L671 with the original wording. READY is only ever set by the nonce round-trip (L640-641), so a stranger's server can never satisfy readiness.

Tests and CI. pytest tests/test_looker_studio_dashboard.py with the main venv interpreter: 29 passed in 152 s. CI on e207fa1: Configurator browser smoke (1m10s), Test 3.10-3.14, Format check, Build package, check-changes, scan-pr, cla/google all green; zizmor-* skipped as before.

P0

None.

P1

None.

P2 (non-blocking)

  1. Fixture 10 cannot tell a fresh-port retry from a same-port retry (L634, L423-428). With the draw hoisted out of the loop the script retried on the same port (22935 twice), and the fixture passed, because the shim releases its holders when spawn 1 exits. The fixture's stated contract is "retried on a fresh port", so it does not currently guard the one line the whole fix depends on. Deterministic fix in the collide-first branch (L352-367): after subprocess.run returns, os.fork() a child that keeps the inherited holder sockets open (time.sleep(60); os._exit(0)), write its pid to "$COUNTER.holder", and have fixtures 10 and 12 kill "$(cat "$COLLIDE_COUNT.holder")" 2>/dev/null || true after the run. A same-port retry then hits EADDRINUSE again, exhausts the cap and fails the fixture at L415; a fresh draw is unaffected (a 1/20000 redraw is a genuine collision and is tolerated). The cheaper alternative — log the port per spawn and assert pairwise-distinct ports — carries a ~1/20000-per-retry false failure, which is exactly the class this PR removes, so I would take the holder route.

  2. The five-attempt cap is not pinned by any fixture (L616, L424). ATTEMPTS=6 passes fixture 10 unless a run sees five genuine collisions (≈1e-6 at CI pressure). A collide-always shim mode (gate [ "$SPAWNS" = "1" ] || [ "$MODE" = collide-always ] at L317, reusing the collide-first body) plus a fixture asserting exit 1, exactly 5 spawns, 4 retry lines and the did not become ready on port … (occupied by another process, or failed to start) wording would pin both the cap and the cap-exhaustion diagnostic, which fixtures 2/12 only pin for the pinned path. About 15 lines, ~3 s, no Chrome.

  3. Carried over, unchanged (not for this PR). PR description still says "failure message is byte-identical" and "one file"; L676 unreachable; DECOY_PID (L132) not in cleanup(); --bind 127.0.0.1 for the server (L636) and the decoy (L131). Worth refreshing the description before the squash so the merge message is accurate.

  4. Cost. The smoke job took 1m10s on this tip vs 44 s on 81be299 for a comment-and-assertion-only delta, so that is runner variance rather than the change; each Test job still pays the full self-test (2-3.5 min per job here).

Blind-review disclosure

Read only: the PR description, diffs, worktree code, CI status, my own reviews 5330118293 and 5330501026, and the author's comments 5856179724 and 5857382194. No other review, review comment, or issue comment on #497 was read before posting.

@haiyuan-eng-google
haiyuan-eng-google merged commit de0d845 into GoogleCloudPlatform:main Sep 28, 2026
15 checks passed
haiyuan-eng-google pushed a commit that referenced this pull request Sep 29, 2026
…st (#501)

* chore(release): 0.5.4 — compaction_windows view, smoke-test unpickling allowlist

Bump the version to 0.5.4 and cut the CHANGELOG for the ten PRs merged
since v0.5.3 (#490–#497, #499, #500). [Unreleased] is left empty; the
#494 entry moves into [0.5.4].

* docs(changelog): tighten 0.5.4 compatibility notes

List every incidental name #490/#496 removed and where each lives
now, fix the permission repair to `chmod go-w`, scope the log-dir
symlink rule to logs outside the state directory, and qualify the
tracing checks' platform fallbacks.

* chore(release): date 0.5.4 for 2026-09-29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants