argoproj / argo-cd

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

Cluster Scoped resources with annotation tracking always show diff #17854

Open kjvellajr opened 2 months ago

kjvellajr commented 2 months ago

Checklist:

Describe the bug

Cluster Scoped resources (provisioned outside of the ArgoCD app) always show as having diffs if they are tracked to a Namespace Scoped resource within an ArgoCD app.

This seems to be closely related to https://github.com/argoproj/argo-cd/issues/8683#issuecomment-1111605207

To Reproduce

  1. Set application.resourceTrackingMethod to annotation
  2. Create a new application, e.g. kustomize-guestbook from https://github.com/argoproj/argocd-example-apps, with a target namespace of guestbook
  3. Sync the application. Make sure that Argo CD has put on tracking annotations on the live resources instead of the label, e.g.
    annotations:
    argocd.argoproj.io/tracking-id: 'guestbook:/Service:guestbook/guestbook-ui'
  4. Create a Cluster Scoped resource, for example a ClusterRole:
    kubectl create clusterrole guestbook-pod-reader --verb=get,list,watch --resource=pods
  5. Annotate the Cluster Scoped resource so that it is tracked by the Deployment
    kubectl annotate clusterrole guestbook-pod-reader argocd.argoproj.io/tracking-id='guestbook:apps/Deployment:guestbook/guestbook-ui'
  6. Observe the application Diff is disabled in the UI. image
  7. Observe the Cluster Scoped resource has a diff. image

Expected behavior

The Cluster Scope resource with annotation tracking should behave like any Namespace scoped resource that has ownership metadata defined. The Diff and Desired Manifest tabs should not be displayed.

Screenshots

:white_check_mark: Namespace scoped resource with ownership metadata defined: image

:x: Cluster Scoped resource using annotation tracking: image

Version

argocd: v2.8.16+a5ae7bd
  BuildDate: 2024-04-15T09:10:52Z
  GitCommit: a5ae7bd16143814dc8560da0e476905ed1d46628
  GitTreeState: clean
  GoVersion: go1.20.14
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.10.6+d504d2b
  BuildDate: 2024-04-05T00:27:47Z
  GitCommit: d504d2b1d92f0cf831a124a5fd1a96ee29fa7679
  GitTreeState: clean
  GoVersion: go1.21.3
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: v5.2.1 2023-10-19T20:13:51Z
  Helm Version: v3.14.3+gf03cc04
  Kubectl Version: v0.26.11
  Jsonnet Version: v0.20.0

Logs

Paste any relevant application logs here.
kjvellajr commented 2 months ago

Also related to #5082