@@ -146,15 +146,12 @@ where
146146 }
147147
148148 // Evaluate scaling decision with GPU-aware idle node matching
149- let decision = self . evaluate_scaling (
150- & policy. spec ,
151- & metrics_snapshot,
152- current_nodes,
153- & status,
154- & pending_gpu_pods,
155- & node_pools,
156- & gpu_nodes,
157- ) ;
149+ let ctx = ScalingContext {
150+ pending_pods : & pending_gpu_pods,
151+ node_pools : & node_pools,
152+ k8s_nodes : & gpu_nodes,
153+ } ;
154+ let decision = self . evaluate_scaling ( & policy. spec , & metrics_snapshot, current_nodes, & ctx) ;
158155
159156 match decision {
160157 ScalingDecision :: ScaleUp ( count) => {
@@ -717,18 +714,18 @@ where
717714 spec : & ScalingPolicySpec ,
718715 metrics : & MetricsSnapshot ,
719716 current_nodes : u32 ,
720- _status : & ScalingPolicyStatus ,
721- pending_pods : & [ Pod ] ,
722- node_pools : & [ NodePool ] ,
723- k8s_nodes : & [ k8s_openapi:: api:: core:: v1:: Node ] ,
717+ ctx : & ScalingContext < ' _ > ,
724718 ) -> ScalingDecision {
725719 // Check scale up: pending GPU pods exceed threshold
726720 if metrics. pending_gpu_pods >= spec. scale_up . pending_pod_threshold {
727721 // GPU-aware idle check: only skip scale-up if idle nodes can actually serve
728722 // the pending pods based on GPU model, count, and memory requirements.
729723 // Also checks that nodes are schedulable (no disk pressure, etc.)
730- let serviceable_count =
731- Self :: count_serviceable_pending_pods ( pending_pods, node_pools, k8s_nodes) ;
724+ let serviceable_count = Self :: count_serviceable_pending_pods (
725+ ctx. pending_pods ,
726+ ctx. node_pools ,
727+ ctx. k8s_nodes ,
728+ ) ;
732729
733730 if serviceable_count >= metrics. pending_gpu_pods && metrics. idle_nodes > 0 {
734731 debug ! (
@@ -1714,6 +1711,14 @@ enum ScalingDecision {
17141711 NoAction ,
17151712}
17161713
1714+ /// Context for scaling evaluation containing node and pod information.
1715+ /// Groups related parameters to reduce function argument count.
1716+ struct ScalingContext < ' a > {
1717+ pending_pods : & ' a [ Pod ] ,
1718+ node_pools : & ' a [ NodePool ] ,
1719+ k8s_nodes : & ' a [ k8s_openapi:: api:: core:: v1:: Node ] ,
1720+ }
1721+
17171722/// Result of offering lookup with fallback handling
17181723enum OfferingResult {
17191724 Found ( crate :: api:: GpuOffering ) ,
0 commit comments