wait for failed jobs

Signed-off-by: aCLr <a.ch.clr@gmail.com>
pull/9437/head
aCLr 5 years ago
parent a9c581584f
commit d0cf331423

@ -190,9 +190,9 @@ func (w *waiter) isPodReady(pod *corev1.Pod) bool {
} }
func (w *waiter) jobReady(job *batchv1.Job) bool { func (w *waiter) jobReady(job *batchv1.Job) bool {
if job.Status.Failed >= *job.Spec.BackoffLimit { if job.Status.Failed > *job.Spec.BackoffLimit {
w.log("Job is failed: %s/%s", job.GetNamespace(), job.GetName()) w.log("Job is failed: %s/%s", job.GetNamespace(), job.GetName())
return false return true
} }
if job.Status.Succeeded < *job.Spec.Completions { if job.Status.Succeeded < *job.Spec.Completions {
w.log("Job is not completed: %s/%s", job.GetNamespace(), job.GetName()) w.log("Job is not completed: %s/%s", job.GetNamespace(), job.GetName())

@ -266,6 +266,16 @@ func Test_waiter_jobReady(t *testing.T) {
args: args{job: newJob("foo", 1, 1, 0, 1)}, args: args{job: newJob("foo", 1, 1, 0, 1)},
want: false, want: false,
}, },
{
name: "job is completed with backoffLimit=0",
args: args{job: newJob("foo", 0, 1, 1, 0)},
want: true,
},
{
name: "job is failed and it is ok",
args: args{job: newJob("foo", 0, 1, 0, 1)},
want: true,
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

Loading…
Cancel
Save