Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

cronjob: handle invalid/unschedulable dates#26

Merged
tomwans merged 1 commit intolyft:release-1.16.15-lyft.1from
tomwans:release-1.16-lyft-cronjobfix
Feb 9, 2021
Merged

cronjob: handle invalid/unschedulable dates#26
tomwans merged 1 commit intolyft:release-1.16.15-lyft.1from
tomwans:release-1.16-lyft-cronjobfix

Conversation

@tomwans
Copy link
Copy Markdown

@tomwans tomwans commented Feb 9, 2021

There is a case for tricky cron schedules, like 0 0 31 2 *, which
intends to run on Feb 31st. This date does not exist at the moment,
which can cause the earliest-missed-deadline math go into an infinite
loop.

Thankfully, the cron library returns a "zero date" when a next
schedule is not found within 5 years:

https://github.com/robfig/cron/blob/6a8421bcff44c2a9889075724070baaebf8dcd72/spec.go#L87-L88

We rely on seeing this zero date and short-circuit out of our
recursive algorithm.

There is a case for tricky cron schedules, like 0 0 31 2 *, which
intends to run on Feb 31st. This date does not exist at the moment,
which can cause the earliest-missed-deadline math go into an infinite
loop.

Thankfully, the cron library returns a "zero date" when a next
schedule is not found within 5 years:

https://github.com/robfig/cron/blob/6a8421bcff44c2a9889075724070baaebf8dcd72/spec.go#L87-L88

We rely on seeing this zero date and short-circuit out of our
recursive algorithm.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants