Skip to content

Commit

Permalink
fix(cron): move logic outside camel-k-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Feb 5, 2024
1 parent a790439 commit 6808e35
Show file tree
Hide file tree
Showing 45 changed files with 641 additions and 235 deletions.
12 changes: 6 additions & 6 deletions config/crd/bases/camel.apache.org_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,9 @@ spec:
Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers
the org.apache.camel.k.RoutesLoader uses to pre/post
process sources
description: 'Deprecated: no longer in use Interceptors
are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources'
items:
type: string
type: array
Expand Down Expand Up @@ -1524,9 +1524,9 @@ spec:
Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers
the org.apache.camel.k.RoutesLoader uses to pre/post
process sources
description: 'Deprecated: no longer in use Interceptors
are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources'
items:
type: string
type: array
Expand Down
5 changes: 3 additions & 2 deletions config/crd/bases/camel.apache.org_integrationkits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors are
optional identifiers the org.apache.camel.k.RoutesLoader uses
to pre/post process sources'
items:
type: string
type: array
Expand Down
20 changes: 6 additions & 14 deletions config/crd/bases/camel.apache.org_integrationplatforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -742,14 +742,10 @@ spec:
format: int32
type: integer
components:
description: "A comma separated list of the Camel components
description: 'A comma separated list of the Camel components
that need to be customized in order for them to work when
the schedule is triggered externally by Kubernetes. A specific
customizer is activated for each specified component. E.g.
for the `timer` component, the `cron-timer` customizer is
activated (it's present in the `org.apache.camel.k:camel-k-cron`
library). \n Supported components are currently: `cron`,
`timer` and `quartz`."
the schedule is triggered externally by Kubernetes. Supported
components are currently: `cron`, `timer` and `quartz`.'
type: string
concurrencyPolicy:
description: 'Specifies how to treat concurrent executions
Expand Down Expand Up @@ -2623,14 +2619,10 @@ spec:
format: int32
type: integer
components:
description: "A comma separated list of the Camel components
description: 'A comma separated list of the Camel components
that need to be customized in order for them to work when
the schedule is triggered externally by Kubernetes. A specific
customizer is activated for each specified component. E.g.
for the `timer` component, the `cron-timer` customizer is
activated (it's present in the `org.apache.camel.k:camel-k-cron`
library). \n Supported components are currently: `cron`,
`timer` and `quartz`."
the schedule is triggered externally by Kubernetes. Supported
components are currently: `cron`, `timer` and `quartz`.'
type: string
concurrencyPolicy:
description: 'Specifies how to treat concurrent executions
Expand Down
20 changes: 9 additions & 11 deletions config/crd/bases/camel.apache.org_integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors are
optional identifiers the org.apache.camel.k.RoutesLoader uses
to pre/post process sources'
items:
type: string
type: array
Expand Down Expand Up @@ -6649,14 +6650,10 @@ spec:
format: int32
type: integer
components:
description: "A comma separated list of the Camel components
description: 'A comma separated list of the Camel components
that need to be customized in order for them to work when
the schedule is triggered externally by Kubernetes. A specific
customizer is activated for each specified component. E.g.
for the `timer` component, the `cron-timer` customizer is
activated (it's present in the `org.apache.camel.k:camel-k-cron`
library). \n Supported components are currently: `cron`,
`timer` and `quartz`."
the schedule is triggered externally by Kubernetes. Supported
components are currently: `cron`, `timer` and `quartz`.'
type: string
concurrencyPolicy:
description: 'Specifies how to treat concurrent executions
Expand Down Expand Up @@ -7978,8 +7975,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors are
optional identifiers the org.apache.camel.k.RoutesLoader uses
to pre/post process sources'
items:
type: string
type: array
Expand Down
14 changes: 6 additions & 8 deletions config/crd/bases/camel.apache.org_kameletbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors
are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources'
items:
type: string
type: array
Expand Down Expand Up @@ -6936,14 +6937,11 @@ spec:
format: int32
type: integer
components:
description: "A comma separated list of the Camel components
description: 'A comma separated list of the Camel components
that need to be customized in order for them to work
when the schedule is triggered externally by Kubernetes.
A specific customizer is activated for each specified
component. E.g. for the `timer` component, the `cron-timer`
customizer is activated (it's present in the `org.apache.camel.k:camel-k-cron`
library). \n Supported components are currently: `cron`,
`timer` and `quartz`."
Supported components are currently: `cron`, `timer`
and `quartz`.'
type: string
concurrencyPolicy:
description: 'Specifies how to treat concurrent executions
Expand Down
10 changes: 6 additions & 4 deletions config/crd/bases/camel.apache.org_kamelets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors are
optional identifiers the org.apache.camel.k.RoutesLoader uses
to pre/post process sources'
items:
type: string
type: array
Expand Down Expand Up @@ -1173,8 +1174,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors are
optional identifiers the org.apache.camel.k.RoutesLoader uses
to pre/post process sources'
items:
type: string
type: array
Expand Down
14 changes: 6 additions & 8 deletions config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ spec:
description: True if the spec is generated from a Kamelet
type: boolean
interceptors:
description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
description: 'Deprecated: no longer in use Interceptors
are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources'
items:
type: string
type: array
Expand Down Expand Up @@ -6934,14 +6935,11 @@ spec:
format: int32
type: integer
components:
description: "A comma separated list of the Camel components
description: 'A comma separated list of the Camel components
that need to be customized in order for them to work
when the schedule is triggered externally by Kubernetes.
A specific customizer is activated for each specified
component. E.g. for the `timer` component, the `cron-timer`
customizer is activated (it's present in the `org.apache.camel.k:camel-k-cron`
library). \n Supported components are currently: `cron`,
`timer` and `quartz`."
Supported components are currently: `cron`, `timer`
and `quartz`.'
type: string
concurrencyPolicy:
description: 'Specifies how to treat concurrent executions
Expand Down
6 changes: 2 additions & 4 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5076,6 +5076,7 @@ interpret this source at runtime
|
Deprecated: no longer in use
Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
uses to pre/post process sources
Expand Down Expand Up @@ -6170,7 +6171,7 @@ 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). E.g.
`cron:tab?schedule=0/2$\{plus}*\{plus}*\{plus}*\{plus}?` or `quartz:trigger?cron=0\{plus}0/2\{plus}*\{plus}*\{plus}*\{plus}?`.
`cron:tab?schedule=0/2 * * * ?` or `quartz:trigger?cron=0 0/2 * * * ?`.
[cols="2,2a",options="header"]
Expand Down Expand Up @@ -6199,9 +6200,6 @@ string
A comma separated list of the Camel components that need to be customized in order for them to work when the schedule is triggered externally by Kubernetes.
A specific customizer is activated for each specified component. E.g. for the `timer` component, the `cron-timer` customizer is
activated (it's present in the `org.apache.camel.k:camel-k-cron` library).
Supported components are currently: `cron`, `timer` and `quartz`.
|`fallback` +
Expand Down
5 changes: 1 addition & 4 deletions docs/modules/traits/pages/cron.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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). E.g.

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


This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
Expand Down Expand Up @@ -48,9 +48,6 @@ mechanism to work correctly.
| cron.components
| string
| A comma separated list of the Camel components that need to be customized in order for them to work when the schedule is triggered externally by Kubernetes.
A specific customizer is activated for each specified component. E.g. for the `timer` component, the `cron-timer` customizer is
activated (it's present in the `org.apache.camel.k:camel-k-cron` library).

Supported components are currently: `cron`, `timer` and `quartz`.

| cron.fallback
Expand Down
31 changes: 14 additions & 17 deletions e2e/common/misc/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,37 @@ import (
func TestRunCronExample(t *testing.T) {
RegisterTestingT(t)

t.Run("cron", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
t.Run("cron-timer", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, "cron-timer", v1.IntegrationConditionCronJobAvailable), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
})

t.Run("cron-yaml", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron-yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron-yaml"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron-yaml", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, "cron-yaml", v1.IntegrationConditionCronJobAvailable), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-yaml"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
})

t.Run("cron-timer", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
t.Run("cron-quartz", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron-quartz.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "cron-quartz"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "cron-quartz", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, "cron-quartz", v1.IntegrationConditionCronJobAvailable), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-quartz"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
})

t.Run("cron-fallback", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron-fallback.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "cron-fallback"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "cron-fallback", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationConditionStatus(ns, "cron-fallback", v1.IntegrationConditionCronJobAvailable), TestTimeoutMedium).Should(Equal(corev1.ConditionFalse))
Eventually(IntegrationLogs(ns, "cron-fallback"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
})

t.Run("cron-quartz", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/cron-quartz.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "cron-quartz"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "cron-quartz", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-quartz"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
})

Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
}
2 changes: 1 addition & 1 deletion e2e/common/misc/files/cron-quartz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from:
uri: "quartz:trigger"
parameters:
cron: "0/1 * * * * ?"
cron: "0 0/1 * * * ?"
steps:
- setHeader:
name: "m"
Expand Down
31 changes: 0 additions & 31 deletions e2e/common/misc/files/cron.yaml

This file was deleted.

Loading

0 comments on commit 6808e35

Please sign in to comment.