-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* better handling * better handling * cleanup * simpler solution
- Loading branch information
1 parent
f0b00a9
commit cdda9d5
Showing
4 changed files
with
100 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package controller | ||
|
||
import ( | ||
batchv1 "k8s.io/api/batch/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
eq "k8s.io/apimachinery/pkg/api/equality" | ||
) | ||
|
||
func jobsAreEqual(first *batchv1.Job, second *batchv1.Job) bool { | ||
return first != nil && second != nil && eq.Semantic.DeepEqual(first, second) | ||
} | ||
|
||
// from https://github.com/kubernetes/kubernetes/blob/v1.28.1/pkg/controller/job/utils.go | ||
// IsJobFinished checks whether the given Job has finished execution. | ||
// It does not discriminate between successful and failed terminations. | ||
func isJobFinished(j *batchv1.Job) bool { | ||
for _, c := range j.Status.Conditions { | ||
if (c.Type == batchv1.JobComplete || c.Type == batchv1.JobFailed) && c.Status == corev1.ConditionTrue { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func hasFailed(job *batchv1.Job) bool { | ||
return job.Status.Failed > 0 | ||
} | ||
|
||
func hasSucceeded(job *batchv1.Job) bool { | ||
return job.Status.Succeeded > 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters