amsten
amsten

Reputation: 207

Argocd application resource stuck at deletion

I've started experimenting with Argocd as part of my cluster setup and set it up to watch a test repo containing some yaml files for a small application I wanted to use for the experiment. While getting to know the system a bit, I broke the repo connection and instead of fixing it I decided that I had what I wanted, and decided to do a clean install with the intention of configuring it towards my actual project.

I pressed the button in the web UI for deleting the application, which got stuck. After which I read that adding spec.syncPolicy.allowEmpty: true and removing the metadata.finalizers declaration from the application yaml file. This did not allow me to remove the application resource.

I then ran an uninstall command with the official manifests/install.yaml as an argument, which cleaned up most resources installed, but left the application resource and the namespace. Command: kubectl delete -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Have tried to use the kubectl delete application NAME --force flag and the --cascade=orphans flag on the application resource as well as on the argocd namespace itself. Now I have both of them stuck at terminating without getting any further.

Now I'm proper stuck as I can't reinstall the argocd in any way I know due to the resources and namespace being marked for deletion, and I'm at my wits end as to what else I can try in order to get rid of the dangling application resource.

Any and all suggestions as to what to look into is much appreciated.

Upvotes: 19

Views: 44672

Answers (5)

Nano
Nano

Reputation: 1

It means a resource is not getting deleted by the current action. You would need to refresh the app and delete the resource that should be deleted. Make sure to do a background delete.

Upvotes: 0

khawarizmi
khawarizmi

Reputation: 742

In my case, application installed in a separate namespace got stuck while deletion from argocd UI. To make sure that application resources are deleted entirely, I deleted the namespace and then patched argocd with this command;

kubectl patch application/airflow--type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' -n argocd

Upvotes: 5

Raghu Reddy
Raghu Reddy

Reputation: 682

It appears that you're encountering difficulties removing a dangling application resource in Argocd. To address this issue, you can follow these steps:

  1. Ensure Finalizer Unset: Verify that the finalizer is successfully unset for the application resource. You can achieve this by running the following command:

Replace APP_NAME/CRD_NAME with the name of your application or the resource you have problem with.

kubectl patch app APP_NAME -p '{"metadata": {"finalizers": null}}' --type merge
kubectl patch crd CRD_NAME -p '{"metadata": {"finalizers": null}}' --type merge

Delete the Application: Once the finalizer has been unset, you can proceed to delete the application resource using the following command: shell

kubectl delete app APP_NAME
kubectl delete crd CRD_NAME

Upvotes: 21

Alex Gray
Alex Gray

Reputation: 71

I've found that using the following commands help greatly...

kubectl api-resources --verbs=list --namespaced -o name | \
   xargs -n 1 kubectl get --show-kind \
   --ignore-not-found -n <namespace>
kubectl api-resources -n <namespace> | grep argo | grep ...

...help greatly to identify the resources that are "stuck".

Then you have to either use some awk to generate delete or delete --all to "prune" the resources. If some get stuck, then you have to resort to editing them to remove the finalisers so that they can then be deleted.

It can get ugly, but awk and printf combinations can help

Upvotes: 7

ice coffee
ice coffee

Reputation: 113

If your problem is that the namespace cannot be deleted, the following two solutions may help you:

  1. Check what resources are stuck in the deletion process, delete these resources, and then delete ns
  2. Edit the namespace of argocd, check if there is a finalizer field in the spec, delete that field and the content of the field

Hopefully it helped you.

Upvotes: 5

Related Questions