Add support in nomad for supporting raft 3 protocol peers.json

This commit is contained in:
Hemanth Basappa 2019-04-29 16:38:27 -07:00 committed by Hemanth Basappa
parent d00da5b827
commit 3fef02aa93
1 changed files with 6 additions and 1 deletions

View File

@ -1169,7 +1169,12 @@ func (s *Server) setupRaft() error {
}
} else if _, err := os.Stat(peersFile); err == nil {
s.logger.Info("found peers.json file, recovering Raft configuration...")
configuration, err := raft.ReadPeersJSON(peersFile)
var configuration raft.Configuration
if s.config.RaftConfig.ProtocolVersion < 3 {
configuration, err = raft.ReadPeersJSON(peersFile)
} else {
configuration, err = raft.ReadConfigJSON(peersFile)
}
if err != nil {
return fmt.Errorf("recovery failed to parse peers.json: %v", err)
}