fix: reject bucketed configs in cluster constructor
This commit is contained in:
@@ -37,7 +37,10 @@ pub struct Cluster {
|
||||
|
||||
impl Cluster {
|
||||
pub fn new(config: &Config, model: &ModelConfig) -> Self {
|
||||
let total_instances = config.cluster.total_instances();
|
||||
let total_instances = config
|
||||
.cluster
|
||||
.require_legacy_single_pool("Cluster::new")
|
||||
.unwrap_or_else(|err| panic!("{err}"));
|
||||
let mut instances = Vec::with_capacity(total_instances as usize);
|
||||
for id in 0..total_instances {
|
||||
instances.push(Instance::new(
|
||||
@@ -185,8 +188,8 @@ impl Cluster {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::config::{
|
||||
CalibrationConfig, ClusterConfig, Config, HardwareConfig, MetaStoreConfig, ModelConfig,
|
||||
RouterConfig, RouterMode, SimConfig,
|
||||
BucketConfig, CalibrationConfig, ClusterConfig, Config, HardwareConfig, MetaStoreConfig,
|
||||
ModelConfig, RouterConfig, RouterMode, SimConfig,
|
||||
};
|
||||
use crate::trace::RequestRecord;
|
||||
|
||||
@@ -285,4 +288,29 @@ mod tests {
|
||||
|
||||
assert!(stats.ready_at > pure_pcie);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cluster_new_rejects_bucketed_configs() {
|
||||
let mut cfg = test_config(RouterMode::EstimatedTtft);
|
||||
cfg.cluster.num_instances = None;
|
||||
cfg.cluster.buckets = vec![BucketConfig {
|
||||
name: "short".into(),
|
||||
input_length_min: 0,
|
||||
input_length_max: 64,
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user