diff --git a/pkg/apis/batch/validation/validation.go b/pkg/apis/batch/validation/validation.go index 24d97a53134..b840f892ae5 100644 --- a/pkg/apis/batch/validation/validation.go +++ b/pkg/apis/batch/validation/validation.go @@ -199,12 +199,7 @@ func validateConcurrencyPolicy(concurrencyPolicy *batch.ConcurrencyPolicy, fldPa func validateScheduleFormat(schedule string, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} - // TODO soltysh: this should be removed when https://github.com/robfig/cron/issues/58 is fixed - tmpSchedule := schedule - if len(schedule) > 0 && schedule[0] != '@' { - tmpSchedule = "0 " + schedule - } - if _, err := cron.Parse(tmpSchedule); err != nil { + if _, err := cron.ParseStandard(schedule); err != nil { allErrs = append(allErrs, field.Invalid(fldPath, schedule, err.Error())) } diff --git a/pkg/controller/scheduledjob/utils.go b/pkg/controller/scheduledjob/utils.go index 72e10b58a96..185624b38fe 100644 --- a/pkg/controller/scheduledjob/utils.go +++ b/pkg/controller/scheduledjob/utils.go @@ -109,8 +109,7 @@ func getNextStartTimeAfter(schedule string, now time.Time) (time.Time, error) { // How to handle concurrency control. // How to detect changes to schedules or deleted schedules and then // update the jobs? - tmpSched := addSeconds(schedule) - sched, err := cron.Parse(tmpSched) + sched, err := cron.Parse(schedule) if err != nil { return time.Unix(0, 0), fmt.Errorf("Unparseable schedule: %s : %s", schedule, err) } @@ -123,8 +122,7 @@ func getNextStartTimeAfter(schedule string, now time.Time) (time.Time, error) { // If there were missed times prior to the last known start time, then those are not returned. func getRecentUnmetScheduleTimes(sj batch.ScheduledJob, now time.Time) ([]time.Time, error) { starts := []time.Time{} - tmpSched := addSeconds(sj.Spec.Schedule) - sched, err := cron.Parse(tmpSched) + sched, err := cron.ParseStandard(sj.Spec.Schedule) if err != nil { return starts, fmt.Errorf("Unparseable schedule: %s : %s", sj.Spec.Schedule, err) } @@ -172,15 +170,6 @@ func getRecentUnmetScheduleTimes(sj batch.ScheduledJob, now time.Time) ([]time.T return starts, nil } -// TODO soltysh: this should be removed when https://github.com/robfig/cron/issues/58 is fixed -func addSeconds(schedule string) string { - tmpSched := schedule - if len(schedule) > 0 && schedule[0] != '@' { - tmpSched = "0 " + schedule - } - return tmpSched -} - // XXX unit test this // getJobFromTemplate makes a Job from a ScheduledJob