Skip to content

Commit

Permalink
Use slice for errors
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed May 8, 2023
1 parent 72224b0 commit 72ba788
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/controllers/jobset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (r *JobSetReconciler) restartPolicyRecreateAll(ctx context.Context, js *job
func (r *JobSetReconciler) deleteJobs(ctx context.Context, jobsForDeletion []*batchv1.Job) error {
log := ctrl.LoggerFrom(ctx)
lock := &sync.Mutex{}
var finalErr error
var finalErrs []error
workqueue.ParallelizeUntil(ctx, parallelDeletions, len(jobsForDeletion), func(i int) {
targetJob := jobsForDeletion[i]
// Delete job. This deletion event will trigger another reconciliation,
Expand All @@ -381,12 +381,12 @@ func (r *JobSetReconciler) deleteJobs(ctx context.Context, jobsForDeletion []*ba
if err := r.Delete(ctx, targetJob, &client.DeleteOptions{PropagationPolicy: &backgroundPolicy}); client.IgnoreNotFound(err) != nil {
lock.Lock()
defer lock.Unlock()
finalErr = errors.Join(finalErr, err)
finalErrs = append(finalErrs, err)
return
}
log.V(2).Info("successfully deleted job", "job", klog.KObj(targetJob), "restart attempt", targetJob.Labels[targetJob.Labels[RestartsKey]])
})
return finalErr
return errors.Join(finalErrs...)
}

// updateStatus updates the status of a JobSet.
Expand Down

0 comments on commit 72ba788

Please sign in to comment.