client: return correct error for 50x response
etcd always returns 500/503 response when it may have no leader. So we should log the other 50x response in a normal way. This helps to log correctly when discovery meets 504 error. Before this PR, it logs like this: ``` 18:31:58 etcd2 | 2015/08/4 18:31:58 discovery: error #0: client: etcd member https://discovery.etcd.io has no leader 18:31:58 etcd2 | 2015/08/4 18:31:58 discovery: waiting for other nodes: error connecting to https://discovery.etcd.io, retrying in 4s ``` After this PR: ``` 22:20:25 etcd2 | 2015/08/4 22:20:25 discovery: error #0: client: etcd member https://discovery.etcd.io returns server error [Gateway Timeout] 22:20:25 etcd2 | 2015/08/4 22:20:25 discovery: waiting for other nodes: error connecting to https://discovery.etcd.io, retrying in 4s ``` Conflicts: client/client.gorelease-2.1
parent
3a346eac25
commit
331ecdf8c8
|
@ -237,8 +237,13 @@ func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (*http.Respo
|
|||
continue
|
||||
}
|
||||
if resp.StatusCode/100 == 5 {
|
||||
// TODO: make sure this is a no leader response
|
||||
cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s has no leader", ep.String()))
|
||||
switch resp.StatusCode {
|
||||
case http.StatusInternalServerError, http.StatusServiceUnavailable:
|
||||
// TODO: make sure this is a no leader response
|
||||
cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s has no leader", ep.String()))
|
||||
default:
|
||||
cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s returns server error [%s]", ep.String(), http.StatusText(resp.StatusCode)))
|
||||
}
|
||||
continue
|
||||
}
|
||||
return resp, body, nil
|
||||
|
|
Loading…
Reference in New Issue