kubernetes-sigs / controller-tools

Tools to use with the controller-runtime libraries
Apache License 2.0
736 stars 420 forks source link

CRD generation broken in v0.16.0: `Forbidden: must be undefined to be structural` #1034

Closed pmalek closed 3 months ago

pmalek commented 3 months ago

Problem statement

For some reason CRD generation broke with v0.16.0.

https://github.com/Kong/gateway-operator/pull/484/files#diff-3166801df88674f5aaf8bae94ae61589866175173bfe3559d4fb31b73ecf767dR4767-R4769

                                        allOf:
                                        - default: TCP
                                        - default: TCP

But also the generated manifests fail to apply (on k8s cluster 1.30.0) (this CRD embeds podTemplateSpec)

https://github.com/Kong/gateway-operator/actions/runs/10384193313/job/28750687237#step:6:55

Error from server (Invalid): CustomResourceDefinition.apiextensions.k8s.io "controlplanes.gateway-operator.konghq.com" is invalid: [spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[ephemeralContainers].items.properties[ports].items.properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[ephemeralContainers].items.properties[ports].items.properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[ephemeralContainers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property, spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property]
sbueringer commented 3 months ago

@pmalek This is the same case as https://github.com/kubernetes-sigs/controller-tools/issues/1027, right? (it's also ContainerPort in your case?)

pmalek commented 3 months ago

@pmalek This is the same case as #1027, right? (it's also ContainerPort in your case?)

It seems like it yes. I also get

spec.validation.openAPIV3Schema.properties[spec].properties[deployment].properties[podTemplateSpec].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property]

but it points to the same property. Close as duplicate of #1027?

sbueringer commented 3 months ago

Yup, let's close here and investigate based on the other one