diff --git a/resource_customizations/camel.apache.org/Integration/health.lua b/resource_customizations/camel.apache.org/Integration/health.lua new file mode 100644 index 0000000000..d2c7494e36 --- /dev/null +++ b/resource_customizations/camel.apache.org/Integration/health.lua @@ -0,0 +1,24 @@ +local hs = {} +if obj.status ~= nil then + if obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + -- Let's check if something is wrong with the CRD deployment + if condition.type == "Ready" and condition.status == "False" then + hs.status = "Degraded" + hs.message = condition.message + return hs + end + -- Let's check if things are healthy with the CRD deployment + if condition.type == "Ready" and condition.status == "True" then + hs.status = "Healthy" + hs.message = condition.message + return hs + end + end + end +end + +-- Otherwise let's assume that we are still busy building/deploying the Integration +hs.status = "Progressing" +hs.message = "Waiting for Integration" +return hs diff --git a/resource_customizations/camel.apache.org/Integration/health_test.yaml b/resource_customizations/camel.apache.org/Integration/health_test.yaml new file mode 100644 index 0000000000..44d6fb38f2 --- /dev/null +++ b/resource_customizations/camel.apache.org/Integration/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Progressing + message: "Waiting for Integration" + inputPath: testdata/progressing.yaml +- healthStatus: + status: Healthy + message: "" + inputPath: testdata/healthy.yaml +- healthStatus: + status: Degraded + message: "back-off 40s restarting failed container=integration pod=camelk-example-deployment" + inputPath: testdata/degraded.yaml diff --git a/resource_customizations/camel.apache.org/Integration/testdata/degraded.yaml b/resource_customizations/camel.apache.org/Integration/testdata/degraded.yaml new file mode 100644 index 0000000000..40b6e69641 --- /dev/null +++ b/resource_customizations/camel.apache.org/Integration/testdata/degraded.yaml @@ -0,0 +1,58 @@ +apiVersion: camel.apache.org/v1 +kind: Integration +metadata: + annotations: + camel.apache.org/operator.id: camel-k + generation: 1 + name: camelk-example + namespace: default +spec: + sources: + - content: | + from('timer:tick?period=3000') + .setBody().constant('Hello world from Camel-K') + .to('log:info') + name: camelk-example.groovy + traits: {} +status: + conditions: + - firstTruthyTime: "2024-01-26T16:01:50Z" + lastTransitionTime: "2024-01-26T16:01:50Z" + lastUpdateTime: "2024-01-26T16:01:50Z" + message: camel-k/camel-k + reason: IntegrationPlatformAvailable + status: "True" + type: IntegrationPlatformAvailable + - firstTruthyTime: "2024-01-26T16:01:52Z" + lastTransitionTime: "2024-01-26T16:01:52Z" + lastUpdateTime: "2024-01-26T16:01:52Z" + message: kit-cmkkksgve68c73e60i60 + reason: IntegrationKitAvailable + status: "True" + type: IntegrationKitAvailable + - lastTransitionTime: "2024-01-26T16:01:52Z" + lastUpdateTime: "2024-01-26T16:01:52Z" + message: different controller strategy used (knative-service) + reason: CronJobNotAvailableReason + status: "False" + type: CronJobAvailable + - lastTransitionTime: "2024-01-26T16:01:52Z" + lastUpdateTime: "2024-01-26T16:01:52Z" + message: 'controller strategy: knative-service' + reason: DeploymentAvailable + status: "False" + type: DeploymentAvailable + - firstTruthyTime: "2024-01-26T16:01:52Z" + lastTransitionTime: "2024-01-26T16:01:52Z" + lastUpdateTime: "2024-01-26T16:01:52Z" + message: Knative service name is api-example + reason: KnativeServiceAvailable + status: "True" + type: KnativeServiceAvailable + - lastTransitionTime: "2024-01-26T16:01:52Z" + lastUpdateTime: "2024-01-26T16:02:55Z" + message: back-off 40s restarting failed container=integration pod=camelk-example-deployment + reason: Error + status: "False" + type: Ready + phase: Error diff --git a/resource_customizations/camel.apache.org/Integration/testdata/healthy.yaml b/resource_customizations/camel.apache.org/Integration/testdata/healthy.yaml new file mode 100644 index 0000000000..6fb5e5e462 --- /dev/null +++ b/resource_customizations/camel.apache.org/Integration/testdata/healthy.yaml @@ -0,0 +1,58 @@ +apiVersion: camel.apache.org/v1 +kind: Integration +metadata: + annotations: + camel.apache.org/operator.id: camel-k + generation: 1 + name: camelk-example + namespace: default +spec: + sources: + - content: | + from('timer:tick?period=3000') + .setBody().constant('Hello world from Camel-K') + .to('log:info') + name: camelk-example.groovy + traits: {} +status: + conditions: + - firstTruthyTime: "2024-01-26T09:13:16Z" + lastTransitionTime: "2024-01-26T09:13:16Z" + lastUpdateTime: "2024-01-26T09:13:16Z" + message: camel-k/camel-k + reason: IntegrationPlatformAvailable + status: "True" + type: IntegrationPlatformAvailable + - firstTruthyTime: "2024-01-26T09:13:19Z" + lastTransitionTime: "2024-01-26T09:13:19Z" + lastUpdateTime: "2024-01-26T09:13:19Z" + message: kit-cmkkksgve68c73e60i60 + reason: IntegrationKitAvailable + status: "True" + type: IntegrationKitAvailable + - lastTransitionTime: "2024-01-26T09:13:19Z" + lastUpdateTime: "2024-01-26T09:13:19Z" + message: different controller strategy used (knative-service) + reason: CronJobNotAvailableReason + status: "False" + type: CronJobAvailable + - lastTransitionTime: "2024-01-26T09:13:19Z" + lastUpdateTime: "2024-01-26T09:13:19Z" + message: 'controller strategy: knative-service' + reason: DeploymentAvailable + status: "False" + type: DeploymentAvailable + - firstTruthyTime: "2024-01-26T09:13:19Z" + lastTransitionTime: "2024-01-26T09:13:19Z" + lastUpdateTime: "2024-01-26T09:13:19Z" + message: Knative service name is camelk-example + reason: KnativeServiceAvailable + status: "True" + type: KnativeServiceAvailable + - firstTruthyTime: "2024-01-26T09:13:31Z" + lastTransitionTime: "2024-01-26T09:13:31Z" + lastUpdateTime: "2024-01-26T09:13:31Z" + reason: KnativeServiceReady + status: "True" + type: Ready + phase: Running diff --git a/resource_customizations/camel.apache.org/Integration/testdata/progressing.yaml b/resource_customizations/camel.apache.org/Integration/testdata/progressing.yaml new file mode 100644 index 0000000000..58e7b4af64 --- /dev/null +++ b/resource_customizations/camel.apache.org/Integration/testdata/progressing.yaml @@ -0,0 +1,39 @@ +apiVersion: camel.apache.org/v1 +kind: Integration +metadata: + annotations: + camel.apache.org/operator.id: camel-k + generation: 1 + name: camelk-example + namespace: default +spec: + sources: + - content: | + from('timer:tick?period=3000') + .setBody().constant('Hello world from Camel-K') + .to('log:info') + name: camelk-example.groovy + traits: {} +status: + conditions: + - firstTruthyTime: "2024-01-26T09:13:16Z" + lastTransitionTime: "2024-01-26T09:13:16Z" + lastUpdateTime: "2024-01-26T09:13:16Z" + message: camel-k/camel-k + reason: IntegrationPlatformAvailable + status: "True" + type: IntegrationPlatformAvailable + - firstTruthyTime: "2024-01-26T09:13:19Z" + lastTransitionTime: "2024-01-26T09:13:19Z" + lastUpdateTime: "2024-01-26T09:13:19Z" + message: kit-cmkkksgve68c73e60i60 + reason: IntegrationKitAvailable + status: "True" + type: IntegrationKitAvailable + - lastTransitionTime: "2024-01-26T09:13:19Z" + lastUpdateTime: "2024-01-26T09:13:19Z" + message: different controller strategy used (knative-service) + reason: CronJobNotAvailableReason + status: "False" + type: CronJobAvailable + phase: Deploying \ No newline at end of file