argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

Deadlock on deleting application

Open ralf-cestusio opened this issue 5 years ago • 10 comments

During experiments i found the following "deadlock" when deleting an application.

I have an application which provisions an appproject a namespace and a new application (which is in the new project and deloys services in the new namespace)

image

Doing a cascading delete on test-app yields the following result:

the local-joe application stays behind with the error message: InvalidSpecError Application referencing project local-joe which does not exist

Application test-app stays behind with the error: DeletionError Operation cannot be fulfilled on namespaces "local-joe": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.

What inspecting the cluster shows is that all the resources from app local joe are gone. The namespace is deleted

A way to fix this behavior is to manually issue:

kubectl delete apps local-joe
application.argoproj.io "local-joe" deleted

which removes the local-joe app and allows test-app to delete.

Also attached the application controller log. delete.log

ralf-cestusio avatar Mar 27 '19 16:03 ralf-cestusio

for some reason, kubectl delete apps <app_name> -n <namespace> did not work for me. The response application.argoproj.io "<app_name>" deleted looks like it worked, but if I kubectl get apps -n <namespace>, the app still remains.

mvpmvh avatar Apr 18 '19 23:04 mvpmvh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 17 '19 23:06 stale[bot]

for some reason, kubectl delete apps <app_name> -n <namespace> did not work for me. The response application.argoproj.io "<app_name>" deleted looks like it worked, but if I kubectl get apps -n <namespace>, the app still remains.

I had a finalizer in the app, going in and editing that to - finalizer: [] allowed it to delete.

TomHellier avatar Jul 17 '19 12:07 TomHellier

Hi, I have the same problem with v1.3.0, until I delete the finalizer the Application object could not be deleted.

Any suggestion or information on this?

Regards

lechuk47 avatar Nov 14 '19 13:11 lechuk47

We could do with clear repro steps for this one.

alexec avatar Nov 14 '19 18:11 alexec

I just had this with the latest argo. I'll see if I can reliably reproduce this.

I created the application by kubectl apply -f the manifest into the cluster. This had a finalizer specified in the metadata. If I removed the app with kubectl delete it would move the state to deleting, but not delete anything, not the app, nor any of the resources. I then edited the manifest and removed the finalizer. This caused argo to remove the app, but did not remove any of the resources. If I removed through the UI, the resources would be removed, but the app itself would not be removed. Again: once I removed the finalizer from the manifest using kubectl edit, the app would be removed as well.

This was on a clean ArgoCD install, no other apps in the k8s cluster. The only modifications I had done was load a custom tool using an init container and an update to the configmap to enable it.

wdullaer avatar Apr 08 '20 12:04 wdullaer

@alexmt by the way: using the latest argocd, I have reproduced the same issue This time, when I manually remove the finalizer, application is not removed and I see that finalizer appears again and again inside of application definition

yebolenko avatar Jun 19 '22 20:06 yebolenko

for some reason, kubectl delete apps <app_name> -n <namespace> did not work for me. The response application.argoproj.io "<app_name>" deleted looks like it worked, but if I kubectl get apps -n <namespace>, the app still remains.

I'm running into this precise issue. How exactly are people resolving it? I've tried 'argocd app delete (app)', 'kubectl delete apps (app)', 'kubectl delete apps (app) --wait=False', but the apps continue sticking. I do not have a finalizer defined in the kubeconfig.

aMiss-aWry avatar Jul 18 '22 14:07 aMiss-aWry

same issue here.

srinath-panda avatar Aug 24 '22 07:08 srinath-panda

Remove finalizer in the all apps in the current namespace and delete:

for app in $(kubectl get applications  --output=jsonpath={.items..metadata.name}); do \
  echo $app && \
  kubectl patch app $app  --type json -p='[{"op": "remove", "path": "/metadata/finalizers"}]'; \
  kubectl delete $app; \
done

Remove kubernetes finalizer with kubectl cli

kksudo avatar Sep 14 '22 18:09 kksudo

Just curious, why we always set the finalizer? (if you must remove it to delete the app)

ebuildy avatar Feb 21 '23 19:02 ebuildy

I recently hit this, and I did find the reference in the docs: https://argo-cd.readthedocs.io/en/stable/user-guide/app_deletion/#deletion-using-kubectl

But I find this all a little silly like the comment above me hinted at.

anthonyalayo avatar Apr 12 '23 05:04 anthonyalayo

Remove finalizer in the all apps in the current namespace and delete:

for app in $(kubectl get applications  --output=jsonpath={.items..metadata.name}); do \
echo $app &&\
kubectl patch app $app  --type json -p='[{"op": "remove", "path": "/metadata/finalizers"}]'; \
kubectl delete $app; \
done

thanks, this help me to remove project

for proj in $(kubectl get appprojects -n argocd -o jsonpath={.items..metadata.name}); do \
    echo $proj &&\
    kubectl patch appproject $proj -n argocd --type json -p='[{"op": "remove", "path": "/metadata/finalizers"}]'; \
    kubectl delete appproject $proj -n argocd; \
done

adiii717 avatar Jul 26 '23 12:07 adiii717