From de78bf8e5ef5e06e41e2e91d9a9141e9b1942798 Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Tue, 26 Mar 2024 12:22:09 -0400 Subject: [PATCH] remove duplicate var --- raft.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/raft.go b/raft.go index 8d9da287..d78178b6 100644 --- a/raft.go +++ b/raft.go @@ -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) { @@ -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