mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
feat: implement KEDA scaledJob health-checks (#25106)
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com> Co-authored-by: Dan Garfield <dan@codefresh.io>
This commit is contained in:
parent
7a09f69ad6
commit
e58bdf2f87
7 changed files with 345 additions and 0 deletions
39
resource_customizations/keda.sh/ScaledJob/health.lua
Normal file
39
resource_customizations/keda.sh/ScaledJob/health.lua
Normal file
|
|
@ -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
resource_customizations/keda.sh/ScaledJob/health_test.yaml
Normal file
21
resource_customizations/keda.sh/ScaledJob/health_test.yaml
Normal file
|
|
@ -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
|
||||
57
resource_customizations/keda.sh/ScaledJob/testdata/keda-degraded.yaml
vendored
Normal file
57
resource_customizations/keda.sh/ScaledJob/testdata/keda-degraded.yaml
vendored
Normal file
|
|
@ -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
|
||||
|
||||
57
resource_customizations/keda.sh/ScaledJob/testdata/keda-healthy.yaml
vendored
Normal file
57
resource_customizations/keda.sh/ScaledJob/testdata/keda-healthy.yaml
vendored
Normal file
|
|
@ -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
|
||||
|
||||
49
resource_customizations/keda.sh/ScaledJob/testdata/keda-progressing.yaml
vendored
Normal file
49
resource_customizations/keda.sh/ScaledJob/testdata/keda-progressing.yaml
vendored
Normal file
|
|
@ -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
|
||||
|
||||
59
resource_customizations/keda.sh/ScaledJob/testdata/keda-suspended.yaml
vendored
Normal file
59
resource_customizations/keda.sh/ScaledJob/testdata/keda-suspended.yaml
vendored
Normal file
|
|
@ -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
|
||||
63
resource_customizations/keda.sh/ScaledJob/testdata/keda-unknown.yaml
vendored
Normal file
63
resource_customizations/keda.sh/ScaledJob/testdata/keda-unknown.yaml
vendored
Normal file
|
|
@ -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…
Reference in a new issue