argoproj / argo-cd

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

Cluster Generator delete Applications using same name unexpectedly #16882

Open MasayaAoyama opened 10 months ago

MasayaAoyama commented 10 months ago

Checklist:

Describe the bug

Generated application is conflict unexpectedly using Cluster Generator of ApplicationSet.

In Argo CD, server is used as unique ID, and name is used as metadata (please see Additional notes in following). But Cluster Generator use name as entry in generation loop, so we cannot use same name with Cluster Generator.

We provide Kubernetes as a Service, so some tenants create same name cluster. After that, ArgoCD sync and delete manifests to the cluster randomly, and then cluster is broken.

To Reproduce

Expected behavior

Cluster generator should not delete existing Application with same name. So I think Cluster generator shoud use server as entry in generation loop. I think this changes are not affected to others.

Version

argocd: v2.7.2+cbee7e6.dirty
  BuildDate: 2023-05-12T13:43:26Z
  GitCommit: cbee7e6011407ed2d1066c482db74e97e0cc6bdb
  GitTreeState: dirty
  GoVersion: go1.19.6
  Compiler: gc
  Platform: linux/amd64

Logs

none

Additional notes

# argocd cluster add context1 --name argocluster1
Cluster 'https://10.0.0.1:443' added

# argocd cluster add context2 --name argocluster1
Cluster 'https://10.0.0.2:443' added
# argocd cluster add context2 --name argocluster1
Cluster 'https://10.0.0.2:443' added

# argocd cluster add context3 --name argocluster2
FATA[0001] rpc error: code = InvalidArgument desc = existing cluster spec is different; use upsert flag to force update; difference in keys "ID,Name"
apiVersion: v1
kind: Config
users:
- name: myuser

clusters:
- cluster:
    server: https://10.0.0.1:443
  name: cluster1
- cluster:
    server: https://10.0.0.2:443 # same cluster
  name: cluster2
- cluster:
    server: https://10.0.0.2:443 # same cluster
  name: cluster3

contexts:
- context:
    cluster: cluster1
    user: myuser
  name: context1
- context:
    cluster: cluster2
    user: myuser
  name: context2
- context:
    cluster: cluster3
    user: myuser
  name: context3

Screenshots

スクリーンショット 2024-01-17 4 24 37

andrii-korotkov-verkada commented 2 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?