Skip to content
New issue

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

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

Already on GitHub? # to your account

CRD's Enums are prefixed with "Raw: " keyword #1565

Closed
dsimansk opened this issue Jun 6, 2019 · 3 comments · Fixed by #1600
Closed

CRD's Enums are prefixed with "Raw: " keyword #1565

dsimansk opened this issue Jun 6, 2019 · 3 comments · Fixed by #1600
Labels

Comments

@dsimansk
Copy link
Contributor

dsimansk commented Jun 6, 2019

kubernetes-client version: 4.2.2.

When I try to create CRD with the client via deserializing to object and creating afterwards, the actual resource posted to API contains "Raw: " prefix in some of the enums.

That's not the case when CRD is created with oc binary, none of the enums is "enhanced".

Lets take Strimzi Kafka CRD:
https://github.com/strimzi/strimzi-kafka-operator/blob/master/install/cluster-operator/040-Crd-kafka.yaml#L75-L80

The example contains both valid and invalid enums.

oc get crds kafkas.kafka.strimzi.io -o yaml | grep -A 40 "storage"
                storage:
                  properties:
                    class:
                      type: string
                    deleteClaim:
                      type: boolean
                    id:
                      minimum: 0
                      type: integer
                    selector:
                      type: object
                    size:
                      type: string
                    type:
                      enum:
                      - Raw: ephemeral
                      - Raw: persistent-claim
                      - Raw: jbod
                      type: string
                    volumes:
                      items:
                        properties:
                          class:
                            type: string
                          deleteClaim:
                            type: boolean
                          id:
                            minimum: 0
                            type: integer
                          selector:
                            type: object
                          size:
                            type: string
                          type:
                            enum:
                            - ephemeral
                            - persistent-claim
                            type: string
                        required:
                        - type
                        type: object

Trying to create such Kafka will fail with validation exception. Same error is also thrown by oc binary.

apiVersion: kafka.strimzi.io/v1alpha1
kind: Kafka
metadata:
  name: kafka-single
spec:
  kafka:
    version: 2.1.1
    replicas: 1
    listeners:
      plain: {}
      tls: {}
    config:
      offsets.topic.replication.factor: 1
      transaction.state.log.replication.factor: 1
      transaction.state.log.min.isr: 1
      log.message.format.version: "2.1"
    storage:
      type: ephemeral
  zookeeper:
    replicas: 1
    storage:
      type: ephemeral
  entityOperator:
    topicOperator: {}
    userOperator: {}
io.fabric8.kubernetes.client.KubernetesClientException:
Failure executing: POST at: https://api.ocp.dynamic.rhoar:8443/apis/kafka.strimzi.io/v1alpha1/namespaces/kafka/kafkas. Message: Kafka.kafka.strimzi.io "kafka-single" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"kafka.strimzi.io/v1alpha1", "kind":"Kafka", "metadata":map[string]interface {}{"namespace":"kafka", "generation":1, "uid":"3a05af3a-8844-11e9-a629-fa163e4debbc", "selfLink":"", "clusterName":"", "name":"kafka-single", "creationTimestamp":"2019-06-06T10:17:02Z"}, "spec":map[string]interface {}{"kafka":map[string]interface {}{"storage":map[string]interface {}{"type":"ephemeral"}, "listeners":map[string]interface {}{"plain":map[string]interface {}{}, "tls":map[string]interface {}{}}, "config":map[string]interface {}{"offsets.topic.replication.factor":1, "transaction.state.log.replication.factor":1, "transaction.state.log.min.isr":1, "log.message.format.version":"2.1"}, "version":"2.1.1", "replicas":1}, "zookeeper":map[string]interface {}{"replicas":1, "storage":map[string]interface {}{"type":"ephemeral"}}, "entityOperator":map[string]interface {}{"topicOperator":map[string]interface {}{"image":"strimzi/topic-operator:latest", "reconciliationIntervalSeconds":90, "zookeeperSessionTimeoutSeconds":20, "topicMetadataMaxAttempts":6}, "userOperator":map[string]interface {}{"image":"strimzi/user-operator:latest", "reconciliationIntervalSeconds":120, "zookeeperSessionTimeoutSeconds":6}}}}: validation failure list:
spec.kafka.storage.type in body should be one of [map[Raw:ephemeral] map[Raw:persistent-claim] map[Raw:jbod]]
spec.zookeeper.storage.type in body should be one of [map[Raw:ephemeral] map[Raw:persistent-claim]]. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=[], message=Invalid value: map[string]interface {}{"apiVersion":"kafka.strimzi.io/v1alpha1", "kind":"Kafka", "metadata":map[string]interface {}{"generation":1, "uid":"3a05af3a-8844-11e9-a629-fa163e4debbc", "selfLink":"", "clusterName":"", "name":"kafka-single", "creationTimestamp":"2019-06-06T10:17:02Z", "namespace":"kafka"}, "spec":map[string]interface {}{"entityOperator":map[string]interface {}{"userOperator":map[string]interface {}{"zookeeperSessionTimeoutSeconds":6, "image":"strimzi/user-operator:latest", "reconciliationIntervalSeconds":120}, "topicOperator":map[string]interface {}{"topicMetadataMaxAttempts":6, "image":"strimzi/topic-operator:latest", "reconciliationIntervalSeconds":90, "zookeeperSessionTimeoutSeconds":20}}, "kafka":map[string]interface {}{"version":"2.1.1", "replicas":1, "storage":map[string]interface {}{"type":"ephemeral"}, "listeners":map[string]interface {}{"plain":map[string]interface {}{}, "tls":map[string]interface {}{}}, "config":map[string]interface {}{"transaction.state.log.min.isr":1, "log.message.format.version":"2.1", "offsets.topic.replication.factor":1, "transaction.state.log.replication.factor":1}}, "zookeeper":map[string]interface {}{"replicas":1, "storage":map[string]interface {}{"type":"ephemeral"}}}}: validation failure list:
spec.kafka.storage.type in body should be one of [map[Raw:ephemeral] map[Raw:persistent-claim] map[Raw:jbod]]
spec.zookeeper.storage.type in body should be one of [map[Raw:ephemeral] map[Raw:persistent-claim]], reason=FieldValueInvalid, additionalProperties={})], group=kafka.strimzi.io, kind=Kafka, name=kafka-single, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Kafka.kafka.strimzi.io "kafka-single" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"kafka.strimzi.io/v1alpha1", "kind":"Kafka", "metadata":map[string]interface {}{"namespace":"kafka", "generation":1, "uid":"3a05af3a-8844-11e9-a629-fa163e4debbc", "selfLink":"", "clusterName":"", "name":"kafka-single", "creationTimestamp":"2019-06-06T10:17:02Z"}, "spec":map[string]interface {}{"kafka":map[string]interface {}{"storage":map[string]interface {}{"type":"ephemeral"}, "listeners":map[string]interface {}{"plain":map[string]interface {}{}, "tls":map[string]interface {}{}}, "config":map[string]interface {}{"offsets.topic.replication.factor":1, "transaction.state.log.replication.factor":1, "transaction.state.log.min.isr":1, "log.message.format.version":"2.1"}, "version":"2.1.1", "replicas":1}, "zookeeper":map[string]interface {}{"replicas":1, "storage":map[string]interface {}{"type":"ephemeral"}}, "entityOperator":map[string]interface {}{"topicOperator":map[string]interface {}{"image":"strimzi/topic-operator:latest", "reconciliationIntervalSeconds":90, "zookeeperSessionTimeoutSeconds":20, "topicMetadataMaxAttempts":6}, "userOperator":map[string]interface {}{"image":"strimzi/user-operator:latest", "reconciliationIntervalSeconds":120, "zookeeperSessionTimeoutSeconds":6}}}}: validation failure list:
spec.kafka.storage.type in body should be one of [map[Raw:ephemeral] map[Raw:persistent-claim] map[Raw:jbod]]
spec.zookeeper.storage.type in body should be one of [map[Raw:ephemeral] map[Raw:persistent-claim]], metadata=ListMeta(_continue=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).
	at io.vertx.openshift.kafka.KafkaClientIT.deployKafka(KafkaClientIT.java:71)
@rohanKanojia
Copy link
Member

@dsimansk : How are u trying to create CRD? Using old approach usingn Pojos or RAW api?

@rohanKanojia
Copy link
Member

rohanKanojia commented Jun 20, 2019

I can confirm that this is happening.
Screenshot from 2019-06-20 18-48-17

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 20, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 22, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 22, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 22, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jun 24, 2019
@dsimansk
Copy link
Contributor Author

@rohanKanojia hey there. Sorry for no reply, I was out for 2 weeks.

Anyway I'm glad you could reproduce the issue. I've used the old POJOs approach as you probably figured.

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 26, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Aug 5, 2019
rohanKanojia added a commit that referenced this issue Aug 5, 2019
* Fix #1565: CRD's Enums are prefixed with "Raw: " keyword

* Added elaborated message regarding the hack in jsonschemagenerate script

* Fix missing SelfSubjectRulesReview and SelfSubjectAccessReview resources
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants