0z5a opened a new pull request, #6972:
URL: https://github.com/apache/camel-k/pull/6972
<!-- Description -->
Fixes #6971
When the cron trait turns a `quartz` or `cron` endpoint into a Kubernetes
CronJob, the day-of-week field is copied as is. Quartz numbers the days 1-7
(SUN-SAT), but a CronJob schedule numbers them 0-6 (SUN-SAT), so every numeric
weekday ends up shifted by one day.
For example `from("quartz:trigger?cron=0+0+9+?+*+2")` (09:00 on Mondays in
Quartz) currently becomes the CronJob schedule `0 9 ? * 2`, which Kubernetes
runs on Tuesdays. `2-6` (Monday to Friday) becomes Tuesday to Saturday. Since
the trait replaces the route consumer with a one-shot timer, the CronJob
schedule is the only trigger, so the integration silently runs on the wrong
days.
Values that only exist in Quartz are also copied over and give a schedule
Kubernetes rejects: `7` (Saturday), as in `1,7`, fails with "end of range (7)
above maximum (6)", and `6L` or `6#3` cannot be parsed at all.
This change converts the day-of-week field when the expression is in Quartz
format (6 or 7 fields, i.e. with seconds): single days, ranges, lists and steps
are shifted to the 0-6 numbering, day names such as `MON-FRI` are left as they
are. If the field uses something that has no CronJob equivalent (`L`, `#`, out
of range values), no CronJob schedule is derived, so the integration keeps
using the Camel implementation, as already happens for expressions with
non-zero seconds or a year.
Five field expressions (`cron:tab?schedule=0 9 * * 1`) are already in the
Kubernetes format and are not changed.
I also compared the results outside the test suite: for a set of expressions
(single days, ranges, lists, steps, names) the next 30 fire times of the
original expression computed with a Quartz cron implementation (go-quartz)
match those of the generated schedule computed with robfig/cron v3, the parser
Kubernetes uses for CronJob schedules.
New cases were added to `TestCronFromURI`; they fail without the fix and
pass with it.
<!--
Please, describe the PR intent carefully, linking it to the github issue
that it wants to address.
-->
This change was drafted with Claude Code (claude-opus-5-5) on behalf of
@0z5a; the test results above are from the runs described.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]