argoproj / argo-cd

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

ApplicationSet, clusterDecisionResource Generator, `kind` in the reference ConfigMap (configMapRef) is `resource` #9785

Open kuanf opened 2 years ago

kuanf commented 2 years ago

Checklist:

Describe the bug

Started to play ArgoCD recently and installed version 2.4.0+91aefab. I'm trying to use PlacementDecision from open-cluster-management as the cluster decision resource, and found that the kind in ConfigMap is actually resource.

my journey of discovering the problem:

At first, I created a ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: rhacm-placement-cm
  namespace: argocd
data:
  apiVersion: cluster.open-cluster-management.io/v1beta1
  kind: PlacementDecision
  statusListKey: decisions
  matchKey: clusterName

but applicationset controller complain that it does not have permission to list the resource even after I added it into it's Role. I have to change the resource in Role to '*' to work it around.

Then, the applicationset controller complains that it can not find any resource.

I noticed in the controller log, it says,

time="2022-06-23T19:39:37Z" level=info msg="Kind.Group/Version Reference" kind.apiVersion=PlacementDecision.cluster.open-cluster-management.io/v1beta1
time="2022-06-23T19:39:37Z" level=info msg="selection type" listOptions.FieldSelector="metadata.name=turbodecision"
time="2022-06-23T19:39:37Z" level=warning msg="resources were not found" GVK="cluster.open-cluster-management.io/v1beta1, Resource=PlacementDecision"
time="2022-06-23T19:39:37Z" level=error msg="error generating params" error="the server could not find the requested resource" generator="&{0xc0000e8000 0xc0006e6170 0xc0006efe00 argocd 0xc000620300}"

I also found previous log says

time="2022-06-23T18:45:48Z" level=info msg="Kind.Group/Version Reference" kind.apiVersion=PlacementDecision.cluster.open-cluster-management.io/v1beta1
time="2022-06-23T18:45:48Z" level=info msg="selection type" listOptions.FieldSelector="metadata.name=turbodecision"
time="2022-06-23T18:45:48Z" level=warning msg="resources were not found" GVK="cluster.open-cluster-management.io/v1beta1, Resource=PlacementDecision"
time="2022-06-23T18:45:48Z" level=error msg="error generating params" error="PlacementDecision.cluster.open-cluster-management.io \"turbodecision\" is forbidden: User \"system:serviceaccount:argocd:argocd-applicationset-controller\" cannot list resource \"PlacementDecision\" in API group \"cluster.open-cluster-management.io\" in the namespace \"argocd\"" generator="&{0xc0000e8000 0xc0006e6170 0xc0006efe00 argocd 0xc000620300}"

and think it might be a problem with Resource=PlacementDecision

So I changed the configmap to

apiVersion: v1
kind: ConfigMap
metadata:
  name: rhacm-placement-cm
  namespace: argocd
data:
  apiVersion: cluster.open-cluster-management.io/v1beta1
  kind: placementdecisions
  statusListKey: decisions
  matchKey: clusterName

and it worked.

@qiujian16 FYI.

To Reproduce

You can find PlacementDecision CRD here. https://raw.githubusercontent.com/open-cluster-management-io/placement/main/deploy/hub/0000_03_clusters.open-cluster-management.io_placementdecisions.crd.yaml but I think it doesn't really matter. the problem should exist to All CRDs.

Expected behavior

I think the k8s concept is misused here. kind should be PlacementDecision, while resource is placementdecisions. So, either accept the right kind or change the key to resource fixes the confusion.

Screenshots

Version

% argocd version  
argocd: v2.4.2+c6d0c8b.dirty
  BuildDate: 2022-06-22T02:07:16Z
  GitCommit: c6d0c8baaa291cd68465acd7ad6bef58b2b6f942
  GitTreeState: dirty
  GoVersion: go1.18.3
  Compiler: gc
  Platform: darwin/amd64
argocd-server: v2.4.0+91aefab
  BuildDate: 2022-06-10T17:23:37Z
  GitCommit: 91aefabc5b213a258ddcfe04b8e69bb4a2dd2566
  GitTreeState: clean
  GoVersion: go1.18.3
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: v4.4.1 2021-11-11T23:36:27Z
  Helm Version: v3.8.1+g5cb9af4
  Kubectl Version: v0.23.1
  Jsonnet Version: v0.18.0

Logs

time="2022-06-23T19:39:37Z" level=error msg="error generating application from params" error="the server could not find the requested resource" generator="{<nil> <nil> <nil> <nil> 0xc0006eec00 <nil> <nil> <nil>}"
time="2022-06-23T19:39:37Z" level=info msg="Kind.Group/Version Reference" kind.apiVersion=PlacementDecision.cluster.open-cluster-management.io/v1beta1
time="2022-06-23T19:39:37Z" level=info msg="selection type" listOptions.FieldSelector="metadata.name=turbodecision"
time="2022-06-23T19:39:37Z" level=warning msg="resources were not found" GVK="cluster.open-cluster-management.io/v1beta1, Resource=PlacementDecision"
time="2022-06-23T19:39:37Z" level=error msg="error generating params" error="the server could not find the requested resource" generator="&{0xc0000e8000 0xc0006e6170 0xc0006efe00 argocd 0xc000620300}"
time="2022-06-23T18:45:48Z" level=info msg="Kind.Group/Version Reference" kind.apiVersion=PlacementDecision.cluster.open-cluster-management.io/v1beta1
time="2022-06-23T18:45:48Z" level=info msg="selection type" listOptions.FieldSelector="metadata.name=turbodecision"
time="2022-06-23T18:45:48Z" level=warning msg="resources were not found" GVK="cluster.open-cluster-management.io/v1beta1, Resource=PlacementDecision"
time="2022-06-23T18:45:48Z" level=error msg="error generating params" error="PlacementDecision.cluster.open-cluster-management.io \"turbodecision\" is forbidden: User \"system:serviceaccount:argocd:argocd-applicationset-controller\" cannot list resource \"PlacementDecision\" in API group \"cluster.open-cluster-management.io\" in the namespace \"argocd\"" generator="&{0xc0000e8000 0xc0006e6170 0xc0006efe00 argocd 0xc000620300}"
sharafcmr commented 2 years ago

We also see the same issue

richardjennings commented 2 years ago

I have run into this also, unfortunately taking quite some while to work out the issue !

sali2801 commented 1 year ago

same here, I stumbled into the same issue, thank you @kuanf for pointing out the alternative solutions