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

Fix cron trait doc, timer usage is missing information #4633

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5669,8 +5669,11 @@ in order to save resources when the integration does not need to be executed.
Integrations that start from the following components are evaluated by the cron trait: `timer`, `cron`, `quartz`.

The rules for using a Kubernetes CronJob are the following:
- `timer`: when periods can be written as cron expressions. E.g. `timer:tick?period=60000`.

- `timer`: when period is set in milliseconds with no remaining seconds, for example 120000. If there is any second left as in 121000 (120s and 1s) or the presence of any of these parameters (delay, repeatCount, time) then a CronJob won't be created, but a standard deployment.

- `cron`, `quartz`: when the cron expression does not contain seconds (or the "seconds" part is set to 0). E.g.

`cron:tab?schedule=0/2$\{plus}*\{plus}*\{plus}*\{plus}?` or `quartz:trigger?cron=0\{plus}0/2\{plus}*\{plus}*\{plus}*\{plus}?`.


Expand Down
5 changes: 4 additions & 1 deletion docs/modules/traits/pages/cron.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ in order to save resources when the integration does not need to be executed.
Integrations that start from the following components are evaluated by the cron trait: `timer`, `cron`, `quartz`.

The rules for using a Kubernetes CronJob are the following:
- `timer`: when periods can be written as cron expressions. E.g. `timer:tick?period=60000`.

- `timer`: when period is set in milliseconds with no remaining seconds, for example 120000. If there is any second left as in 121000 (120s and 1s) or the presence of any of these parameters (delay, repeatCount, time) then a CronJob won't be created, but a standard deployment.

- `cron`, `quartz`: when the cron expression does not contain seconds (or the "seconds" part is set to 0). E.g.

`cron:tab?schedule=0/2${plus}*{plus}*{plus}*{plus}?` or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`.


Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/camel/v1/trait/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ package trait
// Integrations that start from the following components are evaluated by the cron trait: `timer`, `cron`, `quartz`.
//
// The rules for using a Kubernetes CronJob are the following:
// - `timer`: when periods can be written as cron expressions. E.g. `timer:tick?period=60000`.
//
// - `timer`: when period is set in milliseconds with no remaining seconds, for example 120000. If there is any second left as in 121000 (120s and 1s) or the presence of any of these parameters (delay, repeatCount, time) then a CronJob won't be created, but a standard deployment.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity. Where is this behavior defined? in the runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is defined partly in the cron.go trait and the camel-k-cron (camel-k-runtime).

//
// - `cron`, `quartz`: when the cron expression does not contain seconds (or the "seconds" part is set to 0). E.g.
//
// `cron:tab?schedule=0/2${plus}*{plus}*{plus}*{plus}?` or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`.
//
// +camel-k:trait=cron.
Expand Down
11 changes: 7 additions & 4 deletions resources/traits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,13 @@ traits:
CronJob instead of a standard deployment, in order to save resources when the
integration does not need to be executed. Integrations that start from the following
components are evaluated by the cron trait: `timer`, `cron`, `quartz`. The rules
for using a Kubernetes CronJob are the following: - `timer`: when periods can
be written as cron expressions. E.g. `timer:tick?period=60000`. - `cron`, `quartz`:
when the cron expression does not contain seconds (or the "seconds" part is set
to 0). E.g. `cron:tab?schedule=0/2${plus}*{plus}*{plus}*{plus}?` or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`.'
for using a Kubernetes CronJob are the following: - `timer`: when period is set
in milliseconds with no remaining seconds, for example 120000. If there is any
second left as in 121000 (120s and 1s) or the presence of any of these parameters
(delay, repeatCount, time) then a CronJob won''t be created, but a standard deployment.
- `cron`, `quartz`: when the cron expression does not contain seconds (or the
"seconds" part is set to 0). E.g. `cron:tab?schedule=0/2${plus}*{plus}*{plus}*{plus}?`
or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`.'
properties:
- name: enabled
type: bool
Expand Down
Loading