Skip to content

Commit

Permalink
Merge pull request #448 from danielvegamyhre/event
Browse files Browse the repository at this point in the history
Emit Job creation failed event
  • Loading branch information
k8s-ci-robot authored Mar 14, 2024
2 parents 8eaf78b + 54f3809 commit e17f679
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/controllers/jobset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (r *JobSetReconciler) createJobs(ctx context.Context, js *jobset.JobSet, ow
if err := r.Create(ctx, job); err != nil {
lock.Lock()
defer lock.Unlock()
finalErrs = append(finalErrs, err)
finalErrs = append(finalErrs, fmt.Errorf("job %q creation failed with error: %v", job.Name, err))
return
}
log.V(2).Info("successfully created job", "job", klog.KObj(job))
Expand All @@ -475,6 +475,9 @@ func (r *JobSetReconciler) createJobs(ctx context.Context, js *jobset.JobSet, ow
}
allErrs := errors.Join(finalErrs...)
if allErrs != nil {
// Emit event to propagate the Job creation failures up to be more visible to the user.
// TODO(#422): Investigate ways to validate Job templates at JobSet validation time.
r.Record.Eventf(js, corev1.EventTypeWarning, "JobCreationFailed", allErrs.Error())
return allErrs
}
// Skip emitting a condition for StartupPolicy if JobSet is suspended
Expand Down

0 comments on commit e17f679

Please sign in to comment.