Skip to content
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
39 changes: 39 additions & 0 deletions resource_customizations/keda.sh/ScaledJob/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
local hs = {}
local healthy = false
local degraded = false
local suspended = false
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.status == "False" and condition.type == "Ready" then
hs.message = condition.message
degraded = true
end
if condition.status == "True" and condition.type == "Ready" then
hs.message = condition.message
healthy = true
end
if condition.status == "True" and condition.type == "Paused" then
hs.message = condition.message
suspended = true
end
if condition.status == "Unknown" and condition.type == "Ready" then
hs.message = condition.message
degraded = true
end
end
end
end
if degraded == true then
hs.status = "Degraded"
return hs
elseif healthy == true and suspended == false then
hs.status = "Healthy"
return hs
elseif healthy == true and suspended == true then
hs.status = "Suspended"
return hs
end
hs.status = "Progressing"
hs.message = "Waiting for ScaledJob"
return hs
21 changes: 21 additions & 0 deletions resource_customizations/keda.sh/ScaledJob/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Progressing
message: "Waiting for ScaledJob"
inputPath: testdata/keda-progressing.yaml
- healthStatus:
status: Degraded
message: "Triggers defined in ScaledJob are not working correctly"
inputPath: testdata/keda-degraded.yaml
- healthStatus:
status: Healthy
message: "ScaledJob is defined correctly and is ready to scaling"
inputPath: testdata/keda-healthy.yaml
- healthStatus:
status: Degraded
message: "Some triggers defined in ScaledJob are not working correctly"
inputPath: testdata/keda-unknown.yaml
- healthStatus:
status: Suspended
message: "ScaledJob is paused"
inputPath: testdata/keda-suspended.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
finalizers:
- finalizer.keda.sh
name: keda
namespace: keda
resourceVersion: '157163'
uid: 9a6b7c4f-c35b-46ca-a801-ee5cb515ce0a
spec:
jobTargetRef:
backoffLimit: 1
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- sleep
- '10'
envFrom:
- secretRef:
name: scaledjob-conditions-test-secret
image: docker.io/library/busybox
imagePullPolicy: IfNotPresent
name: sleeper
resources: {}
restartPolicy: Never
maxReplicaCount: 5
pollingInterval: 5
rollout: {}
scalingStrategy: {}
triggers:
- metadata:
hostFromEnv: RabbitApiHost
mode: QueueLength
queueName: not-existing-queue
value: '1'
type: rabbitmq
status:
authenticationsTypes: ''
conditions:
- message: Triggers defined in ScaledJob are not working correctly
reason: TriggerError
status: 'False'
type: Ready
- message: Scaling is not performed because triggers are not active
reason: ScalerNotActive
status: 'False'
type: Active
- status: Unknown
type: Fallback
- status: 'False'
type: Paused
triggersTypes: rabbitmq

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
finalizers:
- finalizer.keda.sh
name: keda
namespace: keda
resourceVersion: '157477'
uid: 9a6b7c4f-c35b-46ca-a801-ee5cb515ce0a
spec:
jobTargetRef:
backoffLimit: 1
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- sleep
- '10'
envFrom:
- secretRef:
name: scaledjob-conditions-test-secret
image: docker.io/library/busybox
imagePullPolicy: IfNotPresent
name: sleeper
resources: {}
restartPolicy: Never
maxReplicaCount: 5
pollingInterval: 5
rollout: {}
scalingStrategy: {}
triggers:
- metadata:
hostFromEnv: RabbitApiHost
mode: QueueLength
queueName: hello
value: '1'
type: rabbitmq
status:
authenticationsTypes: ''
conditions:
- message: ScaledJob is defined correctly and is ready to scaling
reason: ScaledJobReady
status: 'True'
type: Ready
- message: Scaling is performed because triggers are active
reason: ScalerActive
status: 'True'
type: Active
- status: Unknown
type: Fallback
- status: 'False'
type: Paused
triggersTypes: rabbitmq

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
finalizers:
- finalizer.keda.sh
name: keda
namespace: keda
resourceVersion: '159237'
uid: 9a6b7c4f-c35b-46ca-a801-ee5cb515ce0a
spec:
jobTargetRef:
backoffLimit: 1
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- sleep
- '10'
envFrom:
- secretRef:
name: scaledjob-conditions-test-secret
image: docker.io/library/busybox
imagePullPolicy: IfNotPresent
name: sleeper
resources: {}
restartPolicy: Never
maxReplicaCount: 5
pollingInterval: 5
rollout: {}
scalingStrategy: {}
triggers:
- metadata:
hostFromEnv: RabbitApiHost
mode: QueueLength
queueName: hello
value: '1'
type: rabbitmq
status:
authenticationsTypes: ''
conditions:
- message: Waiting for ScaledJob
reason: Running
status: 'True'
type: Running
triggersTypes: rabbitmq

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
autoscaling.keda.sh/paused: 'true'
finalizers:
- finalizer.keda.sh
name: keda
namespace: keda
resourceVersion: '157163'
uid: 9a6b7c4f-c35b-46ca-a801-ee5cb515ce0a
spec:
jobTargetRef:
backoffLimit: 1
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- sleep
- '10'
envFrom:
- secretRef:
name: scaledjob-conditions-test-secret
image: docker.io/library/busybox
imagePullPolicy: IfNotPresent
name: sleeper
resources: {}
restartPolicy: Never
maxReplicaCount: 5
pollingInterval: 5
rollout: {}
scalingStrategy: {}
triggers:
- metadata:
hostFromEnv: RabbitApiHost
mode: QueueLength
queueName: hello
value: '1'
type: rabbitmq
status:
authenticationsTypes: ''
conditions:
- message: ScaledJob is paused, skipping reconcile loop
reason: ScaledJobReady
status: 'True'
type: Ready
- message: Scaling is not performed because triggers are not active
reason: ScalerNotActive
status: 'False'
type: Active
- status: Unknown
type: Fallback
- message: ScaledJob is paused
reason: ScaledJobPaused
status: 'True'
type: Paused
triggersTypes: rabbitmq
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
finalizers:
- finalizer.keda.sh
name: keda
namespace: keda
resourceVersion: '158276'
uid: 9a6b7c4f-c35b-46ca-a801-ee5cb515ce0a
spec:
jobTargetRef:
backoffLimit: 1
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- sleep
- '10'
envFrom:
- secretRef:
name: scaledjob-conditions-test-secret
image: docker.io/library/busybox
imagePullPolicy: IfNotPresent
name: sleeper
resources: {}
restartPolicy: Never
maxReplicaCount: 5
pollingInterval: 5
rollout: {}
scalingStrategy: {}
triggers:
- metadata:
hostFromEnv: RabbitApiHost
mode: QueueLength
queueName: hello
value: '1'
type: rabbitmq
- metadata:
hostFromEnv: RabbitApiHost
mode: QueueLength
queueName: not-existing-queue
value: '1'
type: rabbitmq
status:
authenticationsTypes: ''
conditions:
- message: Some triggers defined in ScaledJob are not working correctly
reason: PartialTriggerError
status: Unknown
type: Ready
- message: Scaling is performed because triggers are active
reason: ScalerActive
status: 'True'
type: Active
- status: Unknown
type: Fallback
- status: 'False'
type: Paused
triggersTypes: rabbitmq

Loading