Merge pull request #104799 from RyanAoh/cronjob_dev

fix the error when cleaning up finished jobs for cronjob
This commit is contained in:
Kubernetes Prow Robot
2021-12-17 13:23:53 -08:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -613,13 +613,14 @@ func (jm *ControllerV2) syncCronJob(
}
cj.Status.Active = append(cj.Status.Active, *jobRef)
cj.Status.LastScheduleTime = &metav1.Time{Time: *scheduledTime}
if _, err := jm.cronJobControl.UpdateStatus(ctx, cj); err != nil {
updatedCJ, err = jm.cronJobControl.UpdateStatus(ctx, cj)
if err != nil {
klog.InfoS("Unable to update status", "cronjob", klog.KRef(cj.GetNamespace(), cj.GetName()), "resourceVersion", cj.ResourceVersion, "err", err)
return cj, nil, fmt.Errorf("unable to update status for %s (rv = %s): %v", klog.KRef(cj.GetNamespace(), cj.GetName()), cj.ResourceVersion, err)
}
t := nextScheduledTimeDuration(sched, now)
return cj, t, nil
return updatedCJ, t, nil
}
func getJobName(cj *batchv1.CronJob, scheduledTime time.Time) string {