camel-k icon indicating copy to clipboard operation
camel-k copied to clipboard

Ability to use timezones when using quartz component and CronJob strategy

Open lsergio opened this issue 1 year ago • 2 comments

Requirement

Consider the scenario where I set up an Integration with the following endpoint:

from("quartz://groupName/timerName?cron=* 10-12 * * *&trigger.timeZone=America/Sao_Paulo")

This is supposed to run everyday from 10am to noon on Sao Paulo timezone.

As I create the integration in my cluster, it will create a CronJob with the 10-12 schedule. However, CronJobs run on the k8s node timezone, which in my case is UTC. So the integration would run with a 3-hour offset.

Problem

I would like to have my end users select the timezone they wish to run theirs jobs on, but with the limitation I will either force them to use UTC, or configure my cron trait with fallback: true to support timezone. Using fallback: true, however, keeps the integration pod running all the time, which may waste resources.

Proposal

Since Kubernetes 1.27, CronJobs support timezone configuration in their spec, so I think we can extract that info from the quartz endpoint and use it to build the CronJob.

Open questions

No response

lsergio avatar Jan 30 '24 11:01 lsergio

We can include the parameter in the trait configuration and let the user configure it. I'm about to rework the cron runtime in #5090 so we may have a look at this once that development is over.

squakez avatar Jan 30 '24 15:01 squakez

#5090 was dropped in favor of moving the logic directly in the runtime, eventually. I think for the time being this can be developed on Camel K side while the runtimes are not fully available. @lsergio are you planning to work on this by any chance?

squakez avatar Apr 05 '24 11:04 squakez

Sorry @squakez, I missed your comment in April. If we're ok with adding a field to the cron trait that will be used to create the CronJob, I can work on it.

lsergio avatar Jun 20 '24 17:06 lsergio

Excellent, thanks @lsergio !

squakez avatar Jun 21 '24 08:06 squakez