argoproj / argo-cd

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

out of sync applications ignore manifest-paths annotation #19967

Open bobzoller opened 6 days ago

bobzoller commented 6 days ago

Checklist:

Describe the bug

When an application is a) out of sync and b) uses the manifest-paths annotation, it will attempt a sync for every new repo revision, not only those whose content matches its manifest-paths.

To Reproduce

  1. create an Application that uses manifest-paths:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    argocd.argoproj.io/manifest-generate-paths: .
  name: infra-development-tester-development
spec:
  destination:
    name: development
    namespace: infra-development-tester
  project: default
  source:
    directory:
      recurse: true
    path: development/infra-development-tester
    repoURL: git@github.com:example/deployments.git
  syncPolicy:
    automated:
      allowEmpty: true
      prune: true
    retry: {}
  1. create a commit that adds a manifest at development/infra-development-tester/manifest.yaml that succeeds but does not match, thereby leaving the application Out of Sync (Not sure how to give you a reproducible test case for Out of Sync... in our case a custom operator was swallowing a particular field of the resource definition. Make sure the Application uses the manifest-paths annotation.)

  2. create another commit in a different directory of the deployments repo.

  3. watch the app attempt a sync. (it shouldn't)

  4. create another commit that fixes the out of sync error in the manifest; watch it sync successfully

  5. create another commit in an unrelated directory; watch it ignore that revision and skip the sync!

Expected behavior

That the application only attempts a sync when there's a new revision and it matches its manifest-paths annotation.

Screenshots

none

Version

{
    "Version": "v2.11.7+e4a0246",
    "BuildDate": "2024-07-24T09:33:49Z",
    "GitCommit": "e4a0246c4d920bc1e5ee5f9048a99eca7e1d53cb",
    "GitTreeState": "clean",
    "GoVersion": "go1.21.10",
    "Compiler": "gc",
    "Platform": "linux/amd64",
    "KustomizeVersion": "v5.2.1 2023-10-19T20:13:51Z",
    "HelmVersion": "v3.14.4+g81c902a",
    "KubectlVersion": "v0.26.11",
    "JsonnetVersion": "v0.20.0"
}

Logs

Paste any relevant application logs here.
CefBoud commented 1 day ago

@bobzoller Thank you for the detailed issue report.

My theory is that the sync in step 4 is unrelated to the commit in step 3. Once the application falls out of sync in step 2, it attempts reconciliation at each timeout.reconciliation interval (default: 3 minutes), regardless of any subsequent commits.

This can be confirmed if a sync attempt occurs before creating the commit in step 3.