argoproj / argo-cd

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

tracking annotation in k8s resource cannot be updated after it is moved from one application to another application #17965

Open domechn opened 6 months ago

domechn commented 6 months ago

Checklist:

Describe the bug

Currently we are using annotation+label to track argocd resources.

But When we moved k8s resources from A application to B application, we found that the tracking label can be updated successfully, but the tracking annotation cannot be updated.

Also we checked the argocd diff on argocd ui, it showed there was no difference between before and after.

image

image

image

To Reproduce

  1. use annotation+label as tracking method.
  2. create application A to create any k8s resource.
  3. remove k8s resources in application A in git, but not prune them in k8s.
  4. create application B to manage k8s resources which created in application A.

Expected behavior

argocd.argoproj.io/tracking-id annotation can be updated successfully

Screenshots

Version

Paste the output from `argocd version` here.
argocd: v2.9.2+c5ea5c4.dirty
  BuildDate: 2023-11-20T18:19:21Z
  GitCommit: c5ea5c4df52943a6fff6c0be181fde5358970304
  GitTreeState: dirty
  GoVersion: go1.21.4
  Compiler: gc
  Platform: darwin/arm64
WARN[0001] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.
argocd-server: v2.8.15+e94f6a8
  BuildDate: 2024-04-04T23:36:03Z
  GitCommit: e94f6a8f840714b55006cf8c8e7f3017b3a0d2ea
  GitTreeState: clean
  GoVersion: go1.20.10
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: (devel) unknown
  Helm Version: v3.10.3+g835b733
  Kubectl Version: v0.24.2
  Jsonnet Version: v0.20.0

Logs

Paste any relevant application logs here.
domechn commented 6 months ago

not sure whether it is caused by this function

https://github.com/argoproj/argo-cd/blob/release-2.8/util/argo/resource_tracking.go#L211

image

it seems when argocd does comparision, and it finds tracking method is not label, it will override tracking id annotation in live by using tracking annotation value in target, this behavior makes there is no difference between live tracking annotation value and target tracking annotation value.