Skip to content

[Serve] Add experimental ray-haproxy support behind RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY#62589

Draft
eicherseiji wants to merge 10 commits intoray-project:masterfrom
eicherseiji:seiji/ray-haproxy-m2
Draft

[Serve] Add experimental ray-haproxy support behind RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY#62589
eicherseiji wants to merge 10 commits intoray-project:masterfrom
eicherseiji:seiji/ray-haproxy-m2

Conversation

@eicherseiji
Copy link
Copy Markdown
Contributor

@eicherseiji eicherseiji commented Apr 14, 2026

Summary

Adds support for using the ray-haproxy PyPI package (vendored HAProxy binary) in Ray Serve, gated behind RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY=1 (defaults to off).

When disabled (default): zero behavior change. get_haproxy_binary() returns "haproxy" and Serve uses the system-installed binary as it does today.

When enabled, resolution order:

  1. RAY_SERVE_HAPROXY_BINARY_PATH env var override
  2. Bundled binary from ray-haproxy package
  3. System haproxy on PATH
  4. FileNotFoundError with actionable message

OSError (including PermissionError) from the pip package is caught so that a broken bundled binary falls through to the system haproxy rather than crashing the proxy actor.

Changes

  • constants.py: Add RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY flag
  • haproxy.py: Add get_haproxy_binary(), wire into _start_and_wait_for_haproxy()
  • BUILD.bazel: Add _pip_haproxy env variant for all 3 HAProxy test files
  • test_haproxy_binary.py: Unit tests covering flag-off noop, explicit path validation, OSError fallthrough, and error message quality

CI infrastructure changes (Dockerfile, serve.rayci.yml, release_tests.yaml) are deferred to a follow-up since upstream now uses ray depsets.

Context

This is Milestone 2 of the ray-haproxy deployment plan. Milestone 1 (publishing ray-haproxy to PyPI) is complete: https://pypi.org/project/ray-haproxy/

Test plan

  • Unit tests pass locally (4/4)
  • test_haproxy_metrics integration test passes locally with RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY=1
  • Existing HAProxy Buildkite tests pass (system binary, unchanged)
  • New _pip_haproxy Buildkite variant passes

@eicherseiji eicherseiji added the go add ONLY when ready to merge, run all tests label Apr 14, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 introduces experimental support for using a vendored HAProxy binary from the ray-haproxy PyPI package, controlled by the RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY feature flag. The changes include updates to CI/CD configurations, Dockerfiles, and the internal HAProxy resolution logic to prioritize the bundled binary when the flag is enabled. Feedback was provided to improve the robustness of the binary resolution by catching broader OSError exceptions instead of just FileNotFoundError, ensuring a more reliable fallback to the system binary in case of permission issues.

# Conflicts:
#	python/ray/serve/_private/constants.py
#	python/ray/serve/_private/haproxy.py
aslonnie pushed a commit that referenced this pull request Apr 14, 2026
## Summary

Install the `ray-haproxy` PyPI package in the Serve CI Docker image.
This is a prerequisite for the main PR
#62589 which adds
`RAY_SERVE_EXPERIMENTAL_PIP_HAPROXY` support.

`ray-haproxy` is a standalone binary wheel containing a vendored HAProxy
binary at `site-packages/ray_haproxy/bin/haproxy`. It has no Python
dependencies (`--no-deps`) and does not add anything to PATH — the
binary is only accessible via `from ray_haproxy import
get_haproxy_binary`. It will not interfere with the existing
system-installed HAProxy in the Serve image.

The package is installed but not used by default. It will only be
activated when the experimental flag is set in a follow-up PR.

## Test plan

- [x] `serve.build.Dockerfile` builds successfully
- [x] No impact on existing Serve CI tests (ray-haproxy is installed but
not referenced)

---------

Signed-off-by: seiji <[email protected]>
eicherseiji and others added 4 commits April 14, 2026 16:46
The upstream merge already contains ray depsets. Revert CI-only
files (serve.rayci.yml, serve.build.Dockerfile, BUILD.bazel,
release_tests.yaml) to upstream/master state, keeping only the
core code changes (constants.py, haproxy.py, test_haproxy_binary.py).

Signed-off-by: seiji <[email protected]>
- Re-add py_test_module_list_with_env_variants for HAProxy tests with
  system and pip_haproxy variants (was incorrectly reverted with CI files).
- Rewrite test_haproxy_binary.py: extract shared setup into fixtures,
  group tests by resolution stage (flag-off, explicit path, pip package,
  system fallback), use descriptive names, flatten nesting.

Signed-off-by: seiji <[email protected]>
@eicherseiji eicherseiji force-pushed the seiji/ray-haproxy-m2 branch from 5701b10 to fb41a18 Compare April 14, 2026 23:58
and trim unit tests to what matters

- haproxy.py: widen except FileNotFoundError to except OSError so that
  PermissionError from a broken bundled binary also falls through to
  the system haproxy instead of crashing the proxy actor.
- test_haproxy_binary.py: 8 tests → 4. Keep: flag-off noop guarantee,
  explicit path filesystem validation, OSError fallthrough, and
  actionable error message. Drop tests that just verify return values
  from mocked branches.

Signed-off-by: seiji <[email protected]>
…list

The Ray CI pytest_checker requires all test files to have the
if __name__ == "__main__" snippet. Also reverts BUILD.bazel back
to py_test_module_list per manual edit.

Signed-off-by: seiji <[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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant