argoproj / argo-cd

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

ArgoCD ResourceTree issue: Multiple OwnerReferences causing duplicate nodes #19910

Open DomineCore opened 2 months ago

DomineCore commented 2 months ago

Checklist:

Describe the bug

When I use argocd, I encounter some resources with multiple OWnerreferences. When argocd's resourcetree is generated, two identical nodes will be added to the nodes. The result returned by my resource definition and resourcetree is as follows: 1、my resource:

apiVersion: networking.tke.cloud.tencent.com/v1
kind: VpcIPClaim
metadata:
  name: actsvr-grrjk
  namespace: develop-lobby
  ownerReferences:
    - apiVersion: tkex.tencent.com/v1alpha1
      blockOwnerDeletion: true
      controller: true
      kind: GameDeployment
      name: actsvr
      uid: 513fcac4-48cd-4839-a616-636db421451d
    - apiVersion: v1
      blockOwnerDeletion: true
      controller: false
      kind: Pod
      name: actsvr-grrjk
      uid: 58575c2d-6b7e-454a-a561-b971c11af025

2、resource-tree result.nodes:

            {
                "createdAt": "2024-09-02T01:41:26Z",
                "group": "networking.tke.cloud.tencent.com",
                "kind": "VpcIPClaim",
                "name": "actsvr-grrjk",
                "namespace": "develop-lobby",
                "parentRefs": [
                    {
                        "group": "tkex.tencent.com",
                        "kind": "GameDeployment",
                        "name": "actsvr",
                        "namespace": "develop-lobby",
                        "uid": "513fcac4-48cd-4839-a616-636db421451d"
                    },
                    {
                        "kind": "Pod",
                        "name": "actsvr-grrjk",
                        "namespace": "develop-lobby",
                        "uid": "58575c2d-6b7e-454a-a561-b971c11af025"
                    }
                ],
                "resourceVersion": "31288285932",
                "uid": "35c8b9ba-b6c9-4e78-a0ef-95789e6f10c1",
                "version": "v1"
            },
            {
                "createdAt": "2024-09-02T01:41:26Z",
                "group": "networking.tke.cloud.tencent.com",
                "kind": "VpcIPClaim",
                "name": "actsvr-grrjk",
                "namespace": "develop-lobby",
                "parentRefs": [
                    {
                        "group": "tkex.tencent.com",
                        "kind": "GameDeployment",
                        "name": "actsvr",
                        "namespace": "develop-lobby",
                        "uid": "513fcac4-48cd-4839-a616-636db421451d"
                    },
                    {
                        "kind": "Pod",
                        "name": "actsvr-grrjk",
                        "namespace": "develop-lobby",
                        "uid": "58575c2d-6b7e-454a-a561-b971c11af025"
                    }
                ],
                "resourceVersion": "31288285932",
                "uid": "35c8b9ba-b6c9-4e78-a0ef-95789e6f10c1",
                "version": "v1"
            },

To Reproduce

Expected behavior Normally there should be only one node for the same resource

Screenshots

image

Version

v2.9.0

Logs

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

After reading the code of the getResourceTree function in appcontroller.go, I came up with a solution and I hope to submit a pull request to fix it.

DomineCore commented 2 months ago

/assignee

DomineCore commented 2 months ago

I fix it: https://github.com/argoproj/argo-cd/pull/19911

andrii-korotkov-verkada commented 2 weeks ago

What does it mean for the resource to have multiple owner references? What if they conflict doing some updates or managing lifecycle?

I don't know an easy way to fix the duplication, since the app view is intended to show a tree, and this would introduce a diamond pattern.

andrii-korotkov-verkada commented 2 weeks ago

Is 2.9 your cli or server version? If the later, please upgrade and check if the issue is still present, since 2.9 has reached EOL.