-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api] Implement replace endpoint #1162
Changes from 5 commits
dc654cf
e132f84
85841a3
c60289b
68d95ba
0516e8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,10 @@ The instructions below all contain sample curl commands, but you can always revi | |
|
||
#### Placement Initialization | ||
|
||
Send a POST request to the `/api/v1/placement/init` endpoint | ||
Send a POST request to the `/api/v1/services/m3db/placement/init` endpoint | ||
|
||
```bash | ||
curl -X POST localhost:7201/api/v1/placement/init -d '{ | ||
curl -X POST localhost:7201/api/v1/services/m3db/placement/init -d '{ | ||
"num_shards": <DESIRED_NUMBER_OF_SHARDS>, | ||
"replication_factor": <DESIRED_REPLICATION_FACTOR>(recommended 3), | ||
"instances": [ | ||
|
@@ -104,10 +104,10 @@ curl -X POST localhost:7201/api/v1/placement/init -d '{ | |
|
||
#### Adding a Node | ||
|
||
Send a POST request to the `/api/v1/placement` endpoint | ||
Send a POST request to the `/api/v1/services/m3db/placement` endpoint | ||
|
||
```bash | ||
curl -X POST <M3_COORDINATOR_HOST_NAME>:<M3_COORDINATOR_PORT(default 7201)>/api/v1/placement -d '{ | ||
curl -X POST <M3_COORDINATOR_HOST_NAME>:<M3_COORDINATOR_PORT(default 7201)>/api/v1/services/m3db/placement -d '{ | ||
"instances": [ | ||
{ | ||
"id": "<NEW_NODE_ID>", | ||
|
@@ -126,16 +126,31 @@ After sending the add command you will need to wait for the M3DB cluster to reac | |
|
||
#### Removing a Node | ||
|
||
Send a DELETE request to the `/api/v1/placement/<NODE_ID>` endpoint. | ||
Send a DELETE request to the `/api/v1/services/m3db/placement/<NODE_ID>` endpoint. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice thanks, I think the legacy stuff still works but good to update the docs to the new stuff |
||
|
||
```bash | ||
curl -X DELETE <M3_COORDINATOR_HOST_NAME>:<M3_COORDINATOR_PORT(default 7201)>/api/v1/placement/<NODE_ID> | ||
curl -X DELETE <M3_COORDINATOR_HOST_NAME>:<M3_COORDINATOR_PORT(default 7201)>/api/v1/services/m3db/placement/<NODE_ID> | ||
``` | ||
|
||
After sending the delete command you will need to wait for the M3DB cluster to reach the new desired state. You'll know that this has been achieved when the placement shows that all shards for all hosts are in the `Available` state. | ||
|
||
#### Replacing a Node | ||
|
||
Currently, the best way to replace a node (due to hardware failure or any other reason) is to perform a node remove followed by a node add. We will eventually support node replacement as a single operation, but that is currently not implemented. | ||
|
||
Send a POST request to the `/api/v1/services/m3db/placement/replace` endpoint containing hosts to replace and candidates to replace it with. | ||
|
||
```bash | ||
curl -X POST <M3_COORDINATOR_HOST_NAME>:<M3_COORDINATOR_PORT(default 7201)>/api/v1/services/m3db/placement/replace -d '{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this all work out correctly with various numbers of inputs and outputs? I.E if I want to replace one node with two, or remove two and add one etc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should so long as that algorithm considers that change valid, since we don't do much rather than be a glorified wrapper around that. @cw9 can chime in on the algo stuff There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is fine, the algo basically calls the |
||
"leavingInstanceIDs": ["<OLD_NODE_ID>"], | ||
"candidates": [ | ||
{ | ||
"id": "<NEW_NODE_ID>", | ||
"isolationGroup": "<NEW_NODE_ISOLATION_GROUP>", | ||
"zone": "<ETCD_ZONE>", | ||
"weight": <NODE_WEIGHT>, | ||
"endpoint": "<NEW_NODE_HOST_NAME>:<NEW_NODE_PORT>(default 9000)", | ||
"hostname": "<NEW_NODE_HOST_NAME>", | ||
"port": <NEW_NODE_PORT> | ||
} | ||
] | ||
}' | ||
``` |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ func TestPlacementAddHandler_SafeOK(t *testing.T) { | |
) | ||
switch serviceName { | ||
case M3AggregatorServiceName: | ||
req = httptest.NewRequest(AddHTTPMethod, M3DBAddURL, strings.NewReader(`{"instances":[{"id": "host1","isolation_group": "rack1","zone": "test","weight": 1,"endpoint": "http://host1:1234","hostname": "host1","port": 1234}]}`)) | ||
req = httptest.NewRequest(AddHTTPMethod, M3AggAddURL, strings.NewReader(`{"instances":[{"id": "host1","isolation_group": "rack1","zone": "test","weight": 1,"endpoint": "http://host1:1234","hostname": "host1","port": 1234}]}`)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 thanks |
||
default: | ||
req = httptest.NewRequest(AddHTTPMethod, M3DBAddURL, strings.NewReader(`{"instances":[{"id": "host1","isolation_group": "rack1","zone": "test","weight": 1,"endpoint": "http://host1:1234","hostname": "host1","port": 1234}]}`)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think right now it's a little ambiguous as to when to use
/api/v1/...
and when to use others like/api/v1/services/m3db/...
. There are other mentions of/api/v1/placement
like indocs/how_to
(Github docs) and in our docker integration tests. It would be great to get some clarification on when to use which, but perhaps that's for a larger discussion in another PR.cc @richardartoul
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinjc It should always be the /services/ ones, we just kept the old names in to not make a breaking change. Anywhere we have a URL without the service name should just be updated to include it