Instead of apiserver panic when proxy a request to a dead minion,

print out proper message through http.Response
This commit is contained in:
Dawn Chen 2014-07-28 16:26:30 -07:00
parent 37e5f96074
commit 8e9864e8fc

View File

@ -231,6 +231,15 @@ type minionTransport struct{}
func (t *minionTransport) RoundTrip(req *http.Request) (*http.Response, error) {
resp, err := http.DefaultTransport.RoundTrip(req)
if err != nil && strings.Contains(err.Error(), "connection refused") {
message := fmt.Sprintf("Failed to connect to minion:%s", req.URL.Host)
resp = &http.Response{
StatusCode: http.StatusServiceUnavailable,
Body: ioutil.NopCloser(strings.NewReader(message)),
}
return resp, nil
}
if strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {
// Do nothing, simply pass through
return resp, err