argoproj / argo-cd

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

CLI 'argocd admin cluster stats' doesn't work with round-robin #16901

Open zeusal opened 8 months ago

zeusal commented 8 months ago

Checklist:

Describe the bug

I do not see the statistics correctly when the cluster uses the round robin algorithm.

The application controller works correctly with round robin (at least I can see round robin in logs.) but argocd cli admin cluster stats not.

To Reproduce

Values:

crds:
  install: true
  keep: true

global:
  logging:
    level: debug
  params:
    controller.sharding.algorithm: "round-robin"

controller:
  replicas: 3

Expected behavior

I hope to see the values of shards correctly.

Screenshots

image image image image Application controller log: image

Version

argocd: v2.9.3+6eba5be
  BuildDate: 2023-12-01T23:24:09Z
  GitCommit: 6eba5be864b7e031871ed7698f5233336dfe75c7
  GitTreeState: clean
  GoVersion: go1.21.4
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.9.3+6eba5be
  BuildDate: 2023-12-01T23:05:50Z
  GitCommit: 6eba5be864b7e031871ed7698f5233336dfe75c7
  GitTreeState: clean
  GoVersion: go1.21.3
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: v5.2.1 2023-10-19T20:13:51Z
  Helm Version: v3.13.2+g2a2fb3b
  Kubectl Version: v0.24.2
  Jsonnet Version: v0.20.0

Logs argocd cli

INFO[0000] Starting configmap/secret informers
INFO[0000] Configmap/secret informer synced
INFO[0000] Using filter function:  legacy
INFO[0000] Cluster with uid: d7b3dddc-3fa9-4794-8275-720a0c36e206 will be processed by shard 0
SERVER                          SHARD  CONNECTION  NAMESPACES COUNT  APPS COUNT  RESOURCES COUNT
https://kubernetes.default.svc  0                  0                 0           0

I have been see the code of argocd and I can find the following lines: https://github.com/argoproj/argo-cd/blob/v2.9.3/cmd/argocd/commands/admin/cluster.go#L125C77-L125C101 common.DefaultShardingAlgorithm = LegacyShardingAlgorithm LegacyShardingAlgorithm = "legacy" https://github.com/argoproj/argo-cd/blob/v2.9.3/common/common.go#L118C5-L118C5

does this mean that "admin cluster stats" doesn't work with any other algorithm than "legacy"?

Also, when I have configured the algorithm as legacy, I can see the same information (zero shard, zero apps).

vitorscassiano commented 4 months ago

I got the same error.

zkck commented 2 months ago

Hello, I would like to work on this issue.

zkck commented 13 hours ago

Hello all,

It seems that this is no longer an issue with the current versions of the ArgoCD CLI.

I setup ArgoCD locally with the provided values and added a sample app. I built ArgoCD from source for the CLI commands.

~/argo-cd (master)> alias argocd "go run github.com/argoproj/argo-cd/v2/cmd"
~/argo-cd (master)> argocd version
argocd: v99.99.99+unknown
  BuildDate: 1970-01-01T00:00:00Z
  GitCommit:
  GitTreeState:
  GoVersion: go1.22.7
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.12.3+6b9cd82
  BuildDate: 2024-08-27T11:57:48Z
  GitCommit: 6b9cd828c6e9807398869ad5ac44efd2c28422d6
  GitTreeState: clean
  GoVersion: go1.22.4
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: v5.4.2 2024-05-22T15:19:38Z
  Helm Version: v3.15.2+g1a500d5
  Kubectl Version: v0.29.6
  Jsonnet Version: v0.20.0

I then compared the output of argocd admin cluster stats at the latest commit of master (0573ed79) and at the version specified in this issue, v2.9.3.

~/argo-cd ((0573ed79))> alias argocd "go run github.com/argoproj/argo-cd/v2/cmd"
~/argo-cd ((0573ed79))> argocd admin cluster stats
SERVER                          SHARD  CONNECTION  NAMESPACES COUNT  APPS COUNT  RESOURCES COUNT
https://kubernetes.default.svc  0      Successful  1                 1           367
~/argo-cd ((v2.9.3))> argocd admin cluster stats
SERVER                          SHARD  CONNECTION  NAMESPACES COUNT  APPS COUNT  RESOURCES COUNT
https://kubernetes.default.svc  0                  1                 0           0

It seems the latest commit on master now picks up the resources in the shard correctly.

Please let me know if I missed something, otherwise I think we can close the issue.