Skip to content

test(middleware): accept unknown-outcome failures in the hand-over test - #6251

Open
matthewgrossman wants to merge 4 commits into
mainfrom
fix/6250-middleware-hand-over-flake/matthewgrossman
Open

matthewgrossman wants to merge 4 commits into
mainfrom
fix/6250-middleware-hand-over-flake/matthewgrossman

Conversation

@matthewgrossman

@matthewgrossman matthewgrossman commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Summary

During a service hand-over, some calls can fail with an outcome the client can't know: the old server closes the connection while the client is still writing, so call_with_retries correctly doesn't send them again. unary_calls_are_answered_once_across_service_hand_overs expected every call to be answered, so it failed intermittently. Which calls fail depends on timing, so the test can't assert on answers or failure counts without flaking. It now checks only what holds on every run: across hand-overs, a handler never runs more times than calls were made.

Related Issue

Closes #6250

Changes

  • Renamed the test to calls_reach_a_handler_at_most_once_across_service_hand_overs.
  • Callers count every call, answered or failed, and the test asserts handled <= calls. Sending a call again after a handler ran can break that bound.
  • Removed the assertions that depended on timing: every call is answered, answered calls equal handled calls, and failures stay rare.
How the race happens (from an h2 trace)
  1. The draining server sends GOAWAY(MAX), then GOAWAY(37), ignores later streams, and closes the connection.
  2. The h2 client keeps opening streams (39 to 49) after the first GOAWAY.
  3. The client's write fails on the closed connection before it reads GOAWAY(37), so those streams end with stream closed because of a broken pipe instead of a refusal.
  4. A broken pipe doesn't prove the server never ran the call, so call_with_retries doesn't send it again. a_call_the_service_received_is_not_sent_again_after_a_reset requires this.

Follow-up (not in this PR)

The production middleware path (call_with_retries in crates/openshell-supervisor-middleware/src/lib.rs) can also fail a few calls this way during real hand-overs. A follow-up could reduce this at the source: have the client stop opening streams once it sees GOAWAY, or have the draining server keep reading briefly before it closes.

Testing

  • Reproduced on macOS before the change: 1 failure in 300 runs.
  • After the change: 0 failures in 300 runs with 12 CPU-saturating processes running alongside.
  • cargo test -p openshell-supervisor-middleware --lib remote:: passes; fmt and clippy clean.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

…st (fixes #6250)

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@matthewgrossman matthewgrossman added topic:testing Unit, integration, regression, conformance, E2E tests, coverage, flakes, and test infrastructure. area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. topic:extensions Extension APIs and integration points, consistent design, and external use cases. labels Dec 4, 2026
pimlock
pimlock previously approved these changes Dec 4, 2026
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
…test

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>

@gator-review-bot gator-review-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.

gator-agent

PR Review Status

The test can allow transport failures with unknown outcomes during a service hand-over. The new aggregate assertion leaves two behaviors from #6250 unverified: a logical call must reach a handler at most once, and a call explicitly refused before processing must be retried.

Action required: Track handler invocations per logical call and add a deterministic hand-over retry case for an explicitly refused call.

Blocking findings:

  • GATOR-e50debec-01: The aggregate count can hide a duplicate handler invocation and a missed retry.

Carried findings:

  • None

Non-blocking suggestions:

  • None
Gator metadata
  • Validation: Focused middleware test fix for the macOS Branch Checks flake in #6250.
  • Docs: No direct user-facing behavior changes.
  • Checks: Branch Checks running at review time. DCO and the other reported required CI gates passed.
  • E2E: No additional suite needed for this test-only patch.
  • Head SHA: e50debec040b3a4946d286770220af9453a2acef
  • Base SHA: b7626bfb61951301ae6e511afde250d7c6ab64cb
  • Merge base SHA: 8131ae0b6e08caceaf706253bcf7a6edeadda6c0
  • Patch ID: 1f2464fff4ea3c4b60436049333d54b035301754
  • Gator payload: 24
  • Review mode: initial
  • Previous reviewed SHA: none
  • Review budget exhausted: no
  • Maintainer decision required: no
  • Next state: gator:in-review

"every call reached a handler exactly once"
let handled = handled.load(Ordering::SeqCst);
assert!(
handled <= calls,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

gator-agent

Warning · GATOR-e50debec-01 · The aggregate count can hide hand-over retry regressions

Summary During a service hand-over, a call that never reaches a handler can offset a duplicate invocation for another call. The assertion also passes if a stream the server explicitly refused before processing is never retried. Both regressions can pass CI.

Fix Carry a stable logical call ID across attempts and assert at most one handler invocation per ID. Add a deterministic hand-over case that explicitly refuses the first stream before handler entry and requires the same call to reach the replacement service. Keep allowing unknown-outcome failures in the stress test.

Verify Script two logical calls. Deliver one twice and explicitly refuse the other before handler entry with retries disabled. The current assertion accepts two invocations for two calls. The new checks should catch the duplicate and require the refused call to reach the replacement handler.

Agent context
  • Location: crates/openshell-supervisor-middleware/src/remote.rs:608

@gator-review-bot gator-review-bot Bot added the gator:in-review Gator is reviewing or awaiting PR review feedback label Dec 4, 2026

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

area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. gator:in-review Gator is reviewing or awaiting PR review feedback topic:extensions Extension APIs and integration points, consistent design, and external use cases. topic:testing Unit, integration, regression, conformance, E2E tests, coverage, flakes, and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(test): middleware hand-over test fails on a broken pipe on macOS

2 participants