openshift / origin

Conformance test suite for OpenShift
http://www.openshift.org
Apache License 2.0
8.48k stars 4.7k forks source link

oc new-app does not support annotations on 'servicecatalog.k8s.io/v1alpha1, Kind=Broker' #15996

Closed ghost closed 7 years ago

ghost commented 7 years ago

When adding a broker object to a template, it can be used an oc process, but not oc new-app.

Version

oc v3.6.0+c4dd4cf kubernetes v1.6.1+5115d708d7 features: Basic-Auth GSSAPI Kerberos SPNEGO

Steps To Reproduce
  1. Example (broker.yaml):
apiVersion: v1
kind: Template
metadata:
  name: broker
objects:
- apiVersion: servicecatalog.k8s.io/v1alpha1
  kind: Broker
  metadata:
    name: ansible-service-broker
  spec:
    url: ${BROKER_URL}
    authInfo:
      basicAuthSecret:
        namespace: ${NAMESPACE}
        name: asb-auth-secret
parameters:
- description: Namespace
  displayname: namespace
  name: NAMESPACE
  required: true
- description: Broker URL
  displayname: Broker URL
  name: BROKER_URL
  required: true
  1. works:

oc process -f broker.yaml -p BROKER_URL=http://asb-1338.example.com -p NAMESPACE=sample | oc create -f -

  1. Not works:

oc new-app --file=broker.yaml -p BROKER_URL=http://asb-1338.example.com -p NAMESPACE=sample

Current Result

failed to add annotation to object of type "servicecatalog.k8s.io/v1alpha1, Kind=Broker", this resource type is probably unsupported by your client version.

Expected Result

Same as 2.

bparees commented 7 years ago

possibly related to https://github.com/openshift/origin/issues/15783

@juanvallejo given the changes you made for that issue, any chance you can take a look here?

juanvallejo commented 7 years ago

@bparees sure, will take a look

juanvallejo commented 7 years ago

I suspect this issue is happening due to brokers not being supported in the client yet. In both cases of oc new-app ... and oc process ... | oc create -f -, the client deals with a *runtime.Unknown object. The only difference is that oc new-app fails when trying to use the metadata.Accessor to add annotations to the *runtime.Unknown object, which does not implement a metav1.Object, and after that would also fail here when attempting to extract type info from a *runtime.Unknown object.

cc @deads2k

bparees commented 7 years ago

I thought our clients were supposed to handle this through api discovery?

juanvallejo commented 7 years ago

After looking through, I found that a list of result objects is generated from a template here, before being decoded using the LegacyCodec, which still gives us a list of *runtime.Unknown objects when it fails to decode servicecatalog.k8s.io/Broker objects.

I have made a patch that uses the universal decoder / unstrucutred decoder instead, and it succeeds in creating a Broker template on the server: https://github.com/openshift/origin/pull/16049