Skip to content

Commit d3223a8

Browse files
authored
feat: add Fallback condition to KEDA ScaledObject health assessment (#22844)
Signed-off-by: Rick Brouwer <rickbrouwer@gmail.com>
1 parent fff55f2 commit d3223a8

3 files changed

Lines changed: 67 additions & 1 deletion

File tree

resource_customizations/keda.sh/ScaledObject/health.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ if obj.status ~= nil then
1717
hs.message = condition.message
1818
suspended = true
1919
end
20+
if condition.status == "True" and condition.type == "Fallback" then
21+
hs.message = condition.message
22+
degraded = true
23+
end
2024
end
2125
end
2226
end
@@ -32,4 +36,4 @@ elseif healthy == true and suspended == true then
3236
end
3337
hs.status = "Progressing"
3438
hs.message = "Creating HorizontalPodAutoscaler Object"
35-
return hs
39+
return hs

resource_customizations/keda.sh/ScaledObject/health_test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ tests:
1919
status: Suspended
2020
message: "ScaledObject is paused"
2121
inputPath: testdata/keda-suspended.yaml
22+
- healthStatus:
23+
status: Degraded
24+
message: "At least one trigger is falling back on this scaled object"
25+
inputPath: testdata/keda-fallback.yaml
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: keda.sh/v1alpha1
2+
kind: ScaledObject
3+
metadata:
4+
annotations:
5+
finalizers:
6+
- finalizer.keda.sh
7+
labels:
8+
argocd.argoproj.io/instance: keda-default
9+
name: keda-with-fallback
10+
namespace: keda
11+
resourceVersion: '160591443'
12+
uid: 83ee438a-f383-43f3-9346-b901d9773f5c
13+
spec:
14+
maxReplicaCount: 10
15+
minReplicaCount: 1
16+
fallback:
17+
failureThreshold: 3
18+
replicas: 5
19+
scaleTargetRef:
20+
name: keda-service
21+
triggers:
22+
- type: prometheus
23+
metadata:
24+
serverAddress: http://prometheus-server.monitoring.svc.cluster.local
25+
metricName: http_requests_total
26+
threshold: '100'
27+
query: sum(rate(http_requests_total{app="keda-service"}[2m]))
28+
status:
29+
conditions:
30+
- message: ScaledObject is defined correctly and is ready for scaling
31+
reason: ScaledObjectReady
32+
status: 'True'
33+
type: Ready
34+
- message: Scaling is performed because triggers are active
35+
reason: ScalerActive
36+
status: 'True'
37+
type: Active
38+
- message: At least one trigger is falling back on this scaled object
39+
reason: FallbackExists
40+
status: 'True'
41+
type: Fallback
42+
- status: 'False'
43+
type: Paused
44+
externalMetricNames:
45+
- s0-prometheus
46+
health:
47+
"prometheus":
48+
numberOfFailures: 4
49+
status: Failing
50+
hpaName: keda-with-fallback-hpa
51+
lastActiveTime: '2023-12-19T10:35:22Z'
52+
originalReplicaCount: 1
53+
scaleTargetGVKR:
54+
group: apps
55+
kind: Deployment
56+
resource: deployments
57+
version: v1
58+
scaleTargetKind: apps/v1.Deployment

0 commit comments

Comments
 (0)