mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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 ```
This commit is contained in:
parent
ff5c3469c1
commit
cfeaf3d172
@ -245,8 +245,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", eps[k].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", eps[k].String()))
|
||||
default:
|
||||
cerr.Errors = append(cerr.Errors, fmt.Errorf("client: etcd member %s returns server error [%s]", eps[k].String(), http.StatusText(resp.StatusCode)))
|
||||
}
|
||||
continue
|
||||
}
|
||||
if k != pinned {
|
||||
|
Loading…
x
Reference in New Issue
Block a user