fix: health check race condition by waiting for watch stream discovery - #4876
Conversation
Signed-off-by: tzulingk@nvidia.com <tzulingk@nvidia.com>
WalkthroughHealth check flow modified to wait up to 10 seconds for PushRouter's watch stream to discover instances via Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/runtime/src/health_check.rs (1)
270-299: Discovery wait logic looks sound; consider edge‑case handling and configurabilityThe new
timeout(Duration::from_secs(10), router.client.wait_for_instances())block correctly addresses the startup race by ensuring instance discovery (or a clear failure) before sending the health check, and the error messages are descriptive.A couple of non‑blocking refinements you might consider:
- If
wait_for_instances()can ever returnOk(instances)with an empty list, treating that as at least awarn!(or even an earlyErr) would make the “target registered but no backing instances discovered” case more obvious rather than relying solely on a later routing error.- The hard‑coded
10second discovery timeout could be promoted intoHealthCheckConfig(e.g.,discovery_timeout) or at least aconstso it’s easier to tune per environment and stays consistent with the other health‑check timeouts.These are optional and don’t block the fix; the current change is functionally correct for the stated PR goals.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/runtime/src/health_check.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-11T03:24:47.820Z
Learnt from: kthui
Repo: ai-dynamo/dynamo PR: 3004
File: lib/runtime/src/pipeline/network/ingress/push_handler.rs:271-277
Timestamp: 2025-09-11T03:24:47.820Z
Learning: In lib/runtime/src/pipeline/network/ingress/push_handler.rs, the maintainer prefers to keep the existing error comparison logic using format!("{:?}", err) == STREAM_ERR_MSG unchanged until proper error types are implemented, even though it has technical debt. Avoid suggesting changes to working legacy code that will be refactored later.
Applied to files:
lib/runtime/src/health_check.rs
🧬 Code graph analysis (1)
lib/runtime/src/health_check.rs (1)
lib/runtime/src/component/client.rs (1)
instances(63-65)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: sglang (amd64)
- GitHub Check: trtllm (amd64)
- GitHub Check: vllm (arm64)
- GitHub Check: clippy (lib/bindings/python)
- GitHub Check: clippy (.)
- GitHub Check: clippy (launch/dynamo-run)
- GitHub Check: Build and Test - dynamo
ai-dynamo#4876) Signed-off-by: tzulingk@nvidia.com <tzulingk@nvidia.com>
ai-dynamo#4876) Signed-off-by: tzulingk@nvidia.com <tzulingk@nvidia.com>
The Fix:
Added synchronization in
send_health_check_request()to wait for the watch stream to complete its initial discovery before attempting to send the health check:Why this approach:
wait_for_instances()method (no new API)Expected behavior after fix:
Where should the reviewer start?
lib/runtime/src/health_check.rs
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
DIS-1167
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.