Skip to content

Commit

Permalink
Fix ArgoCD hooks annotation location
Browse files Browse the repository at this point in the history
  • Loading branch information
gcaracuel committed May 13, 2024
1 parent 69ba66c commit 9dc87d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/3989.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
helm: Fix ArgoCD hooks related annotation on init Job, they must be added at Job definition and not tempalte level.
```
10 changes: 5 additions & 5 deletions charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ metadata:
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
{{- if .Values.global.argocd.enabled }}
annotations:
"argocd.argoproj.io/hook": "Sync"
"argocd.argoproj.io/hook-delete-policy": "HookSucceeded"
{{- end }}
spec:
template:
metadata:
Expand All @@ -50,12 +55,7 @@ spec:
{{- if .Values.global.acls.annotations }}
{{- tpl .Values.global.acls.annotations . | nindent 8 }}
{{- end }}
{{- if .Values.global.argocd.enabled }}
"argocd.argoproj.io/hook": "Sync"
"argocd.argoproj.io/hook-delete-policy": "HookSucceeded"
{{- end }}
{{- if .Values.global.secretsBackend.vault.enabled }}

{{- /* Run the Vault agent as both an init container and sidecar.
The Vault agent sidecar is needed when server-acl-init bootstraps ACLs
and writes the bootstrap token back to Vault.
Expand Down
8 changes: 4 additions & 4 deletions charts/consul/test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2383,14 +2383,14 @@ load _helpers
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr)
yq -r '.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr)
[ "${actual}" = "Sync" ]
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr)
yq -r '.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr)
[ "${actual}" = "HookSucceeded" ]
}

Expand All @@ -2401,14 +2401,14 @@ load _helpers
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=false' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr)
yq -r '.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr)
[ "${actual}" = null ]
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=false' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr)
yq -r '.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr)
[ "${actual}" = null ]
}

Expand Down

0 comments on commit 9dc87d1

Please sign in to comment.