[router] Worker Management Workflow Engine (#11868)

This commit is contained in:
Simo Lin
2025-10-20 17:00:22 -07:00
committed by GitHub
parent 0917c5da8c
commit ddcba74b4d
21 changed files with 2937 additions and 171 deletions

View File

@@ -18,7 +18,11 @@ use rustls;
use tokio::{task, time};
use tracing::{debug, error, info, warn};
use crate::{core::WorkerManager, protocols::worker_spec::WorkerConfigRequest, server::AppContext};
use crate::{
core::{Job, WorkerManager},
protocols::worker_spec::WorkerConfigRequest,
server::AppContext,
};
#[derive(Debug, Clone)]
pub struct ServiceDiscoveryConfig {
@@ -157,6 +161,7 @@ impl PodInfo {
}
pub fn worker_url(&self, port: u16) -> String {
// Default to http:// prefix; workflow will detect actual protocol (HTTP vs gRPC)
format!("http://{}:{}", self.ip, port)
}
}
@@ -382,10 +387,18 @@ async fn handle_pod_event(
tool_parser: None,
chat_template: None,
api_key: None,
health_check_timeout_secs: app_context.router_config.health_check.timeout_secs,
health_check_interval_secs: app_context
.router_config
.health_check
.check_interval_secs,
health_success_threshold: app_context.router_config.health_check.success_threshold,
health_failure_threshold: app_context.router_config.health_check.failure_threshold,
max_connection_attempts: app_context.router_config.health_check.success_threshold
* 20,
dp_aware: false,
};
// Submit job for async worker addition
use crate::core::Job;
let job = Job::AddWorker {
config: Box::new(config.clone()),
};
@@ -568,6 +581,7 @@ mod tests {
configured_reasoning_parser: None,
configured_tool_parser: None,
worker_job_queue: Arc::new(std::sync::OnceLock::new()),
workflow_engine: Arc::new(std::sync::OnceLock::new()),
})
}
@@ -815,19 +829,6 @@ mod tests {
assert!(!not_running_pod.is_healthy());
}
#[test]
fn test_pod_info_worker_url() {
let pod_info = PodInfo {
name: "p1".into(),
ip: "1.2.3.4".into(),
status: "Running".into(),
is_ready: true,
pod_type: None,
bootstrap_port: None,
};
assert_eq!(pod_info.worker_url(8080), "http://1.2.3.4:8080");
}
#[test]
fn test_pod_info_equality_with_pod_type() {
let pod1 = PodInfo {