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

a NonVoter node should never try to bootstrap #492

Merged
merged 2 commits into from Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions api.go
Expand Up @@ -36,6 +36,10 @@ var (
// follower or candidate node.
ErrNotLeader = errors.New("node is not the leader")

// ErrNotVoter is returned when an operation can't be completed on a
// non-voter node.
ErrNotVoter = errors.New("node is not a voter")

// ErrLeadershipLost is returned when a leader fails to commit a log entry
// because it's been deposed in the process.
ErrLeadershipLost = errors.New("leadership lost while committing log")
Expand Down
5 changes: 5 additions & 0 deletions raft.go
Expand Up @@ -233,6 +233,11 @@ func (r *Raft) runFollower() {
// the Raft object's member BootstrapCluster for more details. This must only be
// called on the main thread, and only makes sense in the follower state.
func (r *Raft) liveBootstrap(configuration Configuration) error {
if !hasVote(configuration, r.localID) {
// Reject this operation since we are not a voter
return ErrNotVoter
}

// Use the pre-init API to make the static updates.
cfg := r.config()
err := BootstrapCluster(&cfg, r.logs, r.stable, r.snapshots, r.trans, configuration)
Expand Down