Commit Graph

264 Commits (1917e5c543d6b6e3439a4308af1920d038797113)

Author SHA1 Message Date
Yicheng Qin 78af793338 client: return context canceled error correctly
If the body is closed to stop watching, it will ignore the error from
reading body and return context error.

Before this PR, the cancel when watching always returns error `read tcp
127.0.0.1:57824: use of closed network connection`. After this PR, it
will return expected context canceled error.
2015-08-06 14:52:04 -07:00
Xiang Li b04bb3e0ea Merge pull request #3229 from xiang90/f_cerr
client: return context.Canceled error when user cancels the request
2015-08-06 14:41:19 -07:00
Yicheng Qin 25ad71fbac Merge pull request #3225 from yichengq/client-record-err
client: return correct error for 50x response
2015-08-06 14:40:38 -07:00
Yicheng Qin cfeaf3d172 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
```
2015-08-06 14:25:03 -07:00
Xiang Li 9a8607fce1 Merge pull request #3187 from yichengq/client-keep-sync
client: add KeepSync function
2015-08-06 00:16:28 -07:00
Yicheng Qin c53b3016ae client: add AutoSync function
AutoSync provides the way for client to syncing member list from
etcd cluster automatically.
2015-08-05 13:22:56 -07:00
Xiang Li f38187bbdb client: return context.Canceled error when user cancels the request 2015-08-05 09:52:30 -07:00
Eugene Yakubovich 6312e22b1d client: handle empty watch responses elegantly
Even though current etcd does not time out
watches, the client could be running against
an old etcd version or the server may close
polling connection for other reasons.
This patch ignores successful (as in 200)
responses with emtpy bodies instead
of producing JSON errors.
2015-08-03 11:47:21 -07:00
Xiang Li a47e661fff discovery: print out detailed cluster error 2015-07-29 23:06:57 +08:00
Xiang Li 5fa8652241 client: return cluster error if the etcd cluster is not avaliable
Add a new ClusterError type. It contians all encountered errors and
return ClusterNotAvailable as the error string.
2015-07-29 22:55:15 +08:00
Yicheng Qin 6184e271a4 Merge pull request #3164 from yichengq/pin-endpoint
client: pin itself to an endpoint that given
2015-07-27 14:35:51 -07:00
Yicheng Qin ea2347a40f client: pin itself to an endpoint that given
1. When reset endpoints, client will choose a random endpoint to pin.
2. If the pinned endpoint is healthy, client will keep using it.
3. If the pinned endpoint becomes unhealthy, client will attempt other
endpoints and update its pin.
2015-07-27 13:36:53 -07:00
Yicheng Qin b20b87893f client: add Quorum option in getOption 2015-07-22 15:19:34 -07:00
Xiang Li d2dac0fe59 client: consume json error and return ErrInvaildJSON
The default JSON error is not very readable. We let client
consume the error and return a more understandable error in
the context of etcd.

Fix #3120
2015-07-21 12:53:21 -07:00
Xiang Li 6e3769d39e client: add member update 2015-07-21 12:53:20 -07:00
Xiang Li e3fcc450cf etcdctl: make rm use etcd/client 2015-07-21 12:53:19 -07:00
Yicheng Qin cf050ee21d Merge pull request #2943 from yichengq/fix-client-test
client: fix TestSimpleHTTPClientDoCancelContextResponseBodyClosed
2015-06-23 13:43:07 -07:00
Yicheng Qin 7716bdf981 client: fix TestSimpleHTTPClientDoCancelContextResponseBodyClosed
This fixes the bug that the test may hang forever because RoundTrip is
blocked. fixes #2449
2015-06-16 11:29:54 -07:00
Barak Michener 64ec8af91b *: Rename `security` to `auth` 2015-06-15 18:18:50 -04:00
Barak Michener a4d1a5a6e5 *: Add security/auth support to etcdctl and etcd/client
add godep for speakeasy and auth entry parsing
add security_user to client
add role to client
add role commands
add auth support to etcdclient and etcdctl(member/user)
add enable/disable to etcdctl
better error messages, read/write/readwrite
Bump go-etcd to include codec changes, add new dependency
verify the error for revoke/add if nothing changed, remove security-merging prefix
2015-06-10 16:58:10 -04:00
Xiang Li 15ac4f08f8 client: fix cancel watch
ioutil.ReadAll is a blocking call, we need to wait cancelation
during the call.
2015-06-05 15:40:43 -07:00
Xiang Li 4f2df84a38 client: support printing cURL command 2015-06-03 10:02:37 -07:00
Chance Zibolski 48e144ae2e client: Support creating directory through KeysAPI
Creating a directory is done using the Set() method and a SetOptions
struct with it's Dir field set to true.
2015-05-07 10:47:18 -07:00
Brian Waldon ee9e336fd4 client: add Node.TTLDuration() 2015-05-05 15:03:24 -07:00
Yicheng Qin 39dae50e71 client: fix test name typo
This is introduced at d89a862
2015-04-24 18:05:18 -07:00
Xiang Li 91c45c3243 client: 410 is a vaild response for member.Remove
When removing a member, etcdserver might return 410 that indicates
the member has been removed. To client, 410 is a vaild response since
the client might do internal retry.
2015-04-24 17:01:23 -07:00
Xiang Li 61e94ae16c Merge pull request #2625 from bakins/client-srv
Initial SRV discovery for clients
2015-04-17 08:07:32 -07:00
Brian Akins c4899c201e client: Discovery via SRV lookups
Based on code from discovery/srv.go.  The returns the target as DNS
returns it. In the case of SSL, certs are tied to the hostname and not
the IP address generally.

Solves #2547
2015-04-17 10:57:01 -04:00
Chance Zibolski d89a8628c6 client: Add CreateInOrder method to client.KeysAPI
Allows creating nodes within a given directory with atomically increasing
keys
2015-04-13 17:23:17 -07:00
Xiang Li 8e9f2bb9e6 Merge pull request #2634 from xiang90/client-new
client: add dir/ttl fields into node
2015-04-07 09:11:19 -07:00
Xiang Li 666a97271d client: add dir/ttl fields into node 2015-04-06 21:47:20 -07:00
Alex Crawford d9ad6aa2a9 *: update to use IANA-assigned ports 2015-04-06 13:49:43 -07:00
Brian Waldon 9fe78c8bc4 client: don't use nested actions 2015-02-28 10:45:21 -08:00
Brian Waldon 25cf916a80 client: ensure Response closed on cancel 2015-02-28 10:45:21 -08:00
Brian Waldon b41d6bc416 client: set hard limit on redirect checks 2015-02-28 10:45:21 -08:00
Brian Waldon 50a9b2d9c8 client: rm naked return from httpClusterClient.Do 2015-02-28 10:45:21 -08:00
Brian Waldon 99aa0e1fcc client: test httpClusterClient.reset failure cases 2015-02-28 10:45:21 -08:00
Brian Waldon ed173a2a76 client: fix bad URL fixture 2015-02-28 10:45:21 -08:00
Brian Waldon cd777b2966 client: test httpClusterClient.Sync 2015-02-28 10:45:21 -08:00
Brian Waldon ae062a0825 client: move lock so MembersAPI.List doesn't deadlock 2015-02-28 10:45:21 -08:00
Brian Waldon 83930ac113 client: test DefaultCheckRedirect 2015-02-28 10:45:21 -08:00
Brian Waldon 943c7ef307 client: test httpKeysAPI's Create and Update methods 2015-02-28 10:45:21 -08:00
Brian Waldon 115e758c32 client: test httpKeysAPI.Delete 2015-02-28 10:45:21 -08:00
Brian Waldon ece03fb987 client: drop unnecessary field deleteAction.Value 2015-02-28 10:45:21 -08:00
Brian Waldon 6fc209e574 client: test httpKeysAPI.Get 2015-02-28 10:45:21 -08:00
Brian Waldon 32bfcca5a8 client: test httpKeysAPI.Set 2015-02-28 10:45:20 -08:00
Brian Waldon 14b3f96091 client: test httpKeysAPI.Watcher 2015-02-28 10:45:20 -08:00
Brian Waldon cd85451971 client: clarify relationship of AfterIndex and waitIndex 2015-02-28 10:45:20 -08:00
Brian Waldon 09017af35e client: test httpWatcher 2015-02-28 10:38:47 -08:00
Brian Waldon 11a6cb68a6 client: test unmarshaling of failure responses 2015-02-28 10:38:47 -08:00
Brian Waldon 9378413283 client: exhaustive member-related testing 2015-02-28 10:38:47 -08:00
Brian Waldon 32ff3ce26f client: test for non-integer X-Etcd-Index 2015-02-28 10:38:47 -08:00
Brian Waldon 8a6b72b08d client: tweak test fields 2015-02-28 10:38:47 -08:00
Brian Waldon b174732812 client: introduce Error type 2015-02-28 10:38:47 -08:00
Brian Waldon 8fdc6b154e client: document PrevExistType 2015-02-28 10:38:47 -08:00
Brian Waldon 39b5b083c0 client: document Member fields 2015-02-28 10:38:47 -08:00
Brian Waldon 27de5eec76 client: document Response and Node structs 2015-02-28 10:38:47 -08:00
Brian Waldon 4a77760f56 client: break dependency on httptypes pkg 2015-02-28 10:38:46 -08:00
Brian Waldon 9b334e07a6 client: allow caller to decide HTTP redirect policy 2015-02-28 10:38:46 -08:00
Brian Waldon 1c03df62a5 client: WaitIndex -> AfterIndex 2015-02-28 10:38:46 -08:00
Brian Waldon a834f297f9 client: document KeysAPI methods 2015-02-28 10:22:52 -08:00
Brian Waldon 2b5589ddcd client: encourage error handling in package doc 2015-02-28 10:22:52 -08:00
Brian Waldon 6fd105d554 client: document using a custom context 2015-02-28 10:22:52 -08:00
Brian Waldon 479a17dcbf client: add GetOptions.Sort 2015-02-28 10:22:52 -08:00
Brian Waldon 84ede6fbec client: use options struct for KeysAPI.Get 2015-02-28 10:22:52 -08:00
Brian Waldon 8621caf3e2 client: define a DefaultTransport 2015-02-28 10:22:52 -08:00
Brian Waldon ce4486ff85 client: document Client methods 2015-02-28 10:22:52 -08:00
Brian Waldon 1773d0a18b client: simplify CancelableTransport doc 2015-02-28 10:22:52 -08:00
Brian Waldon 19dd4a0f3c client: document Config 2015-02-28 10:22:52 -08:00
Brian Waldon 6d82472275 client: move http.go into client.go 2015-02-28 10:22:52 -08:00
Brian Waldon bfbf672ce4 client: document MembersAPI methods 2015-02-28 10:22:52 -08:00
Brian Waldon 7255fb1b62 client: alias etcdserver/etcdhttp/httptypes.Member 2015-02-28 10:22:52 -08:00
Brian Waldon 932351a00d client: document Watcher.Next 2015-02-28 10:22:52 -08:00
Brian Waldon aee95468ba client: document MembersAPI/KeysAPI constructors 2015-02-28 10:22:51 -08:00
Brian Waldon e885c6c5f4 client: document *Options 2015-02-28 10:22:51 -08:00
Brian Waldon 88cea415a7 client: NewDiscoveryKeysAPI -> NewKeysAPIWithPrefix 2015-02-28 10:22:51 -08:00
Brian Waldon 89070fd237 client: package-level doc 2015-02-28 10:22:51 -08:00
Brian Waldon 3d4e1f59dc client: drop unnecessary Nodes type 2015-02-28 10:22:51 -08:00
Brian Waldon 7ff84351f5 client: centralize exported variables 2015-02-28 10:22:51 -08:00
Brian Waldon a9f605e5fe client: unexport defaultV2MembersPrefix 2015-02-28 10:22:51 -08:00
Brian Waldon bb9f016b91 client: unexport defaultV2KeysPrefix 2015-02-28 10:22:51 -08:00
Brian Waldon 3fdda06602 client: s/SyncableHTTPClient/Client/g 2015-02-28 10:22:51 -08:00
Brian Waldon bac1d2f420 client: unexport httpClient interface 2015-02-28 10:22:51 -08:00
Brian Waldon 52288fa748 client: remove CancelableTransport arg from httpClientFactory 2015-02-28 10:22:51 -08:00
Brian Waldon 3b41b77cd7 client: ClientConfig -> Config 2015-02-28 10:22:51 -08:00
Brian Waldon 2aecbaf165 client: unexport httpAction 2015-02-28 10:22:51 -08:00
Brian Waldon 3f5e827e3c client: httpClient -> simpleHTTPClient 2015-02-28 10:22:51 -08:00
Brian Waldon f037cb9f65 client: collapse unnecessary constructor 2015-02-28 10:22:50 -08:00
Brian Waldon 62054dfb5e client: don't cache httpClients in httpClusterClient 2015-02-28 10:22:50 -08:00
Brian Waldon 99d63eb62e client: protect httpClusterClient with RWMutex 2015-02-28 10:22:50 -08:00
Brian Waldon 0943831b8e client: establish httpClusterClient.reset 2015-02-28 10:22:50 -08:00
Brian Waldon 74fe28c5e0 client: exchange ClientConfig for SyncableHTTPClient 2015-02-28 10:22:50 -08:00
Brian Waldon 942f0f6b9e client: accept TTL through KeysAPI.Set 2015-02-28 10:22:50 -08:00
Brian Waldon 3d53e9bfaa client: pass around options as pointers 2015-02-28 10:22:50 -08:00
Brian Waldon 0a7e0875d5 client: copy DeleteOptions onto deleteAction 2015-02-28 10:19:05 -08:00
Brian Waldon 025ee0379c client: copy SetOptions onto setAction 2015-02-28 10:19:05 -08:00
Brian Waldon 01fc01ec69 client: KeysAPI.[R]Watch -> Watcher w/ opts struct 2015-02-28 10:19:04 -08:00
Brian Waldon bc32060b1d client: support PrevIndex in SetOptions & DeleteOptions 2015-02-28 10:14:25 -08:00
Brian Waldon 7ccf5eb476 client: support PrevValue in SetOptions & DeleteOptions 2015-02-28 10:14:25 -08:00
Brian Waldon 0f31f403d1 client: add KeysAPI.Delete 2015-02-28 10:14:25 -08:00
Brian Waldon 2f479c8721 client: assert method in tests 2015-02-28 10:14:25 -08:00
Brian Waldon 84e495e51e client: s/assertResponse/assertRequest/ 2015-02-28 10:14:25 -08:00
Brian Waldon 6e637f2f75 client: add KeysAPI.Set 2015-02-28 10:14:25 -08:00
Brian Waldon 8b3d05f661 client: add KeysAPI.RGet 2015-02-28 10:14:25 -08:00
Brian Waldon 6d89e6217d client: rename KeysAPI.RecursiveWatch to RWatch 2015-02-28 10:14:25 -08:00
Brian Waldon 4e5c015fe9 client: add Update method 2015-02-28 10:14:25 -08:00
Brian Waldon c6d955f4c1 client: drive Create with setAction; drop TTL 2015-02-28 10:12:35 -08:00
Barak Michener 92dca0af0f *: remove shadowing of variables from etcd and add travis test
We've been bitten by this enough times that I wrote a tool so that
it never happens again.
2015-02-17 16:31:42 -05:00
Jonathan Boulle f1ed69e883 *: switch to line comments for copyright
Build tags are not compatible with block comments.
Also adds copyright header to a few places it was missing.
2015-01-26 09:53:30 -08:00
Xiang Li 7171410422 discovery: discovery will try forever when there is a timeout.
Perviously, etcd retries three times for timeout error. After this
commit, etcd retries forever. Also this commit make etcd client
aware of gateway timetout.
2014-12-10 23:08:24 -08:00
Veres Lajos 3de2ab2c04 *: typofixes
https://github.com/vlajos/misspell_fixer
2014-12-04 22:51:19 +00:00
Brian Waldon 9a728a127a dep: bump golang.org/x/net/context
Move from code.google.com/p/go.net/context to
golang.org/x/net/context before bumping to latest.
2014-11-20 10:19:12 -08:00
Brian Waldon 5f6e536be8 Merge pull request #1639 from bcwaldon/etcdctl-tls
Wire up TLS flags for etcdctl
2014-11-07 13:19:36 -08:00
Xiang Li 66572561bf client: add error handling for addmember 2014-11-06 12:31:24 -08:00
Brian Waldon 4b555dba99 client: add SyncableHTTPClient.Endpoints 2014-11-06 10:54:56 -08:00
Jonathan Boulle 45b7c9a4ac client: return ErrNoEndpoint when none available
In certain cases (for example, if a cluster peer is accessible but it
has no members listed), the httpClusterClient could have an empty set of
endpoints as a result of the Sync. This means that its Do function could
potentially return a nil response and nil error, with catastrophic
consequences for callers.

To be safe (particularly about this latter behaviour), this change
errors in both Sync and Do if no endpoints are available.
2014-11-04 12:51:43 -08:00
Brian Waldon 6dd4944e62 client: follow redirects 2014-11-03 12:15:16 -08:00
Brian Waldon da6827f09e client: use all endpoints 2014-10-31 20:51:47 -07:00
Brian Waldon 58af26736c client: further clarify external interfaces 2014-10-31 20:45:55 -07:00
Brian Waldon 17c6f21d68 client: elevate context to caller of KeysAPI 2014-10-31 17:27:43 -07:00
Brian Waldon f0760d6246 client: elevate context to caller of MembersAPI 2014-10-31 17:27:42 -07:00
Brian Waldon 913d102a81 client: remove unused field 2014-10-31 17:25:05 -07:00
Brian Waldon 824049897d client: export necessary interfaces/methods 2014-10-31 17:25:05 -07:00
Brian Waldon 5ed5d018be client: add httpClusterClient.Sync 2014-10-31 17:25:05 -07:00
Brian Waldon f6e8b677cf client: pass httpActionDo into NewMembersAPI 2014-10-31 17:25:05 -07:00
Brian Waldon 0ef270c25c client: pass httpActionDo into New[Discovery]KeysAPI 2014-10-31 17:25:05 -07:00
Brian Waldon 1130273178 client: s/newHTTPClusterClient/NewHTTPClient/ 2014-10-31 17:25:05 -07:00
Brian Waldon 3eb126af4d client: use httpActionDo in httpClusterClient 2014-10-31 17:25:05 -07:00
Brian Waldon c282664c23 client: s/transport/CancelableTransport/
CancelableTransport is implemented by callers of the
client pkg, so we should export it so it is
documented publicly.
2014-10-31 17:25:04 -07:00
Brian Waldon d52d836761 client: return full http.Response in httpActionDo 2014-10-31 17:25:04 -07:00
Brian Waldon eab4692744 client: use v2MembersURL helper 2014-10-31 12:21:15 -07:00
Brian Waldon 8b8b3efdaa client: accept slice of endpoints 2014-10-31 12:21:15 -07:00
Brian Waldon 8d519ffdb8 client: introduce httpClusterClient 2014-10-31 12:21:15 -07:00
Brian Waldon 323fb1ec85 client: introduce httpActionDo interface 2014-10-31 12:21:15 -07:00
Brian Waldon 9d07db4432 client: move timeout into caller of httpClient 2014-10-31 12:21:15 -07:00
Brian Waldon 7c1f4a9baf client: explicitly carry API prefix around 2014-10-31 12:21:15 -07:00
Brian Waldon 052521eaf1 client: test assertStatusCode 2014-10-30 11:46:44 -07:00
Brian Waldon d756dd2079 client: test membersAPIActionRemove 2014-10-29 16:42:16 -07:00
Brian Waldon 5264c05ddb client: clean up style of TestMembersAPIActionList 2014-10-29 16:42:16 -07:00
Brian Waldon 4e759b46ce client: use httptypes.MemberCreateRequest in member add 2014-10-29 16:42:14 -07:00
Brian Waldon e457d52f5c client: log incorrect HTTP resp body as string 2014-10-29 16:37:07 -07:00
Jonathan Boulle 97c23c4333 client: pass around statuscode instead of Response
There's no real need for do and doWithTimeout to return Responses when
the only field of interest is the status code.

This also removes the superfluous httpMembersAPIResponse struct.
2014-10-29 15:47:55 -07:00
Brian Waldon 95231c1278 Merge pull request #1493 from bcwaldon/etcdctl-members
etcdctl members [list|add|remove]
2014-10-29 15:44:30 -07:00
Brian Waldon 8b12e1aa37 client: fill in MembersAPI 2014-10-29 15:03:22 -07:00
Brian Waldon ab67fa4cc6 api: remove admin prefix from members API 2014-10-29 12:12:51 -07:00
Brian Waldon 80ca168cbe client: simplify MembersAPI response parsing 2014-10-27 11:22:47 -07:00
Brian Waldon 14795d8ed9 httptypes: use MemberCollection for JSON (de)serialization 2014-10-27 11:22:47 -07:00
Brian Waldon 54a2d8ffc9 client: move Member models to new types pkg 2014-10-27 11:22:46 -07:00
Brian Waldon cba19e348f client: MembersAPI.List 2014-10-25 11:30:15 -07:00
Brian Waldon 00dcbf8bf7 client: unexport HTTPKeysAPI 2014-10-25 08:58:25 -07:00