Skip to content

test(session-routing): seed exited-worker sessions deterministically - #5625

Open
deavgprime wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
deavgprime:fix/session-exited-worker-readiness
Open

deavgprime wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
deavgprime:fix/session-exited-worker-readiness

Conversation

@deavgprime

Copy link
Copy Markdown
Contributor

What changed and why

The exited-worker test can put all 200 seed requests on one worker through the shared TCP listener. It then fails its setup assertion before testing the worker exit, as reported in #5433.

Seed two sessions on each worker through its private socket and check the recorded owner. After killing one worker and waiting for its replacement, verify all sessions through the public HTTP endpoint. Assert that both sessions from the killed worker return 410 and every surviving session returns 200 with reward 1.

The socket probe is shared with the existing readiness check. Worker shutdown and replacement timeouts are preserved.

Fixes #5433.

Validation

  • NEMO_GYM_MULTIWORKER_E2E=1 RAY_TMPDIR=/tmp python -m pytest -q tests/e2e/session_routing/test_session_routing_e2e.py tests/unit_tests/server_runtime/test_session_routing.py --cpu: 94 passed.

  • Serialized seed requests with an async lock to force connection reuse. The original test failed with all 200 sessions on one worker; the fixed test passed under the same constraint.

  • Temporarily changed the lost-worker response from 410 to 404. The revised test failed at the lost-owner assertion. Restored the runtime code afterward.

  • python -m pre_commit run --all-files --verbose: passed. The guardwords hook skipped its scan because the private catalog is unavailable.

Rollout evidence: N/A, test-only change. The end-to-end tests use real local server processes and a fake inference backend.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 19:54
@copy-pr-bot

copy-pr-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Nov 4, 2026
async with aiohttp.ClientSession(
connector=aiohttp.UnixConnector(path), cookie_jar=aiohttp.DummyCookieJar()
) as client:
for _ in range(2):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keep the scale of the post-kill burst here.
Before this change, the test sent 200 verifies at once after the kill, and every session the killed worker held was among them.
That was the only place where many requests from one worker are forwarded to the same dead socket at the same time.
On that path, each failed forward calls _discard_client, which closes the shared client that other requests may still be connecting through.
Those requests still get 410 today, but nothing else in the suite sends them concurrently: the router unit tests send one at a time.
With two sessions per worker, only two requests reach the dead socket, so a regression in that race would go unnoticed.
Seeding EPISODES sessions adds roughly 8 seconds to the test, and the test stays deterministic because each worker is still seeded through its own socket:

Suggested change
for _ in range(2):
for _ in range(EPISODES // WORKERS):

assert len(owners) == WORKERS, owners
# uvicorn replaces the worker; the replacement does not hold the killed worker's sessions.
victim = deployment.resources_worker_of(owners.most_common(1)[0][0])
victim_owner = owners.most_common(1)[0][0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: every worker now holds the same number of sessions, so most_common returns whichever owner was inserted first.
The call reads as if the counts could differ.
Naming the choice directly would say what the test means:

Suggested change
victim_owner = owners.most_common(1)[0][0]
victim_owner = next(iter(owners))

Comment on lines 473 to 476
assert all(
owner_of[_session_id(cookies)] in lost_owners for cookies, r in zip(sessions, responses) if r.status != 200
r.status == (410 if owner_of[_session_id(cookies)] == victim_owner else 200)
for cookies, r in zip(sessions, responses)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When this assertion fails, pytest reports only assert False, with no hint of which session got which status.
It is also the only assertion that catches a killed worker's session answering 200 or 502 while the other one answers 410.
Collecting the mismatches would make a CI failure readable without a rerun:

Suggested change
assert all(
owner_of[_session_id(cookies)] in lost_owners for cookies, r in zip(sessions, responses) if r.status != 200
r.status == (410 if owner_of[_session_id(cookies)] == victim_owner else 200)
for cookies, r in zip(sessions, responses)
)
mismatches = [
(owner_of[_session_id(cookies)], r.status)
for cookies, r in zip(sessions, responses)
if r.status != (410 if owner_of[_session_id(cookies)] == victim_owner else 200)
]
assert not mismatches, mismatches

@github-actions github-actions Bot added the sla:author-overdue Author response is over the one-business-day SLA label Nov 5, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-maintainers Waiting on maintainers to respond ci CI, automation, test queue, or workflow infrastructure work area:core Shared APIs, servers, telemetry, health, and registries labels Nov 7, 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:core Shared APIs, servers, telemetry, health, and registries ci CI, automation, test queue, or workflow infrastructure work community-request Issue reported or requested by someone from the community sla:author-overdue Author response is over the one-business-day SLA waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: test_session_of_an_exited_worker_gets_an_explicit_error fails in its precondition

4 participants