argoproj / argo-cd

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

Multiple Sources with values in same github repo, changes all applications #16443

Open joudaon opened 1 year ago

joudaon commented 1 year ago

Checklist:

Describe the bug

I have the following two applications:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp1-dev
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
  labels:
    name: myapp1
    environment: dev
  annotations:
    argocd.argoproj.io/manifest-generate-paths: .
spec:
  project: default
  sources:
    - repoURL: myacrrepo
      targetRevision: 1.0.0
      chart: helm/my-application
      helm:
        version: v3
        releaseName: "myapp1-dev"
        passCredentials: true
        valueFiles:
          - $values/helm/dev-aks.yaml
          - $helm/values/mybapp/myapp1/dev-aks.yaml
    - repoURL: http://127.0.01/argocdpoc/helmapps.git
      targetRevision: HEAD
      ref: helm
    - repoURL: http://127.0.0.1/argocdpoc/myapp1.git
      targetRevision: HEAD
      ref: values
  destination:
    name: my-dev-cluster
    namespace: mybapp
  info:
    - name: Application url
      value: https://myapp1.dev.example.com
  syncPolicy:
    automated:
      selfHeal: true
    syncOptions:
      - Replace=true
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp2-dev
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
  labels:
    name: myapp2
    environment: dev
  annotations:
    argocd.argoproj.io/manifest-generate-paths: .
spec:
  project: default
  sources:
    - repoURL: myacrrepo
      targetRevision: 1.0.0
      chart: helm/my-application
      helm:
        version: v3
        releaseName: "myapp2-dev"
        passCredentials: true
        valueFiles:
          - $values/helm/dev-aks.yaml
          - $helm/values/mybapp/myapp2/dev-aks.yaml
    - repoURL: http://127.0.01/argocdpoc/helmapps.git
      targetRevision: HEAD
      ref: helm
    - repoURL: http://127.0.0.1/argocdpoc/myapp2.git
      targetRevision: HEAD
      ref: values
  destination:
    name: my-dev-cluster
    namespace: mybapp
  info:
    - name: Application url
      value: https://myapp2.dev.example.com
  syncPolicy:
    automated:
      selfHeal: true
    syncOptions:
      - Replace=true

The multisource "helm" value is shared in two applications.

When I update a value in $helm/values/mybapp/myapp1/dev-aks.yaml to update "myapp1-dev" application, "myapp2-dev" application see that changes have been made in http://127.0.01/argocdpoc/helmapps.git.

Is there any workaound to only trigger "myapp1-dev" application?

I tried this but didn´t work:

sources:
    - repoURL: myacrrepo
      targetRevision: 1.0.0
      chart: helm/my-application
      helm:
        version: v3
        releaseName: "myapp1-dev"
        passCredentials: true
        valueFiles:
          - $values/helm/dev-aks.yaml
          - $helm
    - repoURL: http://127.0.01/argocdpoc/helmapps.git
      path: values/mybapp/myapp1/dev-aks/helm-values.yaml
      targetRevision: HEAD
      ref: helm
    - repoURL: http://127.0.0.1/argocdpoc/myapp1.git
      targetRevision: HEAD
      ref: values

To Reproduce

Update a value in $helm/values/mybapp/myapp1/dev-aks.yaml to update "myapp1-dev" application, "myapp2-dev" application see that changes have been made in http://127.0.01/argocdpoc/helmapps.git.

Expected behavior

Only "myapp1-dev" application should be udpated. "myapp2-dev" should not be updated.

Screenshots

Version

v2.9.2+c5ea5c4

Logs

Paste any relevant application logs here.
jackevans43 commented 10 months ago

Is this because the cache key for the repo containing the values files is invalidated due to the new commit, which causes every Application with it included as a source to refresh?

When a source is providing refs, could it hash the values files being provided, and only refresh the Application if these have changed?

andrii-korotkov-verkada commented 3 weeks ago

ArgoCD versions 2.10 and below have reached EOL. Can you upgrade and let us know if the issue is still present, please?