You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "lsergio (via GitHub)" <gi...@apache.org> on 2024/01/22 18:34:35 UTC

[I] Quartz builds failing to start when using native builds [camel-k]

lsergio opened a new issue, #5088:
URL: https://github.com/apache/camel-k/issues/5088

   ### What happened?
   
   Consider the following Integration spec:
   ```
   apiVersion: camel.apache.org/v1
   kind: Integration
   metadata:
     name: test-jvm
   spec:
     sources:
     - name: main.groovy
       content: |-
         from("quartz://Scheduler_Trigger?cron=*+*+*+*+*")
             .to("direct:start")
   
         from("direct:start")
           .to("https://httpbin.org/delay/2?bridgeEndpoint=true")
           .to("log:info")
     traits:
       container:
         requestCPU: "200m"
         requestMemory: 400Mi
         limitMemory: 400Mi
       quarkus:
         buildMode:
         - jvm
       affinity:
         enabled: true
         nodeAffinityLabels:
           - "karpenter=false"
   ```
   When I apply it to my cluster, I get a CronJob that is set up with the * * * * * schedule, and the integration runs smoothly:
   ```
   k get cronjob
   NAME       SCHEDULE    SUSPEND   ACTIVE   LAST SCHEDULE   AGE
   test-jvm   * * * * *   False     0        25s             112s
   k get pod
   NAME                                READY   STATUS      RESTARTS   AGE
   camel-k-operator-6cbc656bbd-ntk99   1/1     Running     0          3m16s
   test-jvm-28432451-6l275             0/1     Completed   0          91s
   test-jvm-28432452-wqr55             0/1     Completed   0          31s
   ```
   
   However, If I modify this code to use native builds, as below:
   
   ```
   apiVersion: camel.apache.org/v1
   kind: Integration
   metadata:
     name: test-native
   spec:
     sources:
     - name: main.groovy
       content: |-
         from("quartz://Scheduler_Trigger?cron=*+*+*+*+*")
             .to("direct:start")
   
         from("direct:start")
           .to("https://httpbin.org/delay/2?bridgeEndpoint=true")
           .to("log:info")
     traits:
       container:
         requestCPU: "200m"
         requestMemory: 20Mi
         limitMemory: 20Mi
       quarkus:
         buildMode:
         - native
       builder:
         properties:
         - "quarkus.native.native-image-xmx=13g"
         tasksRequestCPU:
         - "quarkus-native:8000m"
         tasksRequestMemory:
         - "quarkus-native:16Gi"
         tasksLimitMemory:
         - "quarkus-native:16Gi"
         nodeSelector:
           karpenter: "true"
       affinity:
         enabled: true
         nodeAffinityLabels:
           - "karpenter=false"
   ```
   I still get the same `CronJob`:
   ```
   k get cronjob
   NAME          SCHEDULE    SUSPEND   ACTIVE   LAST SCHEDULE   AGE
   test-native   * * * * *   False     0        <none>          11s
   ```
   But the Integration will fail to run with the following error:
   ```
   Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of CronExpression '* * * * *' is invalid.
   	at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:122)
   
   ```
   
   It seems like the scheduling is being configured at the CronJob and also at the application level, with quartz, where * * * * * is not a valid expression.
     
   
   
   ### Steps to reproduce
   
   _No response_
   
   ### Relevant log output
   
   ```shell
   java.lang.RuntimeException: Failed to start quarkus
   	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
   	at io.quarkus.runtime.Application.start(Application.java:101)
   	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
   	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
   	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
   	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
   	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
   Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of CronExpression '* * * * *' is invalid.
   	at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:47)
   	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source)
   	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy(Unknown Source)
   	... 7 more
   Caused by: java.lang.RuntimeException: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of CronExpression '* * * * *' is invalid.
   	at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:65)
   	at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45)
   	... 9 more
   Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of CronExpression '* * * * *' is invalid.
   	at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:122)
   	at org.apache.camel.impl.engine.InternalRouteStartupManager.doWarmUpRoutes(InternalRouteStartupManager.java:306)
   	at org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:189)
   	at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147)
   	at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2821)
   	at org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:2503)
   	at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2458)
   	at org.apache.camel.support.service.BaseService.start(BaseService.java:113)
   	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2094)
   	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:313)
   	at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94)
   	at org.apache.camel.support.service.BaseService.start(BaseService.java:113)
   	at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140)
   	at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
   	... 10 more
   Caused by: java.lang.RuntimeException: CronExpression '* * * * *' is invalid.
   	at org.quartz.CronScheduleBuilder.cronSchedule(CronScheduleBuilder.java:111)
   	at org.apache.camel.component.quartz.QuartzEndpoint.createTrigger(QuartzEndpoint.java:497)
   	at org.apache.camel.component.quartz.QuartzEndpoint.addJobInScheduler(QuartzEndpoint.java:373)
   	at org.apache.camel.component.quartz.QuartzEndpoint.doStart(QuartzEndpoint.java:329)
   	at org.apache.camel.support.service.BaseService.start(BaseService.java:113)
   	at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113)
   	at org.apache.camel.impl.engine.RouteService.doWarmUp(RouteService.java:183)
   	at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:120)
   	... 23 more
   Caused by: java.text.ParseException: Unexpected end of expression.
   	at org.quartz.CronExpression.buildExpression(CronExpression.java:494)
   	at org.quartz.CronExpression.<init>(CronExpression.java:276)
   	at org.quartz.CronScheduleBuilder.cronSchedule(CronScheduleBuilder.java:107)
   	... 30 more
   ```
   
   
   ### Camel K version
   
   2.2.0


-- 
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: commits-unsubscribe@camel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1907755997

   @lsergio to clarify what you are trying to do, what does your cron expression "* * * * *" should mean in terms of execution schedule ? Because in the end this is not a valid quartz expression as it should contain  6 or 7 fields.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1906336440

   @squakez I'll take care of it.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1908835019

   Sorry I was not clear, it is clear that there is a bug here. I am just trying to get to it.
   
   As @squakez suspected something is not working well with the camel-k-runtime cron `LoaderInterceptor` that is not applied in the native mode, even with a valid quartz expression `0 * * * * ?`.
   
   **JVM** mode replace quartz by `timer://camel-k-cron-override` and the cronjob is created:
   ```
   INFO  [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 4.0.2 is starting
   INFO  [org.apa.cam.k.sup.SourcesSupport] (main) Loading routes from: SourceDefinition{name='main', language='groovy', interceptors='[cron]', type='source', location='file:/etc/camel/sources/main.groovy', }
   INFO  [io.qua.qua.run.QuartzSchedulerImpl] (main) No scheduled business methods found - Quartz scheduler will not be started
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.0.2 (camel-1) is starting
   INFO  [org.apa.cam.com.qua.QuartzComponent] (main) Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (started:2)
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (timer://camel-k-cron-override)
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route2 (direct://start)
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.0.2 (camel-1) started in 182ms (build:0ms init:0ms start:182ms)
   INFO  [org.apa.cam.com.qua.QuartzComponent] (main) Starting Quartz scheduler: org.quartz.impl.StdScheduler@3b1137b0
   INFO  [org.apa.cam.mai.MainSupport] (camel-main) Waiting until complete: Duration idle 5 seconds
   ```
   
   
   **Native** mode keeps the original quartz scheduling `quartz://Scheduler_Trigger`, even if the cronjob is created:
   ```
   INFO  [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 4.0.2 is starting
   INFO  [io.qua.qua.run.QuartzSchedulerImpl] (main) No scheduled business methods found - Quartz scheduler will not be started
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.0.2 (camel-1) is starting
   INFO  [org.apa.cam.com.qua.QuartzComponent] (main) Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX
   INFO  [org.apa.cam.com.qua.QuartzEndpoint] (main) Job Camel_camel-1.Scheduler_Trigger (cron=0 * * * * ?, triggerType=CronTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2024-01-24T19:56:00.000+0000
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (started:2)
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (quartz://Scheduler_Trigger)
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route2 (direct://start)
   INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.0.2 (camel-1) started in 12ms (build:0ms init:0ms start:12ms)
   INFO  [org.apa.cam.com.qua.QuartzComponent] (main) Starting Quartz scheduler: org.quartz.impl.StdScheduler@79a19340
   INFO  [io.quarkus] (main) camel-k-integration 2.3.0-SNAPSHOT native (powered by Quarkus 3.2.9.Final) started in 0.046s. 
   2024-01-24 19:56:00,821 INFO  [org.apa.cam.mai.MainSupport] (camel-main) Waiting until complete: Duration idle 5 seconds
   ```


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1905692487

   If I had to hazard a guess, it could be because the cronjob spec expect 5 field in its cron expression while quartz expect 6 to 7. I suspect that the fact the native version contains the source in the jar is the root of the issue.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "lsergio (via GitHub)" <gi...@apache.org>.
lsergio commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1919579855

   @gansheer It worked for me. Howver, the only issue is that the Cron trait does not allow me to use timezones. I opened #5121 to handle that.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1912384954

   The mechanism used is the following:
   - camel-k identifies if the integration start with a timer, cron or quartz component and creates a cronjob if the cron expression is valid. This is the part that works in both JVM and native modes.
   - camel-k-runtime replace at runtime the original timer, cron or quartz component expression in the source by the following one `timer:camel-k-cron-override?delay=0&period=1&repeatCount=1`. That's where it fails in native mode. This replacement needs the source file available at runtime, which can not be possible with native build since it is integrated at build and is part of the executable.
   
   A refactoring is in progress to remove the camel-k-runtime dependency (#4024), and the cron trait part it contains will be adapted.
   
   For now if you need to have the native version working I suggest to manually do the change directly in the integration:
   ```
   ...
     sources:
     - name: main.groovy
       content: |-
         from("timer:camel-k-cron-override?delay=0&period=1&repeatCount=1")
             .to("direct:start")
   
         from("direct:start")
           .to("https://httpbin.org/delay/2?bridgeEndpoint=true")
           .to("log:info")
     traits:
       cron:
         enabled: true
         schedule: "* * * * ?"
         components: ""
   ...
   ```
   
   This should give you the same result for JVM and native builds. 


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "lsergio (via GitHub)" <gi...@apache.org>.
lsergio commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1908709736

   Per https://camel.apache.org/camel-k/2.2.x/traits/cron.html:
   
   The rules for using a Kubernetes CronJob are the following:
   cron, quartz: when the cron expression does not contain seconds (or the "seconds" part is set to 0). 


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "squakez (via GitHub)" <gi...@apache.org>.
squakez commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1906442085

   @lsergio let's see if we manage to fix. Once it's fixed we can discuss the opportunity to backport and if it makes sense to cut a release on a minor.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "squakez (via GitHub)" <gi...@apache.org>.
squakez closed issue #5088: Quartz builds failing to start when using native builds
URL: https://github.com/apache/camel-k/issues/5088


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "lsergio (via GitHub)" <gi...@apache.org>.
lsergio commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1904629660

   If I change my expression to `0 * * * * ?`, no CronJob is created and the application runs successfully. However, this is not desired, as the pod would be idle, wasting resources, specially if we move to expressions with longer intervals. 


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1920740379

   @lsergio Thanks for your feedback, I will update the documentation to indicate the limitation in native mode for now.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "lsergio (via GitHub)" <gi...@apache.org>.
lsergio commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1908706695

   @gansheer My goal is to run the integration every minute.
   
   The main point here is that it works on jvm mode, where the scheduling is done with a CronJob, which accepts the 5-character pattern. The application in this doesn't deal with the scheduling, so we're not actually Quartz Scheduling.
     
   When I use native mode, though, the behavior changes.  The CronJob is created, but the application is also interpreting the cron pattern, which it shouldn't imho, as scheduling is done at the CronJob level.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "squakez (via GitHub)" <gi...@apache.org>.
squakez commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1905505702

   Thanks for reporting. The cronjob logic happens in the Camel K runtime. I wonder if the failure is because of that by any chance.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "lsergio (via GitHub)" <gi...@apache.org>.
lsergio commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1906423482

   Hi @squakez and @gansheer. Is there any chance of adding this to a 2.2.1 release as well?


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Quartz builds failing to start when using native builds [camel-k]

Posted by "lsergio (via GitHub)" <gi...@apache.org>.
lsergio commented on issue #5088:
URL: https://github.com/apache/camel-k/issues/5088#issuecomment-1912652411

   @gansheer thanks for the suggestion. I'll give it a try.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org