-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PostDelete Hook not work with Application generated from ApplicationSet #17181
Comments
Related to #16595 |
Also hitting this on 2.10.4. Have you found any workarounds @dtrouillet ? |
This is blocking our org from moving forward with some key initiatives - would love to see this get more traction. |
No unfortunately. |
Same for us. We tried a couple of workarounds but nothing seems to accomplish the same thing as a successful PostDelete hook would. In our use case we have ephemeral environments that are generated by an ApplicationSet based on a PR. We need to clean the environment after the PR is closed. |
@alexmt Any leads as to why this is failing? |
Similar story here. We use in our AppSet
when Application is created manually with PostDelete hook it adds (at least in our case)
So combining all 3 finalizers in AppSet template can work as workaround.
At the end application is deleted, but the PostDelete hook is not triggered. If I tweak the AppSet to delete the App, but still keeping the app git folder in usable state, PostDelete hook is triggered (with the extra finalizers in AppSet template). |
@hau21um Do I understand correctly that you have tried adding finalizers to the ApplicationSet template as a workaround? Like the following? template:
metadata:
name: 'test-{{name}}'
finalizers:
- resources-finalizer.argocd.argoproj.io
- post-delete-finalizer.argocd.argoproj.io
- post-delete-finalizer.argocd.argoproj.io/cleanup Do you think your issue w/CMP is a separate issue? |
@joebowbeer yap adding finalizers as you described partially fixed it for me and if not trying to modify the application source repository together with deletion of application is working fine then. (argocd 2.10.7) |
@hau21um I tried the workaround and it doesn't seem to be working for me. Sorry for lack of detail. It may be replacing one problem with another. |
@dtrouillet The fix was released in 2.11.0-rc3 I tested using an appset similar to yours, derived from the dynamic list-generator example in the docs with your hook(s) added as an additional source: apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: elements-yaml
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- matrix:
generators:
- git:
repoURL: https://github.com/joebowbeer/argo-cd.git
revision: joebowbeer-test-1
files:
- path: applicationset/examples/list-generator/list-elementsYaml-example.yaml
- list:
elementsYaml: "{{ .key.components | toJson }}"
template:
metadata:
name: "{{.name}}"
spec:
project: default
syncPolicy:
automated:
selfHeal: true
syncOptions:
- CreateNamespace=true
sources:
- chart: "{{.chart}}"
repoURL: "{{.repoUrl}}"
targetRevision: "{{.version}}"
helm:
releaseName: "{{.releaseName}}"
- path: .
repoURL: https://github.com/joebowbeer/argocd-postdelete-issue
targetRevision: HEAD
destination:
server: https://kubernetes.default.svc
namespace: "{{.namespace}}" Adding/removing array elements in the list-generator example will add/remove applications. I modified your hook(s) Jobs to give them names derived from the helm release, and to use a combined metadata:
name: {{ .Release.Name }}-post-delete
annotations:
argocd.argoproj.io/hook: PostDelete
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded |
Thanks a lot @joebowbeer. |
Checklist:
argocd version
.Describe the bug
When I create an ApplicationSet that create one simple Application (one configmap and one Job as hook with
argocd.argoproj.io/hook: PostDelete
annotation) the postDelete hook are never called. The finalizer on Application are not be created.If I create the same Application manually, the finalizer exist.
To Reproduce
Create an ApplicationSet :
The content of the repo test is here : https://github.com/dtrouillet/argocd-postdelete-issue
Expected behavior
I expect an Application with finalizer and PostDelete hook executed when I delete the Application
Screenshots
Version
argocd: v2.10.0+2175939
BuildDate: 2024-02-06T14:28:43Z
GitCommit: 2175939
GitTreeState: clean
GoVersion: go1.21.3
Compiler: gc
Platform: linux/amd64
Logs
The text was updated successfully, but these errors were encountered: