Repository navigation
[Serve] Fix flaky test_replica_metrics_fields in test_metrics_haproxy - #60953
Conversation
PR ray-project#60823 throttled the serve_deployment_replica_healthy gauge with a 10s cache TTL and bumped the timeout in test_metrics.py to 40s, but missed applying the same fix to the HAProxy variant. The default 10s wait_for_condition timeout is too short now that the gauge is cached. Increase the timeout to 40s to match test_metrics.py. Signed-off-by: Seiji Eicher <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request fixes a flaky test test_replica_metrics_fields in test_metrics_haproxy.py by increasing the timeout for a wait_for_condition call. This change is necessary because the metric being checked, serve_deployment_replica_healthy, is now cached for 10s, making the previous default timeout too short. The fix aligns the HAProxy test with a similar fix made in test_metrics.py. The change is correct and addresses the issue described. I've added one suggestion to improve code clarity by explaining the magic number 40 with a comment.
| wait_for_condition( | ||
| lambda: len(get_metric_dictionaries("ray_serve_deployment_replica_healthy")) | ||
| == 3, | ||
| timeout=40, |
There was a problem hiding this comment.
The timeout value 40 is a magic number. To improve readability and future maintenance, please add a comment explaining why this value was chosen. Based on the PR description, it's to account for the 10s cache TTL on the serve_deployment_replica_healthy gauge.
| timeout=40, | |
| timeout=40, # Needs to be >10s to account for the metric cache TTL. |
Signed-off-by: Seiji Eicher <[email protected]>
| - serve | ||
| - python | ||
| - flaky | ||
| - skip-on-premerge |
There was a problem hiding this comment.
i dont think we want to do this?
There was a problem hiding this comment.
I am adding this temporarily so I can test the fix on premerge, otherwise it seems RAYCI_SELECT cannot activate the flaky test.
There was a problem hiding this comment.
Will remove before setting PR to "Ready for review"
Signed-off-by: Seiji Eicher <[email protected]>
This reverts commit 370925c. Signed-off-by: Seiji Eicher <[email protected]>
This reverts commit e6901ec. Signed-off-by: Seiji Eicher <[email protected]>
The HAProxy BUILD target was missing the RAY_SERVE_REPLICA_HEALTH_GAUGE_REPORT_INTERVAL_S=0.1 env var that the non-HAProxy metrics tests already set. Without it, the health gauge uses the default 10s cache TTL, causing scrapes to miss gauges that haven't been refreshed within the export window. The non-HAProxy test_metrics.py target has had this override since PR ray-project#60823 added the caching optimization. Signed-off-by: Seiji Eicher <[email protected]>
…o fix-haproxy-metrics-timeout Signed-off-by: Seiji Eicher <[email protected]>
|
|
…ray-project#60953) ## Why are these changes needed? `test_metrics_haproxy.py::test_replica_metrics_fields` is failing in postmerge. - ray-project#60823 added a 10s cache on the health gauge, with `RAY_SERVE_REPLICA_HEALTH_GAUGE_REPORT_INTERVAL_S=0.1` in the metrics BUILD target to keep tests passing - ray-project#60914 added a HAProxy BUILD target that re-runs serve tests with `RAY_SERVE_ENABLE_HA_PROXY=1`, but didn't carry over that env var - Without it, the health gauge goes stale between scrapes and the test misses one deployment's metric Fix: add the missing env var to the HAProxy target. Example failure: https://buildkite.com/ray-project/postmerge/builds/15966#019c49dc-52b4-40dd-a67e-9f5ea5c61755 --------- Signed-off-by: Seiji Eicher <[email protected]> Signed-off-by: Adel Nour <[email protected]>
…ray-project#60953) ## Why are these changes needed? `test_metrics_haproxy.py::test_replica_metrics_fields` is failing in postmerge. - ray-project#60823 added a 10s cache on the health gauge, with `RAY_SERVE_REPLICA_HEALTH_GAUGE_REPORT_INTERVAL_S=0.1` in the metrics BUILD target to keep tests passing - ray-project#60914 added a HAProxy BUILD target that re-runs serve tests with `RAY_SERVE_ENABLE_HA_PROXY=1`, but didn't carry over that env var - Without it, the health gauge goes stale between scrapes and the test misses one deployment's metric Fix: add the missing env var to the HAProxy target. Example failure: https://buildkite.com/ray-project/postmerge/builds/15966#019c49dc-52b4-40dd-a67e-9f5ea5c61755 --------- Signed-off-by: Seiji Eicher <[email protected]>

Why are these changes needed?
test_metrics_haproxy.py::test_replica_metrics_fieldsis failing in postmerge.RAY_SERVE_REPLICA_HEALTH_GAUGE_REPORT_INTERVAL_S=0.1in the metrics BUILD target to keep tests passingRAY_SERVE_ENABLE_HA_PROXY=1, but didn't carry over that env varFix: add the missing env var to the HAProxy target.
Example failure: https://buildkite.com/ray-project/postmerge/builds/15966#019c49dc-52b4-40dd-a67e-9f5ea5c61755