fix: complete global router config and recoverable cluster init
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
//! Cluster: routes arrivals, performs the L0 / L1 / remote-RDMA fetch chain
|
||||
//! described in the design diagram, and bookkeeps the global meta store.
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::cluster::meta_store::MetaStore;
|
||||
use crate::config::{Config, ModelConfig};
|
||||
use crate::instance::instance::AdmittedRequest;
|
||||
@@ -36,11 +38,8 @@ pub struct Cluster {
|
||||
}
|
||||
|
||||
impl Cluster {
|
||||
pub fn new(config: &Config, model: &ModelConfig) -> Self {
|
||||
let total_instances = config
|
||||
.cluster
|
||||
.require_legacy_single_pool("Cluster::new")
|
||||
.unwrap_or_else(|err| panic!("{err}"));
|
||||
pub fn new(config: &Config, model: &ModelConfig) -> Result<Self> {
|
||||
let total_instances = config.cluster.require_legacy_single_pool("Cluster::new")?;
|
||||
let mut instances = Vec::with_capacity(total_instances as usize);
|
||||
for id in 0..total_instances {
|
||||
instances.push(Instance::new(
|
||||
@@ -52,7 +51,7 @@ impl Cluster {
|
||||
}
|
||||
let meta_store = MetaStore::new(config.cluster.meta_store.ttl_seconds);
|
||||
let router = router::build(config, config.sim.seed);
|
||||
Self {
|
||||
Ok(Self {
|
||||
instances,
|
||||
meta_store,
|
||||
router,
|
||||
@@ -63,7 +62,7 @@ impl Cluster {
|
||||
&config.calibration,
|
||||
model.kv_block_bytes(),
|
||||
),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Route + admit a request. Returns the chosen instance plus rich
|
||||
@@ -262,7 +261,7 @@ mod tests {
|
||||
#[test]
|
||||
fn l1_ready_at_includes_dram_and_transform_overhead() {
|
||||
let cfg = test_config(RouterMode::EstimatedTtft);
|
||||
let mut cluster = Cluster::new(&cfg, &cfg.model);
|
||||
let mut cluster = Cluster::new(&cfg, &cfg.model).unwrap();
|
||||
let req = RequestRecord {
|
||||
req_id: 1,
|
||||
chat_id: 0,
|
||||
@@ -300,17 +299,10 @@ mod tests {
|
||||
num_instances: 2,
|
||||
}];
|
||||
|
||||
let panic = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
Cluster::new(&cfg, &cfg.model);
|
||||
}))
|
||||
.expect_err("bucketed Cluster::new should panic");
|
||||
|
||||
let msg = panic
|
||||
.downcast_ref::<String>()
|
||||
.cloned()
|
||||
.or_else(|| panic.downcast_ref::<&str>().map(|s| (*s).to_string()))
|
||||
.expect("panic payload should be a string");
|
||||
assert!(msg.contains("Cluster::new"));
|
||||
assert!(msg.contains("cluster.buckets"));
|
||||
let result = Cluster::new(&cfg, &cfg.model);
|
||||
assert!(result.is_err(), "bucketed Cluster::new should fail");
|
||||
let err = result.err().unwrap();
|
||||
assert!(err.to_string().contains("Cluster::new"));
|
||||
assert!(err.to_string().contains("cluster.buckets"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user