While trying to delete an ArgoCD application through a user interface (UI) you may receive an error as follows:
Unable to delete application: error patching application with finalizers: Application.argoproj.io “<appName>” is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{“resources-finalizer.argocd.argoproj.io”} .
To force the deletion of the ArgoCD application that is stuck, you can either use an argocd or kubectl commands as showing in the post below.
Cool Tip: Forcefully delete K8s resources (Pods, Deployments, Services, etc.) stuck in a “Terminating” or “Unknown” state using kubectl! Read more →
Delete ArgoCD Application with Finalizers
If an ArgoCD application deletion through UI is stuck with “Unable to delete application: error patching application with finalizers” error, run one of the commands below depending on your situation.
To delete the ArgoCD application only, without deleting resources (non-cascade deletion):
$ argocd app delete <appName> --cascade=false
- or -
$ kubectl patch app <appName> -p '{"metadata":{"finalizers":null}}' --type merge
$ kubect delete app <appName>
To delete both the ArgoCD application and its resources (cascade deletion):
$ argocd app delete <appName> - or - $ argocd app delete <appName> --cascade - or - $ kubectl patch app <appName> \\ -p '{"metadata": {"finalizers": ["resources-finalizer.argocd.argoproj.io"]}}' \\ --type merge $ kubect delete app <appName>
To ensure that the ArgoCD application has been deleted, list all the ArgoCD applications by executing one the commands below:
$ argocd app list - or - $ kubectl get apps - sample output - NAME SYNC STATUS HEALTH STATUS<appName> Unknown Healthy
Cool Tip: Force delete a “Terminating” Namespace using kubectl! Read more →