Skip to content

Commit

Permalink
remove duplicate var
Browse files Browse the repository at this point in the history
  • Loading branch information
dhiaayachi committed Mar 26, 2024
1 parent 7543a3d commit de78bf8
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions raft.go
Expand Up @@ -1758,11 +1758,8 @@ func (r *Raft) requestPreVote(rpc RPC, req *RequestPreVoteRequest) {
// there is a known leader. But if the leader initiated a leadership transfer,
// vote!
var candidate ServerAddress

// For older raft version ID is not part of the packed message
// We assume that the peer is part of the configuration and skip this check

candidateID := ServerID(req.ID)

// if the Servers list is empty that mean the cluster is very likely trying to bootstrap,
// Grant the vote
if len(r.configurations.latest.Servers) > 0 && !inConfiguration(r.configurations.latest, candidateID) {
Expand Down Expand Up @@ -1796,8 +1793,6 @@ func (r *Raft) requestPreVote(rpc RPC, req *RequestPreVoteRequest) {
// This could happen when a node, previously voter, is converted to non-voter
// The reason we need to step in is to permit to the cluster to make progress in such a scenario
// More details about that in https://github.com/hashicorp/raft/pull/526

candidateID := ServerID(req.ID)
if len(r.configurations.latest.Servers) > 0 && !hasVote(r.configurations.latest, candidateID) {
r.logger.Warn("rejecting pre-vote request since node is not a voter", "from", candidate)
return
Expand Down

0 comments on commit de78bf8

Please sign in to comment.