@@ -20,7 +20,7 @@ import (
20
20
"fmt"
21
21
22
22
apiv1 "k8s.io/api/core/v1"
23
- "k8s.io/autoscaler/cluster-autoscaler/context"
23
+ ca_context "k8s.io/autoscaler/cluster-autoscaler/context"
24
24
core_utils "k8s.io/autoscaler/cluster-autoscaler/core/utils"
25
25
caerrors "k8s.io/autoscaler/cluster-autoscaler/utils/errors"
26
26
"k8s.io/klog/v2"
@@ -35,15 +35,15 @@ func NewFilterOutExpendablePodListProcessor() *filterOutExpendable {
35
35
}
36
36
37
37
// Process filters out pods which are expendable and adds pods which is waiting for lower priority pods preemption to the cluster snapshot
38
- func (p * filterOutExpendable ) Process (context * context .AutoscalingContext , pods []* apiv1.Pod ) ([]* apiv1.Pod , error ) {
39
- nodes , err := context .AllNodeLister ().List ()
38
+ func (p * filterOutExpendable ) Process (autoscalingContext * ca_context .AutoscalingContext , pods []* apiv1.Pod ) ([]* apiv1.Pod , error ) {
39
+ nodes , err := autoscalingContext .AllNodeLister ().List ()
40
40
if err != nil {
41
41
return nil , fmt .Errorf ("Failed to list all nodes while filtering expendable pods: %v" , err )
42
42
}
43
- expendablePodsPriorityCutoff := context .AutoscalingOptions .ExpendablePodsPriorityCutoff
43
+ expendablePodsPriorityCutoff := autoscalingContext .AutoscalingOptions .ExpendablePodsPriorityCutoff
44
44
45
45
unschedulablePods , waitingForLowerPriorityPreemption := core_utils .FilterOutExpendableAndSplit (pods , nodes , expendablePodsPriorityCutoff )
46
- if err = p .addPreemptingPodsToSnapshot (waitingForLowerPriorityPreemption , context ); err != nil {
46
+ if err = p .addPreemptingPodsToSnapshot (waitingForLowerPriorityPreemption , autoscalingContext ); err != nil {
47
47
klog .Warningf ("Failed to add preempting pods to snapshot: %v" , err )
48
48
return nil , err
49
49
}
@@ -54,10 +54,10 @@ func (p *filterOutExpendable) Process(context *context.AutoscalingContext, pods
54
54
// addPreemptingPodsToSnapshot modifies the snapshot simulating scheduling of pods waiting for preemption.
55
55
// this is not strictly correct as we are not simulating preemption itself but it matches
56
56
// CA logic from before migration to scheduler framework. So let's keep it for now
57
- func (p * filterOutExpendable ) addPreemptingPodsToSnapshot (pods []* apiv1.Pod , ctx * context .AutoscalingContext ) error {
57
+ func (p * filterOutExpendable ) addPreemptingPodsToSnapshot (pods []* apiv1.Pod , autoscalingContext * ca_context .AutoscalingContext ) error {
58
58
for _ , p := range pods {
59
59
// TODO(DRA): Figure out if/how to use the predicate-checking SchedulePod() here instead - otherwise this doesn't work with DRA pods.
60
- if err := ctx .ClusterSnapshot .ForceAddPod (p , p .Status .NominatedNodeName ); err != nil {
60
+ if err := autoscalingContext .ClusterSnapshot .ForceAddPod (p , p .Status .NominatedNodeName ); err != nil {
61
61
klog .Errorf ("Failed to update snapshot with pod %s/%s waiting for preemption: %v" , p .Namespace , p .Name , err )
62
62
return caerrors .ToAutoscalerError (caerrors .InternalError , err )
63
63
}
0 commit comments