Simplify PodListProcessor interface
This commit is contained in:
parent
014eff3ec8
commit
d9891ae3ad
|
|
@ -42,9 +42,7 @@ func NewFilterOutSchedulablePodListProcessor() pods.PodListProcessor {
|
|||
// Process filters out pods which are schedulable from list of unschedulable pods.
|
||||
func (filterOutSchedulablePodListProcessor) Process(
|
||||
context *context.AutoscalingContext,
|
||||
unschedulablePods []*apiv1.Pod, allScheduledPods []*apiv1.Pod,
|
||||
allNodes []*apiv1.Node, readyNodes []*apiv1.Node,
|
||||
upcomingNodes []*apiv1.Node) ([]*apiv1.Pod, []*apiv1.Pod, error) {
|
||||
unschedulablePods []*apiv1.Pod) ([]*apiv1.Pod, error) {
|
||||
// We need to check whether pods marked as unschedulable are actually unschedulable.
|
||||
// It's likely we added a new node and the scheduler just haven't managed to put the
|
||||
// pod on in yet. In this situation we don't want to trigger another scale-up.
|
||||
|
|
@ -69,7 +67,7 @@ func (filterOutSchedulablePodListProcessor) Process(
|
|||
context.PredicateChecker, context.ExpendablePodsPriorityCutoff)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
metrics.UpdateDurationFromStart(metrics.FilterOutSchedulable, filterOutSchedulableStart)
|
||||
|
|
@ -80,7 +78,7 @@ func (filterOutSchedulablePodListProcessor) Process(
|
|||
} else {
|
||||
klog.V(4).Info("No schedulable pods")
|
||||
}
|
||||
return unschedulablePodsToHelp, allScheduledPods, nil
|
||||
return unschedulablePodsToHelp, nil
|
||||
}
|
||||
|
||||
func (filterOutSchedulablePodListProcessor) CleanUp() {
|
||||
|
|
|
|||
|
|
@ -380,9 +380,7 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError
|
|||
}
|
||||
}
|
||||
|
||||
unschedulablePodsToHelp, scheduledPods, _ := a.processors.PodListProcessor.Process(
|
||||
a.AutoscalingContext, unschedulablePods, scheduledPods, allNodes, readyNodes,
|
||||
upcomingNodes)
|
||||
unschedulablePodsToHelp, _ := a.processors.PodListProcessor.Process(a.AutoscalingContext, unschedulablePods)
|
||||
|
||||
// finally, filter out pods that are too "young" to safely be considered for a scale-up (delay is configurable)
|
||||
unschedulablePodsToHelp = a.filterOutYoungPods(unschedulablePodsToHelp, currentTime)
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@ import (
|
|||
"k8s.io/autoscaler/cluster-autoscaler/context"
|
||||
)
|
||||
|
||||
// PodListProcessor processes lists of unschedulable and scheduled pods before scaling of the cluster.
|
||||
// PodListProcessor processes lists of unschedulable pods.
|
||||
type PodListProcessor interface {
|
||||
Process(context *context.AutoscalingContext,
|
||||
unschedulablePods []*apiv1.Pod, allScheduledPods []*apiv1.Pod,
|
||||
allNodes []*apiv1.Node, readyNodes []*apiv1.Node,
|
||||
upcomingNodes []*apiv1.Node) ([]*apiv1.Pod, []*apiv1.Pod, error)
|
||||
Process(
|
||||
context *context.AutoscalingContext,
|
||||
unschedulablePods []*apiv1.Pod) ([]*apiv1.Pod, error)
|
||||
CleanUp()
|
||||
}
|
||||
|
||||
|
|
@ -40,11 +39,10 @@ func NewDefaultPodListProcessor() PodListProcessor {
|
|||
}
|
||||
|
||||
// Process processes lists of unschedulable and scheduled pods before scaling of the cluster.
|
||||
func (p *NoOpPodListProcessor) Process(context *context.AutoscalingContext,
|
||||
unschedulablePods []*apiv1.Pod, allScheduledPods []*apiv1.Pod,
|
||||
allNodes []*apiv1.Node, readyNodes []*apiv1.Node,
|
||||
upcomingNodes []*apiv1.Node) ([]*apiv1.Pod, []*apiv1.Pod, error) {
|
||||
return unschedulablePods, allScheduledPods, nil
|
||||
func (p *NoOpPodListProcessor) Process(
|
||||
context *context.AutoscalingContext,
|
||||
unschedulablePods []*apiv1.Pod) ([]*apiv1.Pod, error) {
|
||||
return unschedulablePods, nil
|
||||
}
|
||||
|
||||
// CleanUp cleans up the processor's internal structures.
|
||||
|
|
|
|||
|
|
@ -25,21 +25,14 @@ import (
|
|||
. "k8s.io/autoscaler/cluster-autoscaler/utils/test"
|
||||
)
|
||||
|
||||
func TestPodListProcessor(t *testing.T) {
|
||||
func TestDefaultUnschedulablePodListProcessor(t *testing.T) {
|
||||
context := &context.AutoscalingContext{}
|
||||
p1 := BuildTestPod("p1", 40, 0)
|
||||
p2 := BuildTestPod("p2", 400, 0)
|
||||
n1 := BuildTestNode("n1", 100, 1000)
|
||||
n2 := BuildTestNode("n1", 100, 1000)
|
||||
unschedulablePods := []*apiv1.Pod{p1}
|
||||
allScheduledPods := []*apiv1.Pod{p2}
|
||||
allNodes := []*apiv1.Node{n1, n2}
|
||||
readyNodes := []*apiv1.Node{n1, n2}
|
||||
podListProcessor := NewDefaultPodListProcessor()
|
||||
gotUnschedulablePods, gotAllScheduled, err := podListProcessor.Process(context, unschedulablePods, allScheduledPods, allNodes, readyNodes, []*apiv1.Node{})
|
||||
if len(gotUnschedulablePods) != 1 || len(gotAllScheduled) != 1 || err != nil {
|
||||
t.Errorf("Error podListProcessor.Process() = %v, %v, %v want %v, %v, nil ",
|
||||
gotUnschedulablePods, gotAllScheduled, err, unschedulablePods, allScheduledPods)
|
||||
gotUnschedulablePods, err := podListProcessor.Process(context, unschedulablePods)
|
||||
if len(gotUnschedulablePods) != 1 || err != nil {
|
||||
t.Errorf("Error podListProcessor.Process() = %v,%v want %v, nil ",
|
||||
gotUnschedulablePods, err, unschedulablePods)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue