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

Post-Delete Hook support mutate Application object

Open llavaud opened this issue 5 months ago • 3 comments

Describe the bug

The recent Post-Delete hook support PR, mutate the Application object when refreshing by adding two finalizers if a resource have a "helm.sh/hook": post-delete annotation. In an apps of apps context it causes unnecesssary reconciliations due to object updated:

{"api-version":"argoproj.io/v1alpha1","application":"myRootApp","cluster-name":"myCluster","fields.level":0,"kind":"Application","level":"debug","msg":"Requesting app refresh caused by object update","name":"myApp","namespace":"argo-cd","server":"myServer","time":"2024-03-07T08:14:40Z"}

To Reproduce

Create an Application that deploy another Application, in the nested Application deploy a resource that have a "helm.sh/hook": post-delete annotation. Wait for the 3m default refresh interval and search for the Requesting app refresh caused by object update debug log line.

Expected behavior

Do not mutate the Application object or at least maybe automaticaly ignore thoses finalizers like it is currently done for the metadata fields generation and resourceVersion

Version

argocd: v2.10.2+fcf5d8c
  BuildDate: 2024-03-01T21:24:51Z
  GitCommit: fcf5d8c2381b68ab1621b90be63913b12cca2eb7
  GitTreeState: clean
  GoVersion: go1.21.3
  Compiler: gc
  Platform: linux/amd64

llavaud avatar Mar 07 '24 08:03 llavaud

A possible workaround:

resource.customizations.ignoreDifferences.argoproj.io_Application: |
  jqPathExpressions:
    - .metadata.finalizers[]? | select(. == "post-delete-finalizer.argocd.argoproj.io" or . == "post-delete-finalizer.argocd.argoproj.io/cleanup")
    - if (.metadata.finalizers | length) == 0 then .metadata.finalizers else empty end

llavaud avatar Mar 07 '24 08:03 llavaud

@alexmt Hello, can I have your opinion on this please ? do you consider it as a bug or normal behavior ?

llavaud avatar Mar 07 '24 20:03 llavaud

we are experiencing the same issue. The workaround above works, but it looks like this should be handled on argocd side

msvechla avatar May 17 '24 13:05 msvechla