Skip to content

Commit 16e6edd

Browse files
committed
fix: synch implementation of IsJobFinished with API docs
1 parent 3cec571 commit 16e6edd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/kube/jobs/jobs.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
corev1 "k8s.io/api/core/v1"
66
)
77

8-
// IsJobSucceeded returns true if the job completed and did not fail
8+
// IsJobSucceeded returns true if the job completed
99
func IsJobSucceeded(job *batchv1.Job) bool {
1010
for _, con := range job.Status.Conditions {
1111
if con.Type == batchv1.JobComplete && con.Status == corev1.ConditionTrue {
@@ -15,10 +15,13 @@ func IsJobSucceeded(job *batchv1.Job) bool {
1515
return false
1616
}
1717

18-
// IsJobFinished returns true if the job has completed
18+
// IsJobFinished returns true if the job has finished, i.e. is completed, failed or suspended
19+
// Technically a suspended job can be resumed, but the logic in jx assume this doesn't happen
20+
// Reference: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#jobstatus-v1-batch
1921
func IsJobFinished(job *batchv1.Job) bool {
2022
for _, con := range job.Status.Conditions {
21-
if con.Status == corev1.ConditionTrue {
23+
if (con.Type == batchv1.JobComplete || con.Type == batchv1.JobFailed || con.Type == batchv1.JobSuspended) &&
24+
con.Status == corev1.ConditionTrue {
2225
return true
2326
}
2427
}

0 commit comments

Comments
 (0)