From 08c83d341d46b47d260162d9c8e813e40ff0b256 Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Thu, 25 Jun 2020 20:51:13 -0400 Subject: [PATCH] physical/raft: Add nil check to shutdown (#9322) --- physical/raft/raft.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/physical/raft/raft.go b/physical/raft/raft.go index 5ada5b9579..01ee1999c4 100644 --- a/physical/raft/raft.go +++ b/physical/raft/raft.go @@ -729,14 +729,25 @@ func (b *RaftBackend) TeardownCluster(clusterListener cluster.ClusterHook) error } b.l.Lock() - future := b.raft.Shutdown() + + // Perform shutdown only if the raft object is non-nil. The object could be nil + // if the node is unsealed but has not joined the peer set. + var future raft.Future + if b.raft != nil { + future = b.raft.Shutdown() + } + b.raft = nil // If we're tearing down, then we need to recreate the raftInitCh b.raftInitCh = make(chan struct{}) b.l.Unlock() - return future.Error() + if future != nil { + return future.Error() + } + + return nil } // CommittedIndex returns the latest index committed to stable storage