Skip to content
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

Add support of changing raft peers via HTTP api #232

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Dec 16, 2024

This closes #231.

I have tested the basic features manually for the raft engine:

Step 1: start a cluster with three nodes:

❯ curl -s  http://127.0.0.1:9379/api/v1/raft/peers | jq    

{                                                                       
  "data": {
    "leader": 1,
    "peers": {
      "1": "http://127.0.0.1:6001",
      "2": "http://127.0.0.1:6002",
      "3": "http://127.0.0.1:6003"
    }
  }
}

Step 2: add a new peer node into the cluster:

❯ curl -XPOST -d '{"id":4,"peer":"http://127.0.0.1:6004","operation":"add"}'  http://127.0.0.1:9379/api/v1/raft/peers

❯ curl -s  http://127.0.0.1:9379/api/v1/raft/peers | jq    

{
  "data": {
    "leader": 1,
    "peers": {
      "1": "http://127.0.0.1:6001",
      "2": "http://127.0.0.1:6002",
      "3": "http://127.0.0.1:6003",
      "4": "http://127.0.0.1:6004"
    }
  }
}

Step 3: remove a peer node from the cluster:

❯ curl -XPOST -d '{"id":2,"operation":"remove"}'  http://127.0.0.1:9379/api/v1/raft/peers


❯ curl -s  http://127.0.0.1:9379/api/v1/raft/peers | jq
{
  "data": {
    "leader": 1,
    "peers": {
      "1": "http://127.0.0.1:6001",
      "3": "http://127.0.0.1:6003",
      "4": "http://127.0.0.1:6004"
    }
  }
}

@git-hulk git-hulk marked this pull request as ready for review December 17, 2024 12:37
@git-hulk
Copy link
Member Author

@torwig @PragmaTwice I have also confirmed that the raft engine works normally if the leader node is down and the follower will take over. Will consider how to add some integration tests for the raft engine, but won't have the bandwidth to do that in a short time.

@git-hulk git-hulk requested a review from torwig December 17, 2024 15:25
store/engine/raft/node.go Outdated Show resolved Hide resolved
@git-hulk git-hulk requested a review from torwig December 17, 2024 15:44
@git-hulk git-hulk merged commit 83355d5 into apache:unstable Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to add/remove a peer via HTTP API
3 participants