UPSTREAM: 50259: provide the failing health as part of the controller error
@@ -341,6 +341,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, 5*time.Minute, func() (bool, error) {
@@ -351,17 +352,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()
