Unverified Commit 55c66a63 authored by Biswa Panda's avatar Biswa Panda Committed by GitHub
Browse files

fix: same endpoint for tcp health check (#4494)

parent 75bf7c9b
...@@ -44,4 +44,5 @@ echo "Using request plane mode: $REQUEST_PLANE" ...@@ -44,4 +44,5 @@ echo "Using request plane mode: $REQUEST_PLANE"
python -m dynamo.frontend --http-port=8000 & python -m dynamo.frontend --http-port=8000 &
DYN_SYSTEM_PORT=8081 \ DYN_SYSTEM_PORT=8081 \
DYN_HEALTH_CHECK_ENABLED=true \
python -m dynamo.vllm --model Qwen/Qwen3-0.6B --enforce-eager --connector none python -m dynamo.vllm --model Qwen/Qwen3-0.6B --enforce-eager --connector none
...@@ -126,12 +126,7 @@ impl EndpointConfigBuilder { ...@@ -126,12 +126,7 @@ impl EndpointConfigBuilder {
// Register health check target in SystemHealth if provided // Register health check target in SystemHealth if provided
if let Some(health_check_payload) = &health_check_payload { if let Some(health_check_payload) = &health_check_payload {
// Build transport based on request plane mode // Build transport based on request plane mode
let transport = build_transport_type( let transport = build_transport_type(request_plane_mode, &endpoint_name, &subject);
request_plane_mode,
&endpoint_name,
&subject,
TransportContext::HealthCheck,
);
let instance = Instance { let instance = Instance {
component: component_name.clone(), component: component_name.clone(),
...@@ -237,12 +232,7 @@ impl EndpointConfigBuilder { ...@@ -237,12 +232,7 @@ impl EndpointConfigBuilder {
let discovery = endpoint.drt().discovery(); let discovery = endpoint.drt().discovery();
// Build transport for discovery service based on request plane mode // Build transport for discovery service based on request plane mode
let transport = build_transport_type( let transport = build_transport_type(request_plane_mode, &endpoint_name, &subject);
request_plane_mode,
&endpoint_name,
&subject,
TransportContext::Discovery,
);
let discovery_spec = crate::discovery::DiscoverySpec::Endpoint { let discovery_spec = crate::discovery::DiscoverySpec::Endpoint {
namespace: namespace_name.clone(), namespace: namespace_name.clone(),
...@@ -270,31 +260,21 @@ impl EndpointConfigBuilder { ...@@ -270,31 +260,21 @@ impl EndpointConfigBuilder {
} }
} }
/// Context for building transport type - determines port and formatting differences /// Build transport type based on request plane mode
enum TransportContext {
/// For health check targets
HealthCheck,
/// For discovery service registration
Discovery,
}
/// Build transport type based on request plane mode and context
/// ///
/// This unified function handles both health check and discovery transport building, /// This function handles both health check and discovery transport building.
/// with context-specific differences: /// All transport modes use consistent addressing:
/// - HTTP: Both use the same port (default 8888, configurable via DYN_HTTP_RPC_PORT) /// - HTTP: Uses full URL path including endpoint name (e.g., http://host:port/v1/rpc/endpoint_name)
/// - TCP: Health check omits endpoint suffix, discovery includes it for routing /// - TCP: Includes endpoint name for routing (e.g., host:port/endpoint_name)
/// - NATS: Identical for both contexts /// - NATS: Uses subject-based addressing (unique per endpoint)
fn build_transport_type( fn build_transport_type(
mode: RequestPlaneMode, mode: RequestPlaneMode,
endpoint_name: &str, endpoint_name: &str,
subject: &str, subject: &str,
context: TransportContext,
) -> TransportType { ) -> TransportType {
match mode { match mode {
RequestPlaneMode::Http => { RequestPlaneMode::Http => {
let http_host = crate::utils::get_http_rpc_host_from_env(); let http_host = crate::utils::get_http_rpc_host_from_env();
// Both health check and discovery use the same port (8888) where the HTTP server binds
let http_port = std::env::var("DYN_HTTP_RPC_PORT") let http_port = std::env::var("DYN_HTTP_RPC_PORT")
.ok() .ok()
.and_then(|p| p.parse::<u16>().ok()) .and_then(|p| p.parse::<u16>().ok())
...@@ -316,16 +296,9 @@ fn build_transport_type( ...@@ -316,16 +296,9 @@ fn build_transport_type(
.and_then(|p| p.parse::<u16>().ok()) .and_then(|p| p.parse::<u16>().ok())
.unwrap_or(9999); .unwrap_or(9999);
let tcp_endpoint = match context { // Include endpoint name for proper TCP routing
TransportContext::HealthCheck => { // TCP client parses this format and adds x-endpoint-path header for server-side routing
// Health check uses simple host:port format let tcp_endpoint = format!("{}:{}/{}", tcp_host, tcp_port, endpoint_name);
format!("{}:{}", tcp_host, tcp_port)
}
TransportContext::Discovery => {
// Discovery includes endpoint name for routing
format!("{}:{}/{}", tcp_host, tcp_port, endpoint_name)
}
};
TransportType::Tcp(tcp_endpoint) TransportType::Tcp(tcp_endpoint)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment