Skip to content

Commit

Permalink
Ensure that Autopilot sees all nodes in KnownServers at outset (#24246)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff authored Dec 4, 2023
1 parent 85b3dba commit 31ccb26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelog/24246.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
storage/raft: Fix a race whereby a new leader may present inconsistent node data to Autopilot.
```
21 changes: 12 additions & 9 deletions vault/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,6 @@ func (c *Core) setupRaftActiveNode(ctx context.Context) error {
c.logger.Info("starting raft active node")
raftBackend.SetEffectiveSDKVersion(c.effectiveSDKVersion)

autopilotConfig, err := c.loadAutopilotConfiguration(ctx)
if err != nil {
c.logger.Error("failed to load autopilot config from storage when setting up cluster; continuing since autopilot falls back to default config", "error", err)
}
disableAutopilot := c.disableAutopilot

raftBackend.SetupAutopilot(c.activeContext, autopilotConfig, c.raftFollowerStates, disableAutopilot)

c.pendingRaftPeers = &sync.Map{}

// Reload the raft TLS keys to ensure we are using the latest version.
Expand All @@ -334,7 +326,18 @@ func (c *Core) setupRaftActiveNode(ctx context.Context) error {
if err := c.monitorUndoLogs(); err != nil {
return err
}
return c.startPeriodicRaftTLSRotate(ctx)

if err := c.startPeriodicRaftTLSRotate(ctx); err != nil {
return err
}

autopilotConfig, err := c.loadAutopilotConfiguration(ctx)
if err != nil {
c.logger.Error("failed to load autopilot config from storage when setting up cluster; continuing since autopilot falls back to default config", "error", err)
}
disableAutopilot := c.disableAutopilot
raftBackend.SetupAutopilot(c.activeContext, autopilotConfig, c.raftFollowerStates, disableAutopilot)
return nil
}

func (c *Core) stopRaftActiveNode() {
Expand Down

0 comments on commit 31ccb26

Please sign in to comment.