Skip to content

Conversation

@tssurya
Copy link
Contributor

@tssurya tssurya commented Sep 13, 2022

Currently running a make install to install the CRD's in a cluster fails. We run into:

Error from server (Invalid): error when creating "STDIN": CustomResourceDefinition.apiextensions.k8s.io
"adminnetworkpolicies.policy.networking.k8s.io" is invalid: [spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[0].default: Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[1].default: Forbidden: must be undefined to be structural]

This PR fixes this since defining the default protocol as TCP is breaking the installation.

Signed-off-by: Surya Seetharaman [email protected]

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 13, 2022
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 13, 2022
@tssurya tssurya force-pushed the fix-crd-installation branch from e03b7d0 to 9af3784 Compare September 13, 2022 16:25
Currently running a make install to install the CRD's
in a cluster fails. We run into:

Error from server (Invalid): error when creating "STDIN":
CustomResourceDefinition.apiextensions.k8s.io
"adminnetworkpolicies.policy.networking.k8s.io" is invalid:
[spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[0].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[1].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[0].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[egress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[1].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[0].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portNumber].properties[protocol].allOf[1].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[0].default:
Forbidden: must be undefined to be structural,
spec.validation.openAPIV3Schema.properties[spec].properties[ingress].items.properties[ports].items.properties[portRange].properties[protocol].allOf[1].default:
Forbidden: must be undefined to be structural]

This PR fixes this since defining the default as TCP is breaking the
installation.

Signed-off-by: Surya Seetharaman <[email protected]>
@tssurya tssurya force-pushed the fix-crd-installation branch from 9af3784 to 5f526d6 Compare September 13, 2022 16:30
type Port struct {
// Protocol is the network protocol (TCP, UDP, or SCTP) which traffic must
// match. If not specified, this field defaults to TCP.
// +kubebuilder:default=TCP
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible I might need to use https://github.com/kubernetes/apiextensions-apiserver/blob/aabbdff63fe0a4e940e7cbe3e5188c3b6e4b63bf/pkg/apiserver/schema/validation.go#L49 (x-kubernetes-int-or-string: true) instead ? Would be good to check with an api expert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I think we are good here.

allOf:
- default: TCP
- default: TCP
default: TCP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sou manually added this right? Does it get removed when you run make all? I wonder why this kube builder tag isn't working right :(

Copy link
Contributor Author

@tssurya tssurya Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't manually add it, that's the best part! not exactly sure how the default:TCP is populated, but it wasn't me. I simply did the mentioned changes in the types.go and ran make install and it seems to fill in this value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep theres some legacy API funniness ensuring the default, see https://github.com/kubernetes/api/blob/master/networking/v1/types.go#L148 there's no explicit default in netpol either

This should be alright!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably that port.protocol already has TCP as its magic default somehow.

@astoycos
Copy link
Member

I didn't know about that K8s name limitation thanks so much for catching this!

@astoycos
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 16, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astoycos, tssurya

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 16, 2022
@k8s-ci-robot k8s-ci-robot merged commit d6171ac into kubernetes-sigs:master Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants