mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 08:27:46 +08:00
feat(routing): consolidate scheduling strategy configuration
This commit is contained in:
@@ -67,11 +67,14 @@ pub(crate) async fn build_admin_global_model_routing_payload(
|
||||
.push(key);
|
||||
}
|
||||
|
||||
// Effective default scheduling: system-default routing group first, then
|
||||
// legacy system-config keys.
|
||||
let ordering_config = crate::scheduler::config::read_scheduler_ordering_config(state.app())
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
// The admin view reports the system-default routing strategy.
|
||||
let ordering_config =
|
||||
match crate::scheduler::config::read_system_default_routing_ordering_config(state.app())
|
||||
.await
|
||||
{
|
||||
Ok(Some(config)) => config,
|
||||
Ok(None) | Err(_) => crate::scheduler::config::SchedulerOrderingConfig::default(),
|
||||
};
|
||||
let scheduling_mode = ordering_config.scheduling_mode_str().to_string();
|
||||
let priority_mode = ordering_config.priority_mode_str().to_string();
|
||||
let keep_priority_on_conversion = ordering_config.keep_priority_on_conversion;
|
||||
|
||||
@@ -265,7 +265,9 @@ pub(super) async fn build_admin_monitoring_cache_snapshot(
|
||||
state: &AdminAppState<'_>,
|
||||
) -> Result<AdminMonitoringCacheSnapshot, GatewayError> {
|
||||
let ordering_config =
|
||||
crate::scheduler::config::read_scheduler_ordering_config(state.app()).await?;
|
||||
crate::scheduler::config::read_system_default_routing_ordering_config(state.app())
|
||||
.await?
|
||||
.unwrap_or_default();
|
||||
let scheduling_mode = ordering_config.scheduling_mode_str().to_string();
|
||||
let provider_priority_mode = ordering_config.priority_mode_str().to_string();
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ struct AdminRoutingGroupCreateRequest {
|
||||
#[serde(default)]
|
||||
is_system_default: bool,
|
||||
#[serde(default)]
|
||||
sort_order: i64,
|
||||
#[serde(default)]
|
||||
config_json: Option<Value>,
|
||||
}
|
||||
|
||||
@@ -137,6 +139,7 @@ async fn maybe_build_routing_groups_response(
|
||||
description: payload.description,
|
||||
enabled: payload.enabled,
|
||||
is_system_default: payload.is_system_default,
|
||||
sort_order: payload.sort_order,
|
||||
config_json,
|
||||
version: 1,
|
||||
created_at: now,
|
||||
@@ -464,6 +467,9 @@ fn build_routing_group_update_patch(
|
||||
if let Some(value) = object.get("is_system_default") {
|
||||
patch.is_system_default = Some(required_bool(value, "is_system_default")?);
|
||||
}
|
||||
if let Some(value) = object.get("sort_order") {
|
||||
patch.sort_order = Some(required_i64(value, "sort_order")?.max(0));
|
||||
}
|
||||
if let Some(value) = object.get("config_json") {
|
||||
validate_config_json(value)?;
|
||||
patch.config_json = Some(value.clone());
|
||||
@@ -604,6 +610,7 @@ fn routing_group_payload(group: &StoredRoutingGroup) -> Value {
|
||||
"description": group.description,
|
||||
"enabled": group.enabled,
|
||||
"is_system_default": group.is_system_default,
|
||||
"sort_order": group.sort_order,
|
||||
"config_json": group.config_json,
|
||||
"version": group.version,
|
||||
"created_at": group.created_at,
|
||||
|
||||
@@ -68,7 +68,6 @@ use crate::scheduler::candidate::{
|
||||
is_auth_api_key_concurrency_limit_skip_reason, AUTH_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON,
|
||||
LEGACY_API_KEY_CONCURRENCY_LIMIT_SKIP_REASON,
|
||||
};
|
||||
use crate::scheduler::config::{read_scheduler_ordering_config, SchedulerSchedulingMode};
|
||||
use crate::stage_metrics::observe_gateway_stage_ms;
|
||||
use crate::{
|
||||
AppState, FrontdoorUserRpmOutcome, GatewayError, GatewayFallbackMetricKind,
|
||||
@@ -411,27 +410,7 @@ async fn maybe_forward_public_request_to_tunnel_owner(
|
||||
policy_context,
|
||||
)
|
||||
} else {
|
||||
let cache_affinity_enabled = match read_scheduler_ordering_config(state).await {
|
||||
Ok(config) => config.scheduling_mode == SchedulerSchedulingMode::CacheAffinity,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
trace_id = %request_context.trace_id,
|
||||
error = ?err,
|
||||
"gateway failed to load scheduler config while checking tunnel affinity forwarding mode"
|
||||
);
|
||||
SchedulerSchedulingMode::default() == SchedulerSchedulingMode::CacheAffinity
|
||||
}
|
||||
};
|
||||
if !cache_affinity_enabled {
|
||||
return Ok(None);
|
||||
}
|
||||
crate::scheduler::affinity::read_cached_scheduler_affinity_target(
|
||||
state,
|
||||
&auth_context.api_key_id,
|
||||
affinity_context.client_session_affinity.as_ref(),
|
||||
api_format,
|
||||
&affinity_context.requested_model,
|
||||
)
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(target) = target else {
|
||||
return Ok(None);
|
||||
|
||||
Reference in New Issue
Block a user