Skip to content

Commit

Permalink
add comment and fix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
miagilepner committed Jan 10, 2025
1 parent fd9ed45 commit 1dc7ba9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions physical/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,16 @@ func (b *RaftBackend) StartRemovedChecker(ctx context.Context) {
for {
select {
case <-ticker.C:
// If the raft cluster has been torn down (which will happen on
// seal) the raft backend will be uninitialized. We want to exit
// the loop in that case. If the cluster unseals, we'll get a
// new backend setup and that will have its own removed checker.

// There is a ctx.Done() check below that will also exit, but
// in most (if not all) places we pass in context.Background()
// to this function. Checking initialization will prevent this
// loop from continuing to run after the raft backend is stopped
// regardless of the context.
if !b.Initialized() {
return
}
Expand Down
3 changes: 3 additions & 0 deletions vault/external_tests/raftha/raft_ha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ func TestRaftHACluster_Removed_ReAdd(t *testing.T) {
if !server.Healthy {
return fmt.Errorf("server %s is unhealthy", serverID)
}
if server.NodeType != "voter" {
return fmt.Errorf("server %s has type %s", serverID, server.NodeType)
}
}
return nil
})
Expand Down

0 comments on commit 1dc7ba9

Please sign in to comment.