Skip to content

fix: 🐛✅ Fix flaky lease downgrade test - #892

Merged
evaline-ju merged 3 commits into
rossoctl:mainfrom
evaline-ju:vmpool-race
Nov 18, 2026
Merged

evaline-ju merged 3 commits into
rossoctl:mainfrom
evaline-ju:vmpool-race

Conversation

@evaline-ju

Copy link
Copy Markdown
Contributor

Summary

The test checked a counter that goes up a moment before a queued command actually waits for the lease, so on a busy CI machine another step could sometimes cut in ahead of it. It now waits until the command is really in line, so the order no longer depends on timing.

Flake observed on CI on another PR: https://github.com/rossoctl/moca/actions/runs/44351321113/job/134967418439

Checklist

  • Commits are signed off (git commit -s).
  • make lint and the tests for the touched packages pass.
  • Docs: changed behavior, flags or environment variables are reflected in the relevant README or
    docs/ page, with the right maturity label (see docs/CONTRIBUTING-DOCS.md). - N/A
  • Docs: make check-links passes if any Markdown changed. - N/A
  • A new spec or ADR is registered in docs/specs/README.md or docs/adrs/README.md. - N/A

@evaline-ju
evaline-ju requested a review from pdettori as a code owner November 18, 2026 17:19
@evaline-ju evaline-ju added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 18, 2026

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

This removes a flake in TestDowngradeGraceDoesNotCutAfterAnExecStopped. The old wait (pinnedCount == 2) counted B from routeExec onwards, before B was queued on execGate, so SetMode could reach the gate first. The new wait requires B to be parked in execLease's gate select. Go queues blocked senders first-come first-served, and runtime.Stack stops the world while it takes the snapshot, so B is ahead of SetMode.

Verified locally on Go 1.27.3: this test passes 200/200 and 50/50 with -race, it passes with GOTRACEBACK=system, and the full vmpool package passes three runs in a row (-count=3). One nit inline.

Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: Go tests (vmpool)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: all checks pass

Assisted-By: Claude Code

// is fn (`(*pool).execLease`). Unlike pinnedCount, which counts an Exec from routeExec on,
// one counted here is already queued on the channels it waits for, so it gets the gate
// before any waiter that queues after it.
func parkedIn(fn string) int {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit — parkedIn counts across every goroutine in the test binary, and the test waits for exactly 1. A goroutine some other test leaves parked in execLease's gate select (a failure, a future test, -count=N) would make this test time out at 2, with nothing pointing at the real cause.

It's fine today (the package passes -count=3 locally), but scoping the count to this pool would make it independent of other tests, for example matching the receiver argument in the frame with fmt.Sprintf(".%s(%p", fn, p).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Scoped parkedIn to the pool's receiver as suggested in 55511d5; I checked that the parked frame prints the exact pointer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correction: on linux/amd64 the parked frame prints the receiver as _, so the %p match never matched and CI failed. I replaced it in 09159c1 with a baseline: the test counts the parked execLease goroutines before starting B, then waits for one more.

Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
@evaline-ju
evaline-ju merged commit d2355b0 into rossoctl:main Nov 18, 2026
17 checks passed
@evaline-ju
evaline-ju deleted the vmpool-race branch November 18, 2026 19:57
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants