UPSTREAM: <drop>: disable apiserver loopback loop in generic context
@@ -99,6 +99,16 @@ func (s *GenericAPIServer) RunPostStartHooks() {
s.postStartHooksCalled = true
context := PostStartHookContext{LoopbackClientConfig: s.LoopbackClientConfig}
+
+ // only wait for namespace in a real kube master setup. In unit tests, we don't have the namespace resource
+ // and therefore the wait loop would fail.
+ isKubeMaster := false
+ for _, ws := range s.HandlerContainer.RegisteredWebServices() {
+ if ws.RootPath() == "/api/v1" {
+ isKubeMaster = true
+ }
+ }
+ if isKubeMaster {
// we need to wait until our loopback client has enough rights to actually loopback
// the core APIs cannot be disabled, so we'll use that as a proxy for the information instead
// of attempting a SAR (which can be disabled, though that would be a very bad idea)
@@ -107,6 +117,7 @@ func (s *GenericAPIServer) RunPostStartHooks() {
client := coreclient.NewForConfigOrDie(s.LoopbackClientConfig)
// we can have other errors in our level, like etcd not being up. Treat them all the same
if _, err := client.Namespaces().List(metav1.ListOptions{}); err != nil {
+ fmt.Printf("loopback error: %v\n", err)
return false, nil
}
return true, nil
@@ -114,6 +125,7 @@ func (s *GenericAPIServer) RunPostStartHooks() {
if err != nil {
glog.Fatalf("LoopbackClient was unable to list namespaces: %v", err)
}
+ }
for hookName, hookEntry := range s.postStartHooks {
go runPostStartHook(hookName, hookEntry, context)
