Skip to content

remote-worker: TestCapRefusalsAreBoundedPerVM flakes under -race (samples capRefusalsInFlight before the accept loop registers) #650

Closed

Description

@pdettori

Summary

TestCapRefusalsAreBoundedPerVM (remote-worker/internal/egress/proxy_test.go) flakes under -race: observed 1 in 3 at moca@1b76333 while re-reviewing #647.

Failure:

proxy_test.go:530: no refusal was ever in flight: the test did not exercise the refusal path

Cause

The test offers CONNECTs and samples h.capRefusalsInFlight("vm-1") immediately after each write (proxy_test.go:521), without waiting for the proxy's accept loop to register the refusal. Under -race scheduling every sample can be taken before any refusal is registered, so peak stays 0 and the test fails its own vacuity check (peak == 0) rather than the bound it means to pin.

Context

Found while re-reviewing #647: proto went red twice on that head before passing. The other red was the guestagent EgressForwarder.logf data race, which open PR #645 fixes. This test is untouched by #647 and is a separate defect.

Fix sketch

After offering a refusal, wait for it to register before sampling for the peak — poll capRefusalsInFlight (as TestCapRefusalPastTheBoundClosesWithoutDraining already does at proxy_test.go:552) or otherwise synchronize with the accept loop — instead of sampling opportunistically between writes.

Activity

  1. cwiklik commented on Oct 28, 2026

    @cwiklik
    Contributor

    Fixed by #652 (merged 2026-10-28), which landed the fix this issue sketched:

    • a4680d63 — test(egress): wait for the accept loop in TestCapRefusalsAreBoundedPerVM
    • 55bd74dd — test(egress): enforce the bound across the whole catch-up drain

    The offer loop now waits for the accept goroutine to charge its refusals instead of sampling
    capRefusalsInFlight opportunistically between writes, and the bound is asserted across the whole
    catch-up drain rather than only at whichever sample the poll happened to land on.

    Verified on main at bdab08d9, including the setting that gave the deterministic repro:

    GOMAXPROCS=1 go test -race -run TestCapRefusal -count=10 ./internal/egress/   ok
    GOMAXPROCS=1 go test -race -count=3 ./internal/egress/                        ok
    

    Closing — it stayed open only because #652's body named the flake without a closing keyword.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions