Skip to content

[serve] Deflake test_direct_ingress by moving the test gRPC port range below the ephemeral range - #66940

Merged
abrarsheikh merged 3 commits into
ray-project:masterfrom
johntaylor-cell:serve-direct-ingress-grpc-port-range
Oct 14, 2026
Merged

abrarsheikh merged 3 commits into
ray-project:masterfrom
johntaylor-cell:serve-direct-ingress-grpc-port-range

Conversation

@johntaylor-cell

Copy link
Copy Markdown
Contributor

The default direct ingress gRPC range (40000-41000) sits inside the Linux ephemeral port range (32768-60999), where every Ray worker binds its listen port. When a worker takes a port the tests expect free, test_replica_releases_ports_on_shutdown exhausts its "all ports bindable" wait and every later port test fails with it. HTTP (30000-31000) is below the ephemeral range and unaffected.

This pins the gRPC range for both test targets to 31500-32500 via a shared BUILD env and derives the expected gRPC ports from RAY_SERVE_DIRECT_INGRESS_MIN_GRPC_PORT instead of hardcoding 4000N.

…e below the ephemeral range

The default direct-ingress gRPC range (40000-41000) sits inside the kernel
ephemeral range (32768-60999), where every Ray worker binds its listen
port. When a worker takes one of the ports the tests expect free, the
all-ports-bindable wait never passes and every following port test fails.
Pin the test targets to 31500-32500 and derive expected gRPC ports from it.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: john.taylor <[email protected]>
@johntaylor-cell
johntaylor-cell requested a review from a team as a code owner October 12, 2026 18:57
@johntaylor-cell johntaylor-cell added serve Ray Serve Related Issue go add ONLY when ready to merge, run all tests labels Oct 12, 2026
@johntaylor-cell johntaylor-cell self-assigned this Oct 12, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request configures a specific gRPC port range (31500 to 32500) for the direct ingress tests in python/ray/serve/tests/BUILD.bazel to prevent port conflicts with Ray workers, which use the kernel ephemeral range (32768+). In test_direct_ingress.py, hardcoded gRPC ports (previously starting at 40000) are replaced with dynamically calculated ports relative to the configured minimum port using a new helper function _expected_grpc_ports. There are no review comments, so no feedback is provided.

Comment thread python/ray/serve/tests/BUILD.bazel Resolved
…emeral range

Production replicas share the same exposure the tests had: 40000-41000 sits
inside the Linux ephemeral range, so any Ray worker on the node can already
hold one of those ports. Default the gRPC range to 31500-32500 and drop the
test-only BUILD pin, which is now redundant.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: john.taylor <[email protected]>
@abrarsheikh
abrarsheikh merged commit 50c0807 into ray-project:master Oct 14, 2026
6 checks passed
sai-miduthuri pushed a commit that referenced this pull request Oct 16, 2026
…rcent` for start-before-stop rolling updates (#66267) (#67094)

Cherry-pick of #66267 (master commit
9491664) onto `releases/2.60.0`.

## Why

The first three PRs of the in-place-updates series (#66252, #66290,
#66266) are already on `releases/2.60.0`. This picks the fourth, which
adds `max_surge_percent` for start-before-stop rolling updates, so
2.60.0 ships the complete series.

## Cherry-pick details

`git cherry-pick -x` conflicted in one file,
`python/ray/serve/tests/unit/test_deployment_state.py`. The conflict was
positional only: on master, #66243 (push-based replica health) had
appended `TestPushedHealthEndToEnd` and related tests to the end of that
file, and #66267 inserts `TestMaxSurge` right before them. This branch
doesn't have #66243, so git couldn't anchor the hunk and offered the
#66243 tests as part of the incoming side. Resolved by inserting only
the PR's `TestMaxSurge` block (plus its `defaultdict` import) before the
`__main__` guard. The added and removed lines in each of the 17 files
are identical to the master commit's diff.

After the pick, 11 of the 17 files are byte-identical to master at
9491664. The other 6 differ only by master commits that aren't on
this branch and that #66267 doesn't depend on:

- `_private/deployment_state.py`, `tests/unit/test_deployment_state.py`:
#66243.
- `schema.py`, `tests/BUILD.bazel`, `tests/test_controller.py`,
`tests/test_direct_ingress.py`: #66339 and #66940.

No commit on `releases/2.60.0` after the branch cut touched any of these
files.

Not a duplicate: no PR against `releases/2.60.0` references #66267.

## Testing

Run on this branch with the Serve protobuf regenerated from the branch's
`serve.proto` (the pick adds the `max_surge_percent` field).

```
python -m pytest python/ray/serve/tests/unit/test_deployment_state.py python/ray/serve/tests/unit/test_config.py python/ray/serve/tests/unit/test_deployment_class.py python/ray/serve/tests/unit/test_schema.py
3530 passed, 12 skipped
```

```
python -m pytest python/ray/serve/tests/test_deploy_app_3.py python/ray/serve/tests/test_deploy_app_2.py -k surge
13 passed, 41 deselected in 282s
```

`pre-commit run --files <changed files>` passed.

AI assistance was used to prepare this cherry-pick.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Qisheng He <[email protected]>
Signed-off-by: qishengxhe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants