mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
* Revert "feat: Add health check for HPA (#4915)"
This reverts commit f6a32a9e
Signed-off-by: May Zhang <may_zhang@intuit.com>
* fix: revert health check
Signed-off-by: May Zhang <may_zhang@intuit.com>
* fix: remove extra line
Signed-off-by: May Zhang <may_zhang@intuit.com>
This commit is contained in:
parent
9b53f8f93a
commit
fdb5ada06d
6 changed files with 0 additions and 123 deletions
|
|
@ -1,47 +0,0 @@
|
|||
local json = require("json")
|
||||
health_status = {
|
||||
status = "Progressing",
|
||||
message = "Waiting to Autoscale"
|
||||
}
|
||||
|
||||
function is_degraded( condition )
|
||||
degraded_states = {
|
||||
{"AbleToScale", "FailedGetScale"},
|
||||
{"AbleToScale", "FailedUpdateScale"},
|
||||
{"ScalingActive", "FailedGetResourceMetric"},
|
||||
{"ScalingActive", "InvalidSelector"}
|
||||
}
|
||||
for i, state in ipairs(degraded_states) do
|
||||
if condition.type == state[1] and condition.reason == state[2] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
condition_string = obj.metadata.annotations["autoscaling.alpha.kubernetes.io/conditions"]
|
||||
if condition_string ~= nil then
|
||||
conditions = json.decode(condition_string)
|
||||
end
|
||||
|
||||
if conditions then
|
||||
for i, condition in ipairs(conditions) do
|
||||
if is_degraded(condition) then
|
||||
health_status.status = "Degraded"
|
||||
health_status.message = condition.message
|
||||
return health_status
|
||||
end
|
||||
if condition.type == "AbleToScale" and condition.reason == "SucceededRescale" then
|
||||
health_status.status = "Healthy"
|
||||
health_status.message = condition.message
|
||||
return health_status
|
||||
end
|
||||
if condition.type == "ScalingLimited" and condition.reason == "DesiredWithinRange" then
|
||||
health_status.status = "Healthy"
|
||||
health_status.message = condition.message
|
||||
return health_status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return health_status
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: Waiting to Autoscale
|
||||
inputPath: testdata/progressing_hpa.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: the HPA controller was able to update the target scale to 1
|
||||
inputPath: testdata/healthy_hpa.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: the HPA controller was unable to get the target's current scale
|
||||
inputPath: testdata/degraded_hpa.yaml
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
annotations:
|
||||
autoscaling.alpha.kubernetes.io/conditions: '[{"type":"AbleToScale","status":"True","lastTransitionTime":"2020-11-23T19:38:38Z","reason":"FailedGetScale","message":"the HPA controller was unable to get the target''s current scale"},{"type":"ScalingActive","status":"False","lastTransitionTime":"2020-11-23T19:38:38Z","reason":"FailedGetResourceMetric","message":"the
|
||||
HPA was unable to compute the replica count: unable to get metrics for resource
|
||||
cpu: unable to fetch metrics from resource metrics API: the server is currently
|
||||
unable to handle the request (get pods.metrics.k8s.io)"}]'
|
||||
name: sample
|
||||
namespace: argocd
|
||||
spec:
|
||||
maxReplicas: 1
|
||||
minReplicas: 1
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: sample
|
||||
targetCPUUtilizationPercentage: 2
|
||||
status:
|
||||
currentReplicas: 1
|
||||
desiredReplicas: 0
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
annotations:
|
||||
autoscaling.alpha.kubernetes.io/conditions: '[{"type":"AbleToScale","status":"True","lastTransitionTime":"2020-11-23T19:38:38Z","reason":"SucceededRescale","message":"the HPA controller was able to update the target scale to 1"},{"type":"ScalingActive","status":"False","lastTransitionTime":"2020-11-23T19:38:38Z","reason":"FailedGetResourceMetric","message":"the
|
||||
HPA was unable to compute the replica count: unable to get metrics for resource
|
||||
cpu: unable to fetch metrics from resource metrics API: the server is currently
|
||||
unable to handle the request (get pods.metrics.k8s.io)"}]'
|
||||
name: sample
|
||||
namespace: argocd
|
||||
spec:
|
||||
maxReplicas: 2
|
||||
minReplicas: 1
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: sample
|
||||
targetCPUUtilizationPercentage: 2
|
||||
status:
|
||||
currentReplicas: 1
|
||||
desiredReplicas: 1
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
annotations:
|
||||
autoscaling.alpha.kubernetes.io/conditions: '[{"type":"AbleToScale","status":"True","lastTransitionTime":"2020-11-23T19:38:38Z","reason":"SucceededGetScale","message":"the HPA controller was able to get the target''s current scale"}]'
|
||||
name: sample
|
||||
namespace: argocd
|
||||
spec:
|
||||
maxReplicas: 1
|
||||
minReplicas: 1
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: sample
|
||||
targetCPUUtilizationPercentage: 2
|
||||
status:
|
||||
currentReplicas: 1
|
||||
desiredReplicas: 0
|
||||
|
|
@ -88,9 +88,6 @@ func (vm VM) runLua(obj *unstructured.Unstructured, script string) (*lua.LState,
|
|||
// preload our 'safe' version of the os library. Allows the 'local os = require("os")' to work
|
||||
l.PreloadModule(lua.OsLibName, SafeOsLoader)
|
||||
|
||||
// preload json library to parse json in lua
|
||||
luajson.Preload(l)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
l.SetContext(ctx)
|
||||
|
|
|
|||
Loading…
Reference in a new issue