applicationset icon indicating copy to clipboard operation
applicationset copied to clipboard

Git generator: removal of Helm Chart causes error message and no application deletion

Open alexanderdalloz opened this issue 2 years ago • 4 comments

We are using the Git generator, provisioning all Argo CD projects and applicationsets through a standardized Helm Chart.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
spec:
  generators:
  - git:
      directories:
      - path: '*'
      repoURL: ssh://git@reposerver:7999/opsrepos/opsrepo_project-stage.git
      revision: stages/etu
  template:
    metadata:
      finalizers:
      - resources-finalizer.argocd.argoproj.io

The templated project definition looks like this (as well just a part of it quoted):

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  description: project-etu
  destinations:
  - namespace: project-etu
    server: https://kubernetes.default.svc
  namespaceResourceBlacklist:
  - group: ""
    kind: ResourceQuota
  orphanedResources:
    warn: false

The application CR has set the

  finalizers:
  - resources-finalizer.argocd.argoproj.io

metadata as well. And sync options are defined as:

    syncOptions:
    - Validate=false
    - CreateNamespace=false
    - preserveResourcesOnDeletion=false

Now when deleting a directory with a previously Argo CD deployed Helm Chart from within the source git repo leads to the error message within Argo CD 'rpc error: code = Unknown desc = Manifest generation error (cached): airflow-helm: app path does not exist' The application does not get deleted. We expect it would be deleted.

alexanderdalloz avatar Dec 08 '21 11:12 alexanderdalloz

@alexanderdalloz I am not sure if this is what you are suggesting, but note that the applicationset controller doesn't template AppProject CR (which is what you pasted), it only templates Application CR.

Also, you shouldn't need to include the finalizer in the ApplicationSet template, it should be included by default, see: https://argocd-applicationset.readthedocs.io/en/stable/Application-Deletion/#application-pruning-resource-deletion

  template:
    metadata:
      finalizers: 
      - resources-finalizer.argocd.argoproj.io # not necessary

jgwest avatar Dec 08 '21 20:12 jgwest

@jgwest Sorry for having caused confusion by being not precise enough. The ApplicationSet CR within the Helm Chart template only defines the Application CR, not the project. The complete Helm Chart which we use to provision a new developer team or to reconfigure an existing one consists of kind: AppProject and kind: ApplicationSet. I have quoted a part of the AppProject definition just to show main definitions, especially the finalizer in metadata. Thus to give a more complete view on our setup. AppProject is not part of the ApplicationSet CR.

Is the finalizer definition in ApplicationSet just redundant or could it cause some kind of misbehaviour to the applicationset-controller?

Our aim is that when the developer team deletes a folder within their git repository holding a Helm Chart so far referenced by the ApplicationSet git generator, the application shall be removed within Argo CD thus the OpenShift cluster.

alexanderdalloz avatar Dec 09 '21 10:12 alexanderdalloz

re: finalizer deletion, it shouldn't cause misbehaviour of the applicationset-controller (I just double-checked the relevant code), but it can't hurt to remove it.

It's a bit tough to reason about what you are doing without a full, working example of your Helm chart, but in general the ApplicationSet controller will delete Applications (by default) that it generates if the template parameters that generated them are no longer present (in your example, if the Git repo directory no longer exists).

The error you are receiving ('rpc error: code = Unknown desc = Manifest generation error (cached): airflow-helm: app path does not exist') sounds like the Helm tool is returning an error code to Argo CD, when helm is called.

jgwest avatar Dec 09 '21 16:12 jgwest

@alexanderdalloz what did you do in the end to fix your issue?
I also expected directory deletion to delete my Application, but I get the same Helm error instead. Thanks.

mbonaci avatar Jul 25 '23 17:07 mbonaci