Merge pull request #50092 from sttts/sttts-fix-apiextensions-segfault

Automatic merge from submit-queue

apiextensions: fix panic with KUBE_API_VERSIONS set

https://github.com/kubernetes/kubernetes/pull/48837 introduced a panic in apiextension-apiserver triggered by the `hack/test-update-storage-objects.sh` script in CI.
This commit is contained in:
Kubernetes Submit Queue
2017-08-03 12:54:58 -07:00
committed by GitHub

View File

@@ -178,6 +178,11 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
s.GenericAPIServer.Handler.NonGoRestfulMux.Handle("/apis", crdHandler)
s.GenericAPIServer.Handler.NonGoRestfulMux.HandlePrefix("/apis/", crdHandler)
// this only happens when KUBE_API_VERSIONS is set. We must return without adding controllers or poststarthooks which would affect healthz
if crdClient == nil {
return s, nil
}
crdController := NewDiscoveryController(s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), versionDiscoveryHandler, groupDiscoveryHandler, c.GenericConfig.RequestContextMapper)
namingController := status.NewNamingConditionController(s.Informers.Apiextensions().InternalVersion().CustomResourceDefinitions(), crdClient)
finalizingController := finalizer.NewCRDFinalizer(
@@ -186,11 +191,6 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
crdHandler,
)
// this only happens when KUBE_API_VERSIONS is set. We must return without adding poststarthooks which would affect healthz
if crdClient == nil {
return s, nil
}
s.GenericAPIServer.AddPostStartHook("start-apiextensions-informers", func(context genericapiserver.PostStartHookContext) error {
s.Informers.Start(context.StopCh)
return nil