Skip to content

Commit 979368a

Browse files
committed
apiextensions: don't run openapi controller if genericapiserver disables
openapi
1 parent eb35525 commit 979368a

File tree

1 file changed

+5
-1
lines changed
  • staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver

1 file changed

+5
-1
lines changed

staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
212212
return nil
213213
})
214214
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-controllers", func(context genericapiserver.PostStartHookContext) error {
215-
if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourcePublishOpenAPI) {
215+
// OpenAPIVersionedService and StaticOpenAPISpec are populated in generic apiserver PrepareRun().
216+
// Together they serve the /openapi/v2 endpoint on a generic apiserver. A generic apiserver may
217+
// choose to not enable OpenAPI by having null openAPIConfig, and thus OpenAPIVersionedService
218+
// and StaticOpenAPISpec are both null. In that case we don't run the CRD OpenAPI controller.
219+
if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourcePublishOpenAPI) && s.GenericAPIServer.OpenAPIVersionedService != nil && s.GenericAPIServer.StaticOpenAPISpec != nil {
216220
go openapiController.Run(s.GenericAPIServer.StaticOpenAPISpec, s.GenericAPIServer.OpenAPIVersionedService, context.StopCh)
217221
}
218222

0 commit comments

Comments
 (0)