Skip to content

Commit 5d680d6

Browse files
authored
fix: Add additional healthy states for HPA (argoproj#234)
In the case that you have a HPA with a minimum or maximum replica count set, and the metrics would indicate a need to scale beyond those, this is still an expected and healthy state. Signed-off-by: Mike Bryant <[email protected]>
1 parent 9282458 commit 5d680d6

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

pkg/health/health_hpa.go

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ func isHealthy(condition *hpaCondition) bool {
144144
healthy_states := []hpaCondition{
145145
{Type: "AbleToScale", Reason: "SucceededRescale"},
146146
{Type: "ScalingLimited", Reason: "DesiredWithinRange"},
147+
{Type: "ScalingLimited", Reason: "TooFewReplicas"},
148+
{Type: "ScalingLimited", Reason: "TooManyReplicas"},
147149
}
148150
for _, healthy_state := range healthy_states {
149151
if condition.Type == healthy_state.Type && condition.Reason == healthy_state.Reason {

pkg/health/health_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func TestHPA(t *testing.T) {
8282
assertAppHealth(t, "./testdata/hpa-v2beta1-healthy.yaml", HealthStatusHealthy)
8383
assertAppHealth(t, "./testdata/hpa-v1-degraded.yaml", HealthStatusDegraded)
8484
assertAppHealth(t, "./testdata/hpa-v1-healthy.yaml", HealthStatusHealthy)
85+
assertAppHealth(t, "./testdata/hpa-v1-healthy-toofew.yaml", HealthStatusHealthy)
8586
assertAppHealth(t, "./testdata/hpa-v1-progressing.yaml", HealthStatusProgressing)
8687
assertAppHealth(t, "./testdata/hpa-v1-progressing-with-no-annotations.yaml", HealthStatusProgressing)
8788
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: autoscaling/v1
2+
kind: HorizontalPodAutoscaler
3+
metadata:
4+
annotations:
5+
autoscaling.alpha.kubernetes.io/conditions: '[{"type":"AbleToScale","status":"True","lastTransitionTime":"2021-03-08T17:42:11Z","reason":"ReadyForNewScale","message":"recommended
6+
size matches current size"},{"type":"ScalingActive","status":"True","lastTransitionTime":"2021-03-09T23:59:49Z","reason":"ValidMetricFound","message":"the
7+
HPA was able to successfully calculate a replica count from memory resource
8+
utilization (percentage of request)"},{"type":"ScalingLimited","status":"True","lastTransitionTime":"2021-03-10T10:02:12Z","reason":"TooFewReplicas","message":"the
9+
desired replica count is less than the minimum replica count"}]'
10+
autoscaling.alpha.kubernetes.io/current-metrics: '[{"type":"Resource","resource":{"name":"memory","currentAverageUtilization":2,"currentAverageValue":"3452928"}},{"type":"Resource","resource":{"name":"cpu","currentAverageUtilization":1,"currentAverageValue":"1m"}}]'
11+
name: sample
12+
namespace: default
13+
resourceVersion: "41720063"
14+
selfLink: /apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/sample
15+
uid: cbe887e2-93d6-40de-8f03-7eb7e2d7f978
16+
spec:
17+
maxReplicas: 10
18+
minReplicas: 2
19+
scaleTargetRef:
20+
apiVersion: apps/v1
21+
kind: Deployment
22+
name: sample
23+
targetCPUUtilizationPercentage: 80
24+
status:
25+
currentCPUUtilizationPercentage: 1
26+
currentReplicas: 2
27+
desiredReplicas: 2
28+
lastScaleTime: "2021-03-08T17:42:11Z"

0 commit comments

Comments
 (0)