Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

support for api/ raft-add-peer and raft-remove-peer #1208

Merged
merged 3 commits into from
Jul 26, 2020

Conversation

shlomi-noach
Copy link
Collaborator

This PR adds new API endpoints:

  • api/raft-add-peer/:addr: dynamically add a new raft member. This increases the size of the raft group by 1, thereby possibly changing the quorum size. This API call is made to the leader (a follower will delegate the call to the leader). As for the new node itself, it must know to connect to at least one existing member of the group. Example:
    • Assume the current group is 10.0.0.1, 10.0.0.2, 10.0.0.3
    • make this api call: api/raft-add-peer/10.0.0.4:10008
    • The node on 10.0.0.4 will ideally have this in its config file:
  "RaftNodes": [
    "10.0.0.1:10008",
    "10.0.0.2:10008",
    "10.0.0.3:10008",
    "10.0.0.4:10008"
  ]
  • but it's OK if it has the following, because it will will be able to connect to the quorum:
  "RaftNodes": [
    "10.0.0.3:10008",
    "10.0.0.4:10008"
  ]
  • api/raft-remove-peer/:addr: forcibly remove a node from the raft group. The node will not be allowed to content for leadership, will not receive any updates, will be rejected from the group. Only use this when the node is decomissioned or destroyed (e.g. a kubernetes pod is down)

  • api/raft-status. Example:

$ curl -s http://127.0.0.1:3007/api/raft-status | jq .
{
  "RaftBind": "127.0.0.1:10007",
  "RaftAdvertise": "127.0.0.1:10007",
  "State": "Leader",
  "Healthy": true,
  "IsPartOfQuorum": true,
  "Leader": "127.0.0.1:10007",
  "LeaderURI": "http://127.0.0.1:3007",
  "Peers": [
    "127.0.0.1:10007",
    "127.0.0.1:10008",
    "127.0.0.1:10009"
  ]
}
$ curl -s http://127.0.0.1:3008/api/raft-status | jq .
{
  "RaftBind": "127.0.0.1:10008",
  "RaftAdvertise": "127.0.0.1:10008",
  "State": "Follower",
  "Healthy": true,
  "IsPartOfQuorum": true,
  "Leader": "127.0.0.1:10007",
  "LeaderURI": "http://127.0.0.1:3007",
  "Peers": [
    "127.0.0.1:10007",
    "127.0.0.1:10008",
    "127.0.0.1:10009"
  ]
}

Related: #253, #246 (comment)

@shlomi-noach shlomi-noach merged commit b19d0d7 into master Jul 26, 2020
@shlomi-noach shlomi-noach deleted the raft-add-remove-peer branch July 26, 2020 11:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant