Skip to content

ssh: fix flaky TestOutputAttachRetryExhaustion/Unavailable - #8209

Open
pietern wants to merge 1 commit into
mainfrom
pietern/fix-sandboxexec-retry-exhaustion-flake
Open

pietern wants to merge 1 commit into
mainfrom
pietern/fix-sandboxexec-retry-exhaustion-flake

Conversation

@pietern

@pietern pietern commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Changes

Fix the flaky TestOutputAttachRetryExhaustion/Unavailable (experimental/ssh/sandbox/internal/sandboxexec). Test-only change.

The test reattaches to a server that keeps failing and expects the server's last error code (Unavailable). Output gives up after its one-minute retry budget; if the budget expires while an attach request is still in flight, it returns the budget's DeadlineExceeded instead. That is intended behavior, so the test now accepts either code. The other checks (the retries exhaust within their bound) are unchanged.

Dashboard

  • error/3963: Not equal: expected: 0xe (actual 0x4), macOS, 2 failures in 30 days; both runs took 60.2-60.7s, matching the retry budget.

Tests

  • Reproduced locally by delaying the test's fake server by 1.5s: the old check failed with expected: 0xe, actual: 0x4 after 60.2s; with the fix it passes.
  • The package passes.

Gaps and risks

  • The test no longer tells Unavailable from DeadlineExceeded for the exhausted case; the bound on total retry time is still checked.
  • Risk: low (test-only).

🤖 AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

The one-minute retry budget can expire while an attach RPC is in flight.
Output.reattach then deliberately reports the budget's DeadlineExceeded
instead of the server's Unavailable. On slow macOS runners the RPC window
is wide enough for this to happen occasionally. Accept either code.

Reproduced locally by delaying the attach handler by 1.5s: the old
assertion fails with "expected: 0xe, actual: 0x4", the new one passes.

Co-authored-by: Isaac <no-reply@databricks.com>
@pietern

pietern commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 /trigger all

AI agent (opus5.5, isaac_claude)

@github-actions github-actions Bot added the test-only-fix PRs that update failing of flaky tests without changing CLI code. label Nov 30, 2026
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 4fa4c9b

Run: 46446542979

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 90 6 2:03
💚​ aws-windows-latest-4core-16gb 1 90 6 3:17
💚​ azure linux-2core-8gb 1 90 6 2:06
💚​ azure-windows-latest-4core-16gb 1 90 6 3:35
💚​ gcp linux-2core-8gb 1 90 6 2:04
💚​ gcp-windows-latest-4core-16gb 1 90 6 3:20
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:34 azure-windows-latest-4core-16gb TestAccept
3:19 gcp-windows-latest-4core-16gb TestAccept
3:15 aws-windows-latest-4core-16gb TestAccept

@pietern
pietern marked this pull request as ready for review November 30, 2026 15:51
@pietern
pietern requested review from a team as code owners November 30, 2026 15:51

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 4fa4c9b. Each finding was verified against the code.

No blocking issues found. 1 non-blocking comment(s) below.

This PR fixes the flaky TestOutputAttachRetryExhaustion/Unavailable by accepting DeadlineExceeded as well as the server's last code. Your diagnosis matches reattach in client.go: when the one-minute budget runs out during an in-flight attach, lines 197-198 replace the error with DeadlineExceeded. The catch is that the Unavailable subtest can no longer tell the two outcomes apart, so the flake is gone but so is the check. A deterministic fix would keep it.

// The retry budget can expire while an attach is in flight (likely
// on slow runners); Output then reports the budget's DeadlineExceeded
// instead of the server's last code.
require.Contains(t, []codes.Code{code, codes.DeadlineExceeded}, status.Code(err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nice to have] With DeadlineExceeded accepted, the Unavailable case passes the same check as the DeadlineExceeded case. A regression where reattach always returns the budget's error, for example client.go:214 returning status.FromContextError(retryCtx.Err()).Err(), would still pass: the duration and attach-count checks hold either way. The race exists because the time.Minute budget at client.go:163 is hard-coded. Could we make it injectable, the way lifetime is passed through Follow? Then each outcome can be pinned deterministically, and the test drops from about 60s to milliseconds. The other option is to have reattach return the last server error when the budget expires mid-attach, which makes the original require.Equal correct.

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.

🤖 Agreed: with DeadlineExceeded accepted, the Unavailable subtest can't catch a regression where reattach always returns the budget's error. No other test pins the server code on exhaustion either; TestOutputCancelsAttachRetry only checks Canceled.

There's no test-only way to close this. The outcome depends on whether the hard-coded time.Minute budget at client.go:163 expires during an attach RPC or during backoff, and the test can't control that without changing client.go. Both options you list change the production retry path. I'd rather keep this PR test-only so the flake fix lands, and do it in a follow-up. I lean toward returning the last server error when the budget expires mid-attach, falling back to DeadlineExceeded when no attempt has finished yet. Users then see the real cause, and the original require.Equal holds again. An injectable budget would also cut the ~60s test. I've noted the proposal on the dashboard ticket; the maintainers decide whether to take it.

AI agent (opus5.5, isaac_claude)

This branch has not been deployed

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

Labels

factory-generated test-only-fix PRs that update failing of flaky tests without changing CLI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants