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

Promote Publish CRD OpenAPI to beta #77825

Merged
merged 3 commits into from May 24, 2019

Conversation

@roycaihw
Copy link
Member

commented May 13, 2019

ref kubernetes/enhancements#692

Does this PR introduce a user-facing change?:

The CustomResourcePublishOpenAPI feature is now beta and enabled by default. CustomResourceDefinitions with [structural schemas](https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/20190425-structural-openapi.md) now publish schemas in the OpenAPI document served at `/openapi/v2`. CustomResourceDefinitions with non-structural schemas have a `NonStructuralSchema` condition added with details about what needs to be corrected in the validation schema.

/sig api-machinery
/cc @sttts

/hold
pending #77554 to be merged

@roycaihw roycaihw force-pushed the roycaihw:crd-openapi-beta branch from 2cca33e to 8e672a7 May 13, 2019

@roycaihw roycaihw force-pushed the roycaihw:crd-openapi-beta branch from 8e672a7 to eb35525 May 16, 2019

@roycaihw

This comment has been minimized.

Copy link
Member Author

commented May 20, 2019

/retest

2 similar comments
@roycaihw

This comment has been minimized.

Copy link
Member Author

commented May 23, 2019

/retest

@liggitt

This comment has been minimized.

Copy link
Member

commented May 23, 2019

/retest

@liggitt

This comment has been minimized.

Copy link
Member

commented May 23, 2019

/kind feature
/priority important-soon

@liggitt

This comment has been minimized.

Copy link
Member

commented May 23, 2019

this looks good to merge from my side. @sttts?

@liggitt

This comment has been minimized.

Copy link
Member

commented May 23, 2019

the integration test failures are related. it looks like some test setups do not populate openapiconfig:

openAPIConfig: c.OpenAPIConfig,

so the staticSchema is left nil:

// PrepareRun does post API installation setup steps.
func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer {
if s.openAPIConfig != nil {
s.OpenAPIVersionedService, s.StaticOpenAPISpec = routes.OpenAPI{
Config: s.openAPIConfig,
}.Install(s.Handler.GoRestfulContainer, s.Handler.NonGoRestfulMux)
}

so a nil static schema is passed to the controller:

s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-controllers", func(context genericapiserver.PostStartHookContext) error {
if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourcePublishOpenAPI) {
go openapiController.Run(s.GenericAPIServer.StaticOpenAPISpec, s.GenericAPIServer.OpenAPIVersionedService, context.StopCh)
}

and the dereference here panics:

// mergeSpecs aggregates all OpenAPI specs, reusing the metadata of the first, static spec as the basis.
func mergeSpecs(staticSpec *spec.Swagger, crdSpecs ...*spec.Swagger) *spec.Swagger {
// create shallow copy of staticSpec, but replace paths and definitions because we modify them.
specToReturn := *staticSpec

we have a few options:

  1. require openapiconfig, and put a nice warning here to make it clearer to server creators it is required:

    func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*GenericAPIServer, error) {
    if c.Serializer == nil {
    return nil, fmt.Errorf("Genericapiserver.New() called with config.Serializer == nil")
    }
    if c.LoopbackClientConfig == nil {
    return nil, fmt.Errorf("Genericapiserver.New() called with config.LoopbackClientConfig == nil")
    }

  2. tolerate a nil static schema by replacing it with an empty one here:

    // Run sets openAPIAggregationManager and starts workers
    func (c *Controller) Run(staticSpec *spec.Swagger, openAPIService *handler.OpenAPIService, stopCh <-chan struct{}) {
    defer utilruntime.HandleCrash()
    defer c.queue.ShutDown()
    defer klog.Infof("Shutting down OpenAPI controller")
    klog.Infof("Starting OpenAPI controller")
    c.staticSpec = staticSpec

@k8s-ci-robot k8s-ci-robot removed the size/XS label May 23, 2019

@k8s-ci-robot k8s-ci-robot added the size/S label May 23, 2019

@roycaihw roycaihw force-pushed the roycaihw:crd-openapi-beta branch from 60432f3 to 979368a May 23, 2019

@roycaihw

This comment has been minimized.

Copy link
Member Author

commented May 23, 2019

/retest

@liggitt

This comment has been minimized.

Copy link
Member

commented May 24, 2019

/approve
/lgtm

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented May 24, 2019

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@k8s-ci-robot k8s-ci-robot merged commit a07b027 into kubernetes:master May 24, 2019

20 checks passed

cla/linuxfoundation roycaihw 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-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
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
@kacole2 kacole2 referenced this pull request May 28, 2019
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.