diff --git a/resource_customizations/autoscaling/HorizontalPodAutoscaler/health.lua b/resource_customizations/autoscaling/HorizontalPodAutoscaler/health.lua deleted file mode 100644 index cc56ef098d..0000000000 --- a/resource_customizations/autoscaling/HorizontalPodAutoscaler/health.lua +++ /dev/null @@ -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 diff --git a/resource_customizations/autoscaling/HorizontalPodAutoscaler/health_test.yaml b/resource_customizations/autoscaling/HorizontalPodAutoscaler/health_test.yaml deleted file mode 100644 index dfa6bea700..0000000000 --- a/resource_customizations/autoscaling/HorizontalPodAutoscaler/health_test.yaml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/degraded_hpa.yaml b/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/degraded_hpa.yaml deleted file mode 100644 index 39a2549abf..0000000000 --- a/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/degraded_hpa.yaml +++ /dev/null @@ -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 diff --git a/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/healthy_hpa.yaml b/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/healthy_hpa.yaml deleted file mode 100644 index 35cdeb8b83..0000000000 --- a/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/healthy_hpa.yaml +++ /dev/null @@ -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 diff --git a/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/progressing_hpa.yaml b/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/progressing_hpa.yaml deleted file mode 100644 index 77aa4a7b50..0000000000 --- a/resource_customizations/autoscaling/HorizontalPodAutoscaler/testdata/progressing_hpa.yaml +++ /dev/null @@ -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 diff --git a/util/lua/lua.go b/util/lua/lua.go index a3df9b58f9..bb14bfde98 100644 --- a/util/lua/lua.go +++ b/util/lua/lua.go @@ -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)