Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add new status conditions for k8s v1.31 #403

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions pkg/jobs/runnable_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ func (r *runnableJob) Run(ctx context.Context) error {
if r.job.UID != newJob.UID {
return
}
if len(newJob.Status.Conditions) == 0 {
return
}
switch condition := newJob.Status.Conditions[0]; condition.Type {
case batchv1.JobComplete:
complete <- nil
case batchv1.JobFailed:
complete <- fmt.Errorf("job failed: %s: %s", condition.Reason, condition.Message)
for _, condition := range newJob.Status.Conditions {
switch condition.Type {
case batchv1.JobComplete, batchv1.JobSuccessCriteriaMet:
complete <- nil
return
case batchv1.JobFailed:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also check the JobFailureTarget condition?
From the doc:

You can use the FailureTarget or the SuccessCriteriaMet condition to evaluate whether the Job has failed or succeeded without having to wait for the controller to add a terminal condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! I thought about it, but decided to wait for JobFailed. that means all pods are terminated.
to avoid an error aquasecurity/trivy#5639

wdyt?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

complete <- fmt.Errorf("job failed: %s: %s", condition.Reason, condition.Message)
return
}
}
},
})
Expand Down
Loading