Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

apiextensions: add nullable support to OpenAPI v3 validations #74804

Merged
merged 4 commits into from Mar 4, 2019

Conversation

@sttts
Copy link
Contributor

sttts commented Mar 1, 2019

OpenAPI v3 supports nullable, but not "type": "null" (in contrast to JSON Schema). We don't support either today. This PR completes our support to match OpenAPI v3.

Why we want this: Empty RawExtensions render to null, same for zero-valued timestamps (like in ObjectMeta). I.e. any kind of embedding of Kubernetes types into CRDs leads to potential null values.

Note: we always rejected "type": "null" although go-openapi supports that.

Add `nullable` support to CustomResourceDefinition OpenAPI validation schemata.

Part of the CRD openapi publishing efforts alongside #71192 (https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/00xx-publish-crd-openapi.md), here to be able to express our basic types like ObjectMeta and RawExtension.

TODO follow-ups:

  • add CRD tests for type: object, properties: ...., type:[object,null], properties: ...., properties: ... (compare #74804 (comment)) when #71192 merges.
@nikhita

This comment has been minimized.

Copy link
Member

nikhita commented Mar 1, 2019

/cc @nikhita @liggitt @mbohlool @roycaihw

/label api-review

@s-urbaniak
Copy link
Contributor

s-urbaniak left a comment

/lgtm

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Mar 1, 2019

@s-urbaniak: changing LGTM is restricted to assignees, and only kubernetes/kubernetes repo collaborators may be assigned issues.

In response to this:

/lgtm

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.

@sttts sttts force-pushed the sttts:sttts-crd-validation-nullable branch from 8835a5a to 315364f Mar 1, 2019

@sttts

This comment has been minimized.

Copy link
Contributor Author

sttts commented Mar 1, 2019

@liggitt liggitt added this to Changes requested in API Reviews Mar 1, 2019

@sttts sttts force-pushed the sttts:sttts-crd-validation-nullable branch from 8fa26e6 to 0b16c88 Mar 1, 2019

@sttts

This comment has been minimized.

Copy link
Contributor Author

sttts commented Mar 1, 2019

openapi v2 doesn't support nullable, does ConvertJSONSchemaPropsToOpenAPIv2Schema need to drop this field? does dropping it for openapi v2 make the v2 schema weaker or more restrictive?

Yes, we will have to add it to ConvertJSONSchemaPropsToOpenAPIv2Schema. Did that merge already? Will update, if yes. #74778 merged.

Nullable implies that we drop the other type as well to make the schema weaker. In v3 we will have it published 1:1.

@sttts sttts force-pushed the sttts:sttts-crd-validation-nullable branch from 0b16c88 to 7a66d99 Mar 1, 2019

@sttts

This comment has been minimized.

Copy link
Contributor Author

sttts commented Mar 1, 2019

@liggitt updated ConvertJSONSchemaPropsToOpenAPIv2Schema.

@sttts sttts force-pushed the sttts:sttts-crd-validation-nullable branch from 7a66d99 to c2b8708 Mar 1, 2019

@sttts sttts force-pushed the sttts:sttts-crd-validation-nullable branch from c2b8708 to 5209f3a Mar 1, 2019

@sttts

This comment has been minimized.

Copy link
Contributor Author

sttts commented Mar 1, 2019

/retest

@sttts

This comment has been minimized.

Copy link
Contributor Author

sttts commented Mar 4, 2019

Green.

@liggitt anything left to do here?

@liggitt

This comment has been minimized.

Copy link
Member

liggitt commented Mar 4, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm label Mar 4, 2019

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Mar 4, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, sttts

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

The pull request process is described here

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

@liggitt liggitt removed the api-review label Mar 4, 2019

@liggitt liggitt removed this from Changes requested in API Reviews Mar 4, 2019

@fejta-bot

This comment has been minimized.

Copy link

fejta-bot commented Mar 4, 2019

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@liggitt

This comment has been minimized.

Copy link
Member

liggitt commented Mar 4, 2019

/retest

@k8s-ci-robot k8s-ci-robot merged commit d0c3b70 into kubernetes:master Mar 4, 2019

17 checks passed

cla/linuxfoundation sttts authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-godeps Job succeeded.
Details
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.