Skip to content

Commit bfca950

Browse files
authored
Added indexed option for k8s jobs (#597)
* Added indexed option for k8s jobs * Use completions instead of indexed * I'm bad at go * Remove k8s completions option: use Indexed if parallelism > 1, else NonIndexed
1 parent 3b32117 commit bfca950

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

task/k8s/resources/resource_job.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ func (j *Job) Create(ctx context.Context) error {
119119
jobCompletions := int32(j.Attributes.Task.Parallelism)
120120
jobParallelism := int32(j.Attributes.Task.Parallelism)
121121

122+
var jobCompletionMode kubernetes_batch.CompletionMode
123+
if jobParallelism > 1 {
124+
jobCompletionMode = kubernetes_batch.IndexedCompletion
125+
} else {
126+
jobCompletionMode = kubernetes_batch.NonIndexedCompletion
127+
}
128+
122129
jobActiveDeadlineSeconds := int64(j.Attributes.Task.Environment.Timeout / time.Second)
123130

124131
jobEnvironment := []kubernetes_core.EnvVar{}
@@ -204,6 +211,7 @@ func (j *Job) Create(ctx context.Context) error {
204211
BackoffLimit: &jobBackoffLimit,
205212
Completions: &jobCompletions,
206213
Parallelism: &jobParallelism,
214+
CompletionMode: &jobCompletionMode,
207215
// We don't want jobs to delete themselves upon completion, because
208216
// that would also mean losing logs before users check them.
209217
// TTLSecondsAfterFinished: &jobTTLSecondsAfterFinished,

0 commit comments

Comments
 (0)