Skip to content

Commit 3e1a4e2

Browse files
committed
new-pod-scale-up-delay=0 should effectively disable filtering out young pods
1 parent 934a600 commit 3e1a4e2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

cluster-autoscaler/core/static_autoscaler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,10 @@ func (a *StaticAutoscaler) filterOutYoungPods(allUnschedulablePods []*apiv1.Pod,
984984
}
985985
}
986986

987-
if podAge > podScaleUpDelay {
987+
// newPodScaleUpDelay <= 0 means that young pod filtering out is disabled.
988+
// As pod age is calculated from CA loop start time, it is technically possible that some pods will have negative
989+
// age and would be unnecesarily skipped by the current loop.
990+
if podScaleUpDelay <= 0 || podAge > podScaleUpDelay {
988991
oldUnschedulablePods = append(oldUnschedulablePods, pod)
989992
} else {
990993
klog.V(3).Infof("Pod %s is %.3f seconds old, too new to consider unschedulable", pod.Name, podAge.Seconds())

cluster-autoscaler/core/static_autoscaler_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,6 +2836,8 @@ func TestFilterOutYoungPods(t *testing.T) {
28362836
p4.Annotations = map[string]string{
28372837
annotations.PodScaleUpDelayAnnotationKey: "error",
28382838
}
2839+
p5 := BuildTestPod("p5", 500, 1000)
2840+
p5.CreationTimestamp = metav1.NewTime(now)
28392841

28402842
tests := []struct {
28412843
name string
@@ -2882,6 +2884,20 @@ func TestFilterOutYoungPods(t *testing.T) {
28822884
expectedPods: []*apiv1.Pod{p1, p4},
28832885
expectedError: "Failed to parse pod",
28842886
},
2887+
{
2888+
name: "future pods included when podScaleUpDelay is 0",
2889+
newPodScaleUpDelay: 0,
2890+
runTime: now,
2891+
pods: []*apiv1.Pod{p1, p5},
2892+
expectedPods: []*apiv1.Pod{p1, p5},
2893+
},
2894+
{
2895+
name: "future pods excluded when podScaleUpDelay is above 0",
2896+
newPodScaleUpDelay: 1 * time.Second,
2897+
runTime: now,
2898+
pods: []*apiv1.Pod{p1, p5},
2899+
expectedPods: []*apiv1.Pod{p1},
2900+
},
28852901
}
28862902

28872903
for _, tt := range tests {

0 commit comments

Comments
 (0)