mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
provide the failing health as part of the controller error
This commit is contained in:
parent
dbc81febc1
commit
47d426c441
@ -342,6 +342,7 @@ func NewControllerInitializers() map[string]InitFunc {
|
|||||||
func GetAvailableResources(clientBuilder controller.ControllerClientBuilder) (map[schema.GroupVersionResource]bool, error) {
|
func GetAvailableResources(clientBuilder controller.ControllerClientBuilder) (map[schema.GroupVersionResource]bool, error) {
|
||||||
var discoveryClient discovery.DiscoveryInterface
|
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
|
// 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.
|
// important when we start apiserver and controller manager at the same time.
|
||||||
err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
|
err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
|
||||||
@ -352,17 +353,19 @@ func GetAvailableResources(clientBuilder controller.ControllerClientBuilder) (ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
healthStatus := 0
|
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 {
|
if healthStatus != http.StatusOK {
|
||||||
glog.Errorf("Server isn't healthy yet. Waiting a little while.")
|
glog.Errorf("Server isn't healthy yet. Waiting a little while.")
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
content, _ := resp.Raw()
|
||||||
|
healthzContent = string(content)
|
||||||
|
|
||||||
discoveryClient = client.Discovery()
|
discoveryClient = client.Discovery()
|
||||||
return true, nil
|
return true, nil
|
||||||
})
|
})
|
||||||
if err != 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()
|
resourceMap, err := discoveryClient.ServerResources()
|
||||||
|
Loading…
Reference in New Issue
Block a user