origin icon indicating copy to clipboard operation
origin copied to clipboard

Discovery info for processedtemplates & templates both have kind: Template

Open cben opened this issue 6 years ago • 13 comments

This might not be a bug, but creates complications for dynamic clients parsing discovery info:

Both oapi/v1 and apis/template.openshift.io/v1 have 2 different paths with same kind:

      "name": "templates",
      "namespaced": true,
      "kind": "Template",
      "verbs": ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"],
...
      "name": "processedtemplates",
      "namespaced": true,
      "kind": "Template",
      "verbs": ["create"],
  1. Given kind: Template input, how does oc know which of the endpoints to hit?

  2. Could anything be added to discovery to make this unambiguous?

  3. What is the difference between /templates and /processedtemplates anyway? Do clients need both or can I just hardcode preference to /templates?

  4. The docs are non-helpful — don't explain the difference — and weird:

    • https://docs.openshift.com/container-platform/3.11/rest_api/apis-template.openshift.io/v1.Template.html documents "kind": "Template" for both endpoints.
    • https://docs.openshift.com/container-platform/3.11/rest_api/oapi/v1.Template.html documents "kind": "ProcessedTemplate" for /templates. :bug: Is kind ProcessedTemplate a real thing?
    • https://docs.openshift.com/container-platform/3.11/rest_api/oapi/v1.ProcessedTemplate.html documents "kind": "ProcessedTemplate" for /processedtemplates.

    The docs are organized by kind, could it be they're buggy as result of this collision?

Version
oc v3.11.0+8de5c34
kubernetes v1.10.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://192.168.99.103:8443
kubernetes v1.11.0+d4cacc0
Steps To Reproduce
  1. curl $API/apis/template.openshift.io/v1/
  2. curl $API/oapi/v1/
Current Result

Duplicate entries with different name but same kind.

Expected Result

Ideally, exactly one name per kind (ignoring subresources like routes/status). If kind ProcessedTemplate really exists, can that be reported for "name": "processedtemplates"? If impossible, some hint in discovery info helping decide between the two?

Additional Information

FWIW, there was a similar collision up to openshift 3.6 between DeploymentConfig /generatedeploymentconfigs and DeploymentConfig /deploymentconfigs. generatedeploymentconfigs is gone in 3.7+ discovery info.

cben avatar Dec 16 '18 16:12 cben

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Mar 17 '19 15:03 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Apr 16 '19 17:04 openshift-bot

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar May 16 '19 18:05 openshift-bot

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci-robot avatar May 16 '19 18:05 openshift-ci-robot

/reopen

  • [ ] Documents are still confusing and at least one is wrong. Edited OP with a bit more details.

To partially answer myself, /processedtemplates endpoint is a pseudo-collection for server-side oc process. With oc v1.13 I see it performs POST https://192.168.99.103:8443/apis/template.openshift.io/v1/namespaces/myproject/processedtemplates with Request Body: {"kind":"Template","apiVersion":"template.openshift.io/v1",,"metadata":{"name":"route","creationTimestamp":null},... and gets back Response Body: {"kind":"Template","apiVersion":"template.openshift.io/v1","metadata":{"name":"route","selfLink":"/apis/template.openshift.io/v1/namespaces/myproject/processedtemplates/route",.... "Pseudo-collection" because you can only POST, and the result is ephemeral, server doesn't add it to any storage. Attempting to GET returns MethodNotAllowed (consistent with discovery verbs": ["create"]).

  • [ ] oc get processedtemplates behaves confusingly by performing GET .../templates. :bug: It works (e.g. try oc get processedtemplates -n openshift). (This demonstrates that oc is also partially confused by this collision?)
  • [ ] oc explain processedtemplate contradicts this by saying: the server doesn't have a resource type "processedtemplate"
  • [ ] oc explain template fails, saying :bug: error: Couldn't find resource for "template.openshift.io/v1, Kind=Template"

AFAICT kind "ProcessedTemplate" is not a thing. oc process send "Template" it and server responds with "Template".

cben avatar May 19 '19 10:05 cben

@cben: Reopened this issue.

In response to this:

/reopen

  • [ ] Documents are still confusing and at least one is wrong. Edited OP with a bit more details.

To partially answer myself, /processedtemplates endpoint is a pseudo-collection for server-side oc process. With oc v1.13 I see it performs POST https://192.168.99.103:8443/apis/template.openshift.io/v1/namespaces/myproject/processedtemplates with Request Body: {"kind":"Template","apiVersion":"template.openshift.io/v1",,"metadata":{"name":"route","creationTimestamp":null},... and gets back Response Body: {"kind":"Template","apiVersion":"template.openshift.io/v1","metadata":{"name":"route","selfLink":"/apis/template.openshift.io/v1/namespaces/myproject/processedtemplates/route",.... "Pseudo-collection" because you can only POST, and the result is ephemeral, server doesn't add it to any storage. Attempting to GET returns MethodNotAllowed (consistent with discovery verbs": ["create"]).

  • [ ] oc get processedtemplates behaves confusingly by performing GET .../templates. :bug: It works (e.g. try oc get processedtemplates -n openshift). (This demonstrates that oc is also partially confused by this collision?)
  • [ ] oc explain processedtemplate contradicts this by saying: the server doesn't have a resource type "processedtemplate"
  • [ ] oc explain template fails, saying :bug: error: Couldn't find resource for "template.openshift.io/v1, Kind=Template"

AFAICT kind "ProcessedTemplate" is not a thing. oc process send "Template" it and server responds with "Template".

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci-robot avatar May 19 '19 10:05 openshift-ci-robot

Such collisions have caused a bunch of ResourceNotUniqueError errors in python lib (which is also a dynamic client using discovery info): https://github.com/openshift/openshift-restclient-python/issues/284 and ansible k8s aka openshift_raw module that uses that lib: https://github.com/ansible/ansible/issues/55221
https://github.com/ansible/ansible/issues/55388

cben avatar May 19 '19 14:05 cben

/oapi paths are gone since https://github.com/openshift/origin/pull/21782 so that part can be ignored. Most of the issue still stands.

cben avatar May 19 '19 14:05 cben

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar Jun 18 '19 19:06 openshift-bot

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci-robot avatar Jun 18 '19 19:06 openshift-ci-robot

/reopen /remove-lifecycle rotten /lifecycle frozen

cben avatar Jun 19 '19 06:06 cben

@cben: Reopened this issue.

In response to this:

/reopen /remove-lifecycle rotten /lifecycle frozen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci-robot avatar Jun 19 '19 06:06 openshift-ci-robot

Hello! Any update on this? Still hitting this issue.

CermakM avatar Nov 13 '19 08:11 CermakM