argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.82k stars 5.44k forks source link

ignoreDifference not works with app in app pattern #19680

Open keyolk opened 2 months ago

keyolk commented 2 months ago

Checklist:

Describe the bug

Trying to ignore the TargetRevision field if the Application has a label ignoreTargetRevision: "true". But from the Argocd UI, it always catches the diff.

To Reproduce

From the parent application

...
spec:
  ignoreDifferences:
  - group: argoproj.io/v1alpha1
    jqPathExpressions:
    - . | select(.metadata.labels.ignoreTargetRevision == "true") | .spec.source.targetRevision
    kind: Application
  source:
    syncOptions:
    - FailOnSharedResource=false
    - CreateNamespace=true
    - PrunePropagationPolicy=foreground
    - RespectIgnoreDifferences=true
...

And the child

...
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  labels:
    ignoreTargetRevision: "true"
...

Make it sure that if the child app has proper states.

$ cat child.yaml | yaml2json | jq ' . | select(.metadata.labels.ignoreTargetRevision == "true").spec.source.targetRevision'
"CPLAT-3112"

Expected behavior

The diff from targetRevision should be ignored from the parent application.

Screenshots

image

Version

argocd: v2.11.1+9f40df0
  BuildDate: 2024-05-21T22:43:41Z
  GitCommit: 9f40df0c29eca7e45a73f802f033dfd1ed0068e3
  GitTreeState: clean
  GoVersion: go1.22.3
  Compiler: gc
  Platform: darwin/amd64
argocd-server: v2.11.5+c4b283c
  BuildDate: 2024-07-15T17:39:54Z
  GitCommit: c4b283ce0c092aeda00c78ae7b3b2d3b28e7feec
  GitTreeState: clean
  GoVersion: go1.21.10
  Compiler: gc
  Platform: linux/arm64
  Kustomize Version: v5.2.1 2023-10-19T20:13:51Z
  Helm Version: v3.14.4+g81c902a
  Kubectl Version: v0.26.11
  Jsonnet Version: v0.20.0

Logs

No suspected logs I can see

blakepettersson commented 2 months ago

Are you expecting that if the app-of-apps has ignoreDifferences set, that it should be reflected in all child applications?

gavin-jeong commented 2 months ago

@blakepettersson No, what I'm trying is ignore the tagetRevision only if the application has specific label