Skip to content

Commit 690914f

Browse files
authored
Merge pull request #8576 from walidghallab/fix-workqueue
Fix completions set to 1 being recognized as work queue.
2 parents f729346 + a8ed7c8 commit 690914f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cluster-autoscaler/processors/podinjection/job_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func desiredReplicasFromJob(job *batchv1.Job) int {
5656
return max(desiredReplicas, 0)
5757
}
5858

59-
// isWorkQueueJob returns true if the job is a work queue job (Completions is 1 or nil and Parallelism >=0)
59+
// isWorkQueueJob returns true if the job is a work queue job (Completions is nil and Parallelism >=0)
6060
// work queue jobs should have replicas equal to Parallelism regardless in case of no Succeeded
6161
func isWorkQueueJob(job *batchv1.Job) bool {
62-
return (job.Spec.Completions == nil || *(job.Spec.Completions) == 1) && job.Spec.Parallelism != nil && *(job.Spec.Parallelism) >= 0
62+
return job.Spec.Completions == nil && job.Spec.Parallelism != nil && *(job.Spec.Parallelism) >= 0
6363
}

cluster-autoscaler/processors/podinjection/job_controller_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ func TestDesiredReplicasFromJob(t *testing.T) {
7474
},
7575
wantReplicas: 5,
7676
},
77+
{
78+
name: "Parallelism is large while completion is 1",
79+
job: &batchv1.Job{
80+
Spec: batchv1.JobSpec{
81+
Completions: &one,
82+
Parallelism: &ten,
83+
},
84+
Status: batchv1.JobStatus{
85+
Succeeded: 0,
86+
},
87+
},
88+
wantReplicas: 1,
89+
},
7790
{
7891
name: "Work queue with succeeded pods",
7992
job: &batchv1.Job{

0 commit comments

Comments
 (0)