Provide a better error when Kubelet pod status is unexpected

Treat HTTP errors with respect, provide a distinct error message
This commit is contained in:
Clayton Coleman
2015-01-29 19:05:41 -05:00
parent 0345211e0c
commit c1a5e14270
2 changed files with 43 additions and 0 deletions

View File

@@ -135,6 +135,9 @@ func (c *HTTPKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.
if response.StatusCode == http.StatusNotFound {
return status, ErrPodInfoNotAvailable
}
if response.StatusCode >= 300 || response.StatusCode < 200 {
return status, fmt.Errorf("kubelet %q server responded with HTTP error code %d for pod %s/%s", host, response.StatusCode, podNamespace, podID)
}
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return status, err