mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
commit
b53a98eb38
@ -51,7 +51,7 @@ curl http://10.0.0.10:2379/v2/members
|
||||
|
||||
Returns an HTTP 201 response code and the representation of added member with a newly generated a memberID when successful. Returns a string describing the failure condition when unsuccessful.
|
||||
|
||||
If the POST body is malformed an HTTP 400 will be returned. If the member exists in the cluster or existed in the cluster at some point in the past an HTTP 500(TODO: fix this) will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
|
||||
If the POST body is malformed an HTTP 400 will be returned. If the member exists in the cluster or existed in the cluster at some point in the past an HTTP 409 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
|
||||
|
||||
### Request
|
||||
|
||||
|
@ -189,7 +189,7 @@ func (h *membersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
err = h.server.AddMember(ctx, *m)
|
||||
switch {
|
||||
case err == etcdserver.ErrIDExists || err == etcdserver.ErrPeerURLexists:
|
||||
writeError(w, httptypes.NewHTTPError(http.StatusPreconditionFailed, err.Error()))
|
||||
writeError(w, httptypes.NewHTTPError(http.StatusConflict, err.Error()))
|
||||
return
|
||||
case err != nil:
|
||||
log.Printf("etcdhttp: error adding node %s: %v", m.ID, err)
|
||||
|
@ -773,6 +773,34 @@ func TestServeMembersFail(t *testing.T) {
|
||||
|
||||
http.StatusInternalServerError,
|
||||
},
|
||||
{
|
||||
// etcdserver.AddMember error
|
||||
&http.Request{
|
||||
URL: mustNewURL(t, membersPrefix),
|
||||
Method: "POST",
|
||||
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
|
||||
Header: map[string][]string{"Content-Type": []string{"application/json"}},
|
||||
},
|
||||
&errServer{
|
||||
etcdserver.ErrIDExists,
|
||||
},
|
||||
|
||||
http.StatusConflict,
|
||||
},
|
||||
{
|
||||
// etcdserver.AddMember error
|
||||
&http.Request{
|
||||
URL: mustNewURL(t, membersPrefix),
|
||||
Method: "POST",
|
||||
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
|
||||
Header: map[string][]string{"Content-Type": []string{"application/json"}},
|
||||
},
|
||||
&errServer{
|
||||
etcdserver.ErrPeerURLexists,
|
||||
},
|
||||
|
||||
http.StatusConflict,
|
||||
},
|
||||
{
|
||||
// etcdserver.RemoveMember error with arbitrary server error
|
||||
&http.Request{
|
||||
|
Loading…
x
Reference in New Issue
Block a user