From 62560f995961e92b59e5321ed7183529bd3c74f7 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Tue, 20 May 2014 20:01:10 -0700 Subject: [PATCH 1/3] fix(server): add user facing remove API This was accidently removed as we refactored the standy stuff. Re-add this user facing remove endpoint that matches the config endpoints. --- Documentation/api.md | 22 ++++++++++++++++++++++ server/peer_server.go | 1 + 2 files changed, 23 insertions(+) diff --git a/Documentation/api.md b/Documentation/api.md index f8276900602..3f31148b573 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -1233,3 +1233,25 @@ curl -L http://127.0.0.1:7001/v2/admin/config "promoteDelay": 1800 } ``` + +## Remove Machines + +At times you may want to manually remove a machine. Using the machines endpoint +you can find and remove machines. + +```sh +curl -L http://127.0.0.1:7001/v2/admin/machines/peer2 +``` + +```json +{ + "clientURL": "http://127.0.0.1:4002", + "name": "peer2", + "peerURL": "http://127.0.0.1:7002", + "state": "follower" +} +``` + +```sh +curl -L -XDELETE http://127.0.0.1:7001/v2/admin/machines/peer2 +``` diff --git a/server/peer_server.go b/server/peer_server.go index 984d8783f0b..d7a11140008 100644 --- a/server/peer_server.go +++ b/server/peer_server.go @@ -355,6 +355,7 @@ func (s *PeerServer) HTTPHandler() http.Handler { router.HandleFunc("/v2/admin/config", s.setClusterConfigHttpHandler).Methods("PUT") router.HandleFunc("/v2/admin/machines", s.getMachinesHttpHandler).Methods("GET") router.HandleFunc("/v2/admin/machines/{name}", s.getMachineHttpHandler).Methods("GET") + router.HandleFunc("/v2/admin/machines/{name}", s.RemoveHttpHandler).Methods("DELETE") return router } From c3aab4295905774cd5675b54be9f79043a318cab Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Tue, 20 May 2014 20:07:47 -0700 Subject: [PATCH 2/3] fix(Documentation): update based on standby refactor These docs were not updated after the refactoring of the standy mode. Fix that now. --- Documentation/api.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/api.md b/Documentation/api.md index 3f31148b573..2fbd4c7be89 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -1205,21 +1205,22 @@ The configuration endpoint manages shared cluster wide properties. ### Set Cluster Config ```sh -curl -L http://127.0.0.1:7001/v2/admin/config -XPUT -d '{"activeSize":3, "promoteDelay":1800}' +curl -L http://127.0.0.1:7001/v2/admin/config -XPUT -d '{"activeSize":3, "removeDelay":1800,"syncInterval":5}' ``` ```json { "activeSize": 3, - "promoteDelay": 1800 + "removeDelay": 1800, + "syncInterval":5 } ``` `activeSize` is the maximum number of peers that can join the cluster and participate in the consensus protocol. -The size of cluster is controlled to be around a certain number. If it is not, it will promote standby-mode instances or demote peer-mode instances to make it happen. +The size of cluster is controlled to be around a certain number. If it is not, standby-mode instances will join or peer-mode instances will be removed to make it happen. -`promoteDelay` indicates the minimum length of delay that has been observed before promotion or demotion. +`removeDelay` indicates the minimum time that a machine has been observed to be unresponsive before it is removed from the cluster. ### Get Cluster Config @@ -1230,7 +1231,8 @@ curl -L http://127.0.0.1:7001/v2/admin/config ```json { "activeSize": 3, - "promoteDelay": 1800 + "removeDelay": 1800, + "syncInterval":5 } ``` From 0eba3c9000173a5b95cae28939c0bfe7d1f876c2 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Tue, 20 May 2014 20:25:34 -0700 Subject: [PATCH 3/3] feat(Documentation): document the entire admin machines API Flesh out this document a bit more completely. --- Documentation/api.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/api.md b/Documentation/api.md index 2fbd4c7be89..f392c95e6d2 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -1241,6 +1241,36 @@ curl -L http://127.0.0.1:7001/v2/admin/config At times you may want to manually remove a machine. Using the machines endpoint you can find and remove machines. +First, list all the machines in the cluster. + +```sh +curl -L http://127.0.0.1:7001/v2/admin/machines +``` +```json +[ + { + "clientURL": "http://127.0.0.1:4001", + "name": "peer1", + "peerURL": "http://127.0.0.1:7001", + "state": "leader" + }, + { + "clientURL": "http://127.0.0.1:4002", + "name": "peer2", + "peerURL": "http://127.0.0.1:7002", + "state": "follower" + }, + { + "clientURL": "http://127.0.0.1:4003", + "name": "peer3", + "peerURL": "http://127.0.0.1:7003", + "state": "follower" + } +] +``` + +Then take a closer look at the machine you want to remove. + ```sh curl -L http://127.0.0.1:7001/v2/admin/machines/peer2 ``` @@ -1254,6 +1284,8 @@ curl -L http://127.0.0.1:7001/v2/admin/machines/peer2 } ``` +And finally remove it. + ```sh curl -L -XDELETE http://127.0.0.1:7001/v2/admin/machines/peer2 ```