diff --git a/cmd/kube-controller-manager/app/controllermanager.go b/cmd/kube-controller-manager/app/controllermanager.go index 7fed1789165..0c7659cbb41 100644 --- a/cmd/kube-controller-manager/app/controllermanager.go +++ b/cmd/kube-controller-manager/app/controllermanager.go @@ -342,6 +342,7 @@ func NewControllerInitializers() map[string]InitFunc { func GetAvailableResources(clientBuilder controller.ControllerClientBuilder) (map[schema.GroupVersionResource]bool, error) { var discoveryClient discovery.DiscoveryInterface + var healthzContent string // If apiserver is not running we should wait for some time and fail only then. This is particularly // important when we start apiserver and controller manager at the same time. err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) { @@ -352,17 +353,19 @@ func GetAvailableResources(clientBuilder controller.ControllerClientBuilder) (ma } healthStatus := 0 - client.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus) + resp := client.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus) if healthStatus != http.StatusOK { glog.Errorf("Server isn't healthy yet. Waiting a little while.") return false, nil } + content, _ := resp.Raw() + healthzContent = string(content) discoveryClient = client.Discovery() return true, nil }) if err != nil { - return nil, fmt.Errorf("failed to get api versions from server: %v", err) + return nil, fmt.Errorf("failed to get api versions from server: %v: %v", healthzContent, err) } resourceMap, err := discoveryClient.ServerResources()