Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When subresource is given, non-conventional CRD resource pluralization not working in kubectl #67235

Closed
the-redback opened this issue Aug 10, 2018 · 8 comments
Assignees
Labels
area/custom-resources kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@the-redback
Copy link

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

I was using Non-conventional CRD resource pluralization, say fooes (fooes.samplecontroller.k8s.io). I used status as subresource. Now, When I create an object of Foo kind with kubectl, it gives error that there is no requested resource post foos.samplecontroller.k8s.io. But, When I use client-go:8.0.0 it works just fine.
I can also confirm that, this fooes pluralization works fine with kubectl when no subresource is given.

What you expected to happen:

kubectl is able to handle non-conventional pluralization of CRD objects, So it also should be able to handle this when subresource is enabled.

How to reproduce it (as minimally and precisely as possible):

# To start fresh, I deleted minikube cluster and recreated it.
$ minikube delete
$ minikube start --kubernetes-version=v1.11.1

$ rm -rf ~/.kube/http-cache/
$ rm -rf ~/.kube/cache/
$ cat crd.yaml 
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: fooes.samplecontroller.k8s.io
spec:
  group: samplecontroller.k8s.io
  version: v1alpha1
  names:
    kind: Foo
    plural: fooes
  scope: Namespaced
  subresources:
    status: {}

$ cat crd-object.yaml
apiVersion: samplecontroller.k8s.io/v1alpha1
kind: Foo
metadata:
  name: example-foo
spec:
  deploymentName: example-foo
  replicas: 1

$ kubectl create -f crd.yaml
customresourcedefinition.apiextensions.k8s.io/fooes.samplecontroller.k8s.io created

$ kubectl create -f crd-object.yaml 
Error from server (NotFound): error when creating "crd-object.yaml": the server could not find the requested resource (post foos.samplecontroller.k8s.io)

$ kubectl create -f crd-object.yaml --v=8
I0810 11:00:59.971503   11288 loader.go:359] Config loaded from file /home/maruf/.kube/config
I0810 11:00:59.972953   11288 round_trippers.go:383] GET https://192.168.99.100:8443/openapi/v2?timeout=32s
I0810 11:00:59.972968   11288 round_trippers.go:390] Request Headers:
I0810 11:00:59.972974   11288 round_trippers.go:393]     Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf
I0810 11:00:59.972980   11288 round_trippers.go:393]     User-Agent: kubectl/v1.11.1 (linux/amd64) kubernetes/b1b2997
I0810 11:00:59.984936   11288 round_trippers.go:408] Response Status: 200 OK in 11 milliseconds
I0810 11:00:59.984952   11288 round_trippers.go:411] Response Headers:
I0810 11:00:59.984958   11288 round_trippers.go:414]     Content-Type: application/octet-stream
I0810 11:00:59.984966   11288 round_trippers.go:414]     Date: Fri, 10 Aug 2018 05:00:59 GMT
I0810 11:00:59.984972   11288 round_trippers.go:414]     Etag: "BDDB7BC1F7375D7754E38AEE0B825455152B8FD1F703EF18CB258E5F1687B9D147E0C6AEBB565CE13883F2B1CA56665A09B07CE7E06E6CE1B59539838880F3A7"
I0810 11:00:59.984981   11288 round_trippers.go:414]     Vary: Accept-Encoding
I0810 11:00:59.984987   11288 round_trippers.go:414]     Vary: Accept
I0810 11:00:59.984993   11288 round_trippers.go:414]     Last-Modified: Fri, 10 Aug 2018 04:23:15 GMT
I0810 11:00:59.984999   11288 round_trippers.go:414]     X-From-Cache: 1
I0810 11:00:59.985005   11288 round_trippers.go:414]     X-Varied-Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf
I0810 11:00:59.985011   11288 round_trippers.go:414]     Accept-Ranges: bytes
I0810 11:01:00.104991   11288 request.go:895] Response Body:
00000000  0a 03 32 2e 30 12 15 0a  0a 4b 75 62 65 72 6e 65  |..2.0....Kuberne|
00000010  74 65 73 12 07 76 31 2e  31 31 2e 31 42 e3 ef 67  |tes..v1.11.1B..g|
00000020  12 ca 02 0a 05 2f 61 70  69 2f 12 c0 02 12 bd 02  |...../api/......|
00000030  0a 04 63 6f 72 65 1a 1a  67 65 74 20 61 76 61 69  |..core..get avai|
00000040  6c 61 62 6c 65 20 41 50  49 20 76 65 72 73 69 6f  |lable API versio|
00000050  6e 73 2a 12 67 65 74 43  6f 72 65 41 50 49 56 65  |ns*.getCoreAPIVe|
00000060  72 73 69 6f 6e 73 32 10  61 70 70 6c 69 63 61 74  |rsions2.applicat|
00000070  69 6f 6e 2f 6a 73 6f 6e  32 10 61 70 70 6c 69 63  |ion/json2.applic|
00000080  61 74 69 6f 6e 2f 79 61  6d 6c 32 23 61 70 70 6c  |ation/yaml2#appl|
00000090  69 63 61 74 69 6f 6e 2f  76 6e 64 2e 6b 75 62 65  |ication/vnd.kube|
000000a0  72 6e 65 74 65 73 2e 70  72 6f 74 6f 62 75 66 3a  |rnetes.protobuf:|
000000b0  10 61 70 70 6c 69 63 61  74 69 6f 6e 2f 6a 73 6f  |.application/jso|
000000c0  6e 3a 10 61 70 70 6c 69  63 61 74 69 6f 6e 2f 79  |n:.application/ [truncated 11471668 chars]
I0810 11:01:00.179882   11288 loader.go:359] Config loaded from file /home/maruf/.kube/config
I0810 11:01:00.180387   11288 loader.go:359] Config loaded from file /home/maruf/.kube/config
I0810 11:01:00.180990   11288 loader.go:359] Config loaded from file /home/maruf/.kube/config
I0810 11:01:00.181209   11288 decoder.go:224] decoding stream as YAML
I0810 11:01:00.183478   11288 loader.go:359] Config loaded from file /home/maruf/.kube/config
I0810 11:01:00.183756   11288 request.go:897] Request Body: {"apiVersion":"samplecontroller.k8s.io/v1alpha1","kind":"Foo","metadata":{"name":"example-foo","namespace":"default"},"spec":{"deploymentName":"example-foo","replicas":1}}
I0810 11:01:00.183790   11288 round_trippers.go:383] POST https://192.168.99.100:8443/apis/samplecontroller.k8s.io/v1alpha1/namespaces/default/foos
I0810 11:01:00.183799   11288 round_trippers.go:390] Request Headers:
I0810 11:01:00.183806   11288 round_trippers.go:393]     Accept: application/json
I0810 11:01:00.183812   11288 round_trippers.go:393]     Content-Type: application/json
I0810 11:01:00.183819   11288 round_trippers.go:393]     User-Agent: kubectl/v1.11.1 (linux/amd64) kubernetes/b1b2997
I0810 11:01:00.185088   11288 round_trippers.go:408] Response Status: 404 Not Found in 1 milliseconds
I0810 11:01:00.185105   11288 round_trippers.go:411] Response Headers:
I0810 11:01:00.185112   11288 round_trippers.go:414]     Content-Type: text/plain; charset=utf-8
I0810 11:01:00.185118   11288 round_trippers.go:414]     X-Content-Type-Options: nosniff
I0810 11:01:00.185124   11288 round_trippers.go:414]     Content-Length: 19
I0810 11:01:00.185129   11288 round_trippers.go:414]     Date: Fri, 10 Aug 2018 05:01:00 GMT
I0810 11:01:00.185147   11288 request.go:897] Response Body: 404 page not found
I0810 11:01:00.185280   11288 helpers.go:201] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "error when creating \"crd-object.yaml\": the server could not find the requested resource (post foos.samplecontroller.k8s.io)",
  "reason": "NotFound",
  "details": {
    "group": "samplecontroller.k8s.io",
    "kind": "foos",
    "causes": [
      {
        "reason": "UnexpectedServerResponse",
        "message": "404 page not found"
      }
    ]
  },
  "code": 404
}]
F0810 11:01:00.185302   11288 helpers.go:119] Error from server (NotFound): error when creating "crd-object.yaml": the server could not find the requested resource (post foos.samplecontroller.k8s.io)

$ kubectl get --raw /apis/samplecontroller.k8s.io/v1alpha1 | jq
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "samplecontroller.k8s.io/v1alpha1",
  "resources": [
    {
      "name": "fooes",
      "singularName": "foo",
      "namespaced": true,
      "kind": "Foo",
      "verbs": [
        "delete",
        "deletecollection",
        "get",
        "list",
        "patch",
        "create",
        "update",
        "watch"
      ]
    },
    {
      "name": "fooes/status",
      "singularName": "",
      "namespaced": true,
      "kind": "Foo",
      "verbs": [
        "get",
        "patch",
        "update"
      ]
    }
  ]
}

Anything else we need to know?:

  • This pluralization has no problem in client-go.
  • Conventional pluralizations have no problem, like postgreses, mongodbs, with subresource enabled.

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-17T18:53:20Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-17T18:43:26Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: LocalPC. CPU: intel core i3, memory 16GB.
  • OS (e.g. from /etc/os-release):
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
  • Kernel (e.g. uname -a): Linux appscode 4.15.0-30-generic #32-Ubuntu SMP Thu Jul 26 17:42:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: minikube start --kubernetes-version=v1.11.1
  • Others:
$ minikube version
minikube version: v0.28.2
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. kind/bug Categorizes issue or PR as related to a bug. labels Aug 10, 2018
@the-redback
Copy link
Author

cc: @tamalsaha @nikhita @sttts

@nikhita
Copy link
Member

nikhita commented Aug 10, 2018

/sig api-machinery
/area custom-resources

Tried this on master, worked fine.

minikube start --kubernetes-version=v1.11.1

Tried on v1.11.1, can reproduce the error.

Looks like some commit fixed it. 🎉 I'm not sure which commit fixed this, but I'll find it and report here. We should probably cherry-pick to 1.11 as well.

Thanks for reporting this, @the-redback!

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. area/custom-resources and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 10, 2018
@nikhita
Copy link
Member

nikhita commented Aug 10, 2018

Not really related to this, but creating a custom resource in this case says:

foo.samplecontroller.k8s.io/example-foo created

instead, it should be fooes.samplecontroller.k8s.io.

@nikhita
Copy link
Member

nikhita commented Aug 10, 2018

#66249 was the fix. Will cherry-pick it into 1.11.

➜  kubernetes git:(master) git tag --contains 24fc97a82810671c76a7bc9fd57a9cd7719dcd37                        
v1.12.0-alpha.1

@nikhita
Copy link
Member

nikhita commented Aug 10, 2018

/assign

@nikhita
Copy link
Member

nikhita commented Aug 10, 2018

created #67240

k8s-github-robot pushed a commit that referenced this issue Aug 15, 2018
…9-upstream-release-1.11

Automatic merge from submit-queue.

Automated cherry pick of #66249: fill in normal restmapping info with the legacy guess

Fixes 1.11 part of #67235

Cherry pick of #66249 on release-1.11.

#66249: fill in normal restmapping info with the legacy guess

```release-note
Fix creation of custom resources when the CRD contains non-conventional pluralization and subresources
```
k8s-publishing-bot added a commit to kubernetes/client-go that referenced this issue Aug 16, 2018
…9-upstream-release-1.11

Automatic merge from submit-queue.

Automated cherry pick of #66249: fill in normal restmapping info with the legacy guess

Fixes 1.11 part of kubernetes/kubernetes#67235

Cherry pick of #66249 on release-1.11.

#66249: fill in normal restmapping info with the legacy guess

```release-note
Fix creation of custom resources when the CRD contains non-conventional pluralization and subresources
```

Kubernetes-commit: 10ecc6db83fd47a93eb0940e2e4434f2b0a5c3ec
@fedebongio
Copy link
Contributor

/cc @mbohlool

k8s-github-robot pushed a commit that referenced this issue Aug 17, 2018
…9-upstream-release-1.10

Automatic merge from submit-queue.

Automated cherry pick of #66249: fill in normal restmapping info with the legacy guess

Fixes 1.10 part of #67235

Cherry pick of #66249 on release-1.10.

#66249: fill in normal restmapping info with the legacy guess

```release-note
Fix creation of custom resources when the CRD contains non-conventional pluralization and subresources
```
k8s-publishing-bot added a commit to kubernetes/client-go that referenced this issue Aug 17, 2018
…9-upstream-release-1.10

Automatic merge from submit-queue.

Automated cherry pick of #66249: fill in normal restmapping info with the legacy guess

Fixes 1.10 part of kubernetes/kubernetes#67235

Cherry pick of #66249 on release-1.10.

#66249: fill in normal restmapping info with the legacy guess

```release-note
Fix creation of custom resources when the CRD contains non-conventional pluralization and subresources
```

Kubernetes-commit: b16193f435cefa70de14823738a2c5af3d99b7ca
@nikhita
Copy link
Member

nikhita commented Aug 18, 2018

#67240 (1.11) and #67393 (1.10) cherry picks have been merged. The 1.11 fix will be present in v1.11.3 and the 1.10 fix will be present in v1.10.7.

Closing.
/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/custom-resources kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

4 participants