From 6f15881d7b83c43b42c076049f5c713e134d3cab Mon Sep 17 00:00:00 2001 From: Tiit Hansen Date: Tue, 30 May 2023 21:08:45 +0300 Subject: [PATCH] Agent deployed with ArgoCD remains in endless sync loop (#4008) By reordering metrics argocd will no longer be stuck in endless loop. Related issue in ArgoCD project https://github.com/argoproj/argo-cd/issues/1079 --- operations/helm/charts/grafana-agent/CHANGELOG.md | 1 + .../helm/charts/grafana-agent/templates/hpa.yaml | 11 +++++++---- .../grafana-agent/templates/hpa.yaml | 3 +++ .../grafana-agent/templates/hpa.yaml | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/operations/helm/charts/grafana-agent/CHANGELOG.md b/operations/helm/charts/grafana-agent/CHANGELOG.md index f02aeb177f1a..408de0b92e21 100644 --- a/operations/helm/charts/grafana-agent/CHANGELOG.md +++ b/operations/helm/charts/grafana-agent/CHANGELOG.md @@ -22,6 +22,7 @@ Unreleased ### Bugfixes - Only set the deployment replicas when autoscaling is disabled. (@tiithansen) +- Reorder HPA `spec.metrics` to avoid endless sync loop in ArgoCD. (@tiithansen) 0.14.0 (2023-05-11) ------------------- diff --git a/operations/helm/charts/grafana-agent/templates/hpa.yaml b/operations/helm/charts/grafana-agent/templates/hpa.yaml index 3bfe3f09f415..9a9ff6b24493 100644 --- a/operations/helm/charts/grafana-agent/templates/hpa.yaml +++ b/operations/helm/charts/grafana-agent/templates/hpa.yaml @@ -14,18 +14,21 @@ spec: minReplicas: {{ .minReplicas }} maxReplicas: {{ .maxReplicas }} metrics: - {{- with .targetCPUUtilizationPercentage }} + # Changing the order of the metrics will cause ArgoCD to go into a sync loop + # memory needs to be first. + # More info in: https://github.com/argoproj/argo-cd/issues/1079 + {{- with .targetMemoryUtilizationPercentage }} - type: Resource resource: - name: cpu + name: memory target: type: Utilization averageUtilization: {{ . }} {{- end }} - {{- with .targetMemoryUtilizationPercentage }} + {{- with .targetCPUUtilizationPercentage }} - type: Resource resource: - name: memory + name: cpu target: type: Utilization averageUtilization: {{ . }} diff --git a/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml b/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml index b484dc3c1f7e..2317e963fb11 100644 --- a/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml +++ b/operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml @@ -18,6 +18,9 @@ spec: minReplicas: 1 maxReplicas: 5 metrics: + # Changing the order of the metrics will cause ArgoCD to go into a sync loop + # memory needs to be first. + # More info in: https://github.com/argoproj/argo-cd/issues/1079 - type: Resource resource: name: memory diff --git a/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml b/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml index f38b911424f1..e2277ceb7fda 100644 --- a/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml +++ b/operations/helm/tests/create-statefulset-autoscaling/grafana-agent/templates/hpa.yaml @@ -18,6 +18,9 @@ spec: minReplicas: 1 maxReplicas: 5 metrics: + # Changing the order of the metrics will cause ArgoCD to go into a sync loop + # memory needs to be first. + # More info in: https://github.com/argoproj/argo-cd/issues/1079 - type: Resource resource: name: memory