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

Remove seconds from scheduled jobs cron format #30227

Merged
merged 1 commit into from
Aug 10, 2016

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Aug 8, 2016

@erictune @janetkuo as promised this removes the seconds from the cron format


This change is Reviewable

@soltysh soltysh added area/batch release-note-none Denotes a PR that doesn't merit a release note. labels Aug 8, 2016
@k8s-github-robot k8s-github-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 8, 2016
@soltysh soltysh assigned janetkuo and unassigned lavalamp Aug 8, 2016
@soltysh soltysh mentioned this pull request Aug 8, 2016
if err != nil {
allErrs = append(allErrs, field.Invalid(fldPath, schedule, err.Error()))
}
if ssObj, ok := obj.(*cron.SpecSchedule); ok {
if ssObj.Second != 1 {
Copy link
Member

Choose a reason for hiding this comment

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

move this to the end of the parent if

@soltysh
Copy link
Contributor Author

soltysh commented Aug 9, 2016

@janetkuo comments addressed, ptal

@@ -125,7 +125,11 @@ 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{}
sched, err := cron.Parse(sj.Spec.Schedule)
tmpSched := sj.Spec.Schedule
Copy link
Member

Choose a reason for hiding this comment

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

Shall we make this (L128-132) our own Parse function?

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like only parsed data adjust, so maybe it should have other name, but still extracting this and adding a name for this block - could improve readability of this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll create one. I've already spoke with cron library author, I'll be addressing those issues in the library, when I'm back from my PTO in Sep.

@janetkuo
Copy link
Member

janetkuo commented Aug 9, 2016

Fix the last two nits and then this lgtm.

@janetkuo
Copy link
Member

janetkuo commented Aug 9, 2016

Just found that getNextStartTimeAfter in pkg/controller/scheduledjob/utils.go also calls cron.Parse(schedule). We need to update it also.

@soltysh
Copy link
Contributor Author

soltysh commented Aug 9, 2016

Just found that getNextStartTimeAfter in pkg/controller/scheduledjob/utils.go also calls cron.Parse(schedule). We need to update it also.

I'll do once again a grep over the sources looking for that, just to make sure. Thanks for the review.

@janetkuo
Copy link
Member

janetkuo commented Aug 9, 2016

Oh, and the example in kubectl run needs to be updated too

@janetkuo janetkuo added this to the v1.4 milestone Aug 10, 2016
@soltysh
Copy link
Contributor Author

soltysh commented Aug 10, 2016

Nits addressed, the temporary method and places where we're adding seconds are commented with a pointer to robfig/cron#58 which when fixed, will replace them.
Applying lgtm label based on the previous approval.

@soltysh soltysh added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 10, 2016
@k8s-bot
Copy link

k8s-bot commented Aug 10, 2016

GCE e2e build/test passed for commit 902ecd8.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Aug 10, 2016

GCE e2e build/test passed for commit 902ecd8.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit cc7d509 into kubernetes:master Aug 10, 2016
@soltysh soltysh deleted the remove_seconds branch August 10, 2016 11:40
k8s-github-robot pushed a commit that referenced this pull request Sep 23, 2016
Automatic merge from submit-queue

Remove hacks from ScheduledJobs cron spec parsing 

Previusly `github.com/robfig/cron` library did not allow passing cron spec without seconds. First commit updates the library, which has additional method ParseStandard which follows the standard cron spec, iow. minute, hour, day of month, month, day of week.

@janetkuo @erictune as promised in #30227 I've updated the library and now I'm updating it in k8s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/batch lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants