Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cluster-autoscaler/core/static_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,10 @@ func (a *StaticAutoscaler) filterOutYoungPods(allUnschedulablePods []*apiv1.Pod,
}
}

if podAge > podScaleUpDelay {
// newPodScaleUpDelay <= 0 means that young pod filtering out is disabled.
// As pod age is calculated from CA loop start time, it is technically possible that some pods will have negative
// age and would be unnecesarily skipped by the current loop.
if podScaleUpDelay <= 0 || podAge > podScaleUpDelay {
oldUnschedulablePods = append(oldUnschedulablePods, pod)
} else {
klog.V(3).Infof("Pod %s is %.3f seconds old, too new to consider unschedulable", pod.Name, podAge.Seconds())
Expand Down
16 changes: 16 additions & 0 deletions cluster-autoscaler/core/static_autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2836,6 +2836,8 @@ func TestFilterOutYoungPods(t *testing.T) {
p4.Annotations = map[string]string{
annotations.PodScaleUpDelayAnnotationKey: "error",
}
p5 := BuildTestPod("p5", 500, 1000)
p5.CreationTimestamp = metav1.NewTime(now)

tests := []struct {
name string
Expand Down Expand Up @@ -2882,6 +2884,20 @@ func TestFilterOutYoungPods(t *testing.T) {
expectedPods: []*apiv1.Pod{p1, p4},
expectedError: "Failed to parse pod",
},
{
name: "future pods included when podScaleUpDelay is 0",
newPodScaleUpDelay: 0,
runTime: now,
pods: []*apiv1.Pod{p1, p5},
expectedPods: []*apiv1.Pod{p1, p5},
},
{
name: "future pods excluded when podScaleUpDelay is above 0",
newPodScaleUpDelay: 1 * time.Second,
runTime: now,
pods: []*apiv1.Pod{p1, p5},
expectedPods: []*apiv1.Pod{p1},
},
}

for _, tt := range tests {
Expand Down
Loading