Repository navigation
[Serve] Fix HAProxy config file race condition and draining guard - #61120
Merged
abrarsheikh merged 2 commits intoFeb 18, 2026
Merged
Conversation
Fix two bugs in HAProxy test environments: 1. Use a separate lock file for config writes. The previous pattern opened the config file with "w" mode (which truncates) before acquiring fcntl.flock(), allowing concurrent writers to corrupt each other's output. 2. Add a draining guard in serving() so that a draining proxy returns immediately instead of looping forever waiting for backends to become healthy. Also remove leftover debug print statements from test files. Signed-off-by: Seiji Eicher <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces several important fixes and cleanups for Ray Serve's HAProxy integration. The primary change addresses a race condition during HAProxy configuration file writes by using a separate .lock file. This prevents file truncation issues in concurrent environments. Additionally, a draining guard has been added to the serving() method to avoid infinite loops when a proxy is draining. Finally, some leftover debug print statements have been removed from test files, improving code cleanliness. The changes are well-implemented and address the issues described. The code quality is high, and the fixes are crucial for stability, especially in multi-node testing scenarios.
Signed-off-by: Seiji Eicher <[email protected]>
Contributor
Author
harshit-anyscale
approved these changes
Feb 18, 2026
Contributor
|
good find! |
ans9868
pushed a commit
to ans9868/ray
that referenced
this pull request
Feb 18, 2026
…y-project#61120) ## Why are these changes needed - `test_haproxy` flakiness: https://buildkite.com/ray-project/postmerge/builds/16082#019c6c94-633e-4557-84e1-8a3e0ffd36ba ## Summary - Fix config file write race: use a separate `.lock` file so the config isn't truncated before the lock is acquired. The previous `open("w")` + `fcntl.flock()` pattern allowed concurrent HAProxyManagers (in multi-node test environments on a single machine) to corrupt each other's config output. - Add draining guard in `serving()`: return early if the proxy is draining instead of looping forever waiting for backends to become healthy. - Remove leftover debug print statements from test files. ## Test plan - [x] `test_drain_and_undrain_haproxy_manager` passes 5/5 locally (previously failed ~2-3/5) - [x] CI green on `test_haproxy`, `test_metrics_haproxy`, `test_proxy` --------- Signed-off-by: Seiji Eicher <[email protected]> Signed-off-by: Adel Nour <[email protected]>
Aydin-ab
pushed a commit
to kunling-anyscale/ray
that referenced
this pull request
Feb 20, 2026
…y-project#61120) ## Why are these changes needed - `test_haproxy` flakiness: https://buildkite.com/ray-project/postmerge/builds/16082#019c6c94-633e-4557-84e1-8a3e0ffd36ba ## Summary - Fix config file write race: use a separate `.lock` file so the config isn't truncated before the lock is acquired. The previous `open("w")` + `fcntl.flock()` pattern allowed concurrent HAProxyManagers (in multi-node test environments on a single machine) to corrupt each other's config output. - Add draining guard in `serving()`: return early if the proxy is draining instead of looping forever waiting for backends to become healthy. - Remove leftover debug print statements from test files. ## Test plan - [x] `test_drain_and_undrain_haproxy_manager` passes 5/5 locally (previously failed ~2-3/5) - [x] CI green on `test_haproxy`, `test_metrics_haproxy`, `test_proxy` --------- Signed-off-by: Seiji Eicher <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why are these changes needed
test_haproxyflakiness: https://buildkite.com/ray-project/postmerge/builds/16082#019c6c94-633e-4557-84e1-8a3e0ffd36baSummary
.lockfile so the config isn't truncated before the lock is acquired. The previousopen("w")+fcntl.flock()pattern allowed concurrent HAProxyManagers (in multi-node test environments on a single machine) to corrupt each other's config output.serving(): return early if the proxy is draining instead of looping forever waiting for backends to become healthy.Test plan
test_drain_and_undrain_haproxy_managerpasses 5/5 locally (previously failed ~2-3/5)test_haproxy,test_metrics_haproxy,test_proxy