mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3229 from xiang90/f_cerr
client: return context.Canceled error when user cancels the request
This commit is contained in:
commit
b04bb3e0ea
@ -255,7 +255,13 @@ func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (*http.Respo
|
|||||||
resp, body, err = hc.Do(ctx, action)
|
resp, body, err = hc.Do(ctx, action)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cerr.Errors = append(cerr.Errors, err)
|
cerr.Errors = append(cerr.Errors, err)
|
||||||
if err == context.DeadlineExceeded || err == context.Canceled {
|
// mask previous errors with canceled error if the user explicitly canceled the request
|
||||||
|
if err == context.Canceled {
|
||||||
|
return nil, nil, context.Canceled
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: deal with deadline error when we improve the deadline handling.
|
||||||
|
if err == context.DeadlineExceeded {
|
||||||
return nil, nil, cerr
|
return nil, nil, cerr
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
@ -364,7 +364,7 @@ func TestHTTPClusterClientDo(t *testing.T) {
|
|||||||
),
|
),
|
||||||
rand: rand.New(rand.NewSource(0)),
|
rand: rand.New(rand.NewSource(0)),
|
||||||
},
|
},
|
||||||
wantErr: &ClusterError{Errors: []error{context.Canceled}},
|
wantErr: context.Canceled,
|
||||||
},
|
},
|
||||||
|
|
||||||
// return err if there are no endpoints
|
// return err if there are no endpoints
|
||||||
|
Loading…
x
Reference in New Issue
Block a user