mirror of https://github.com/status-im/consul.git
Move autopilot initialization to prevent race (#5322)
`establishLeadership` invoked during leadership monitoring may use autopilot to do promotions etc. There was a race with doing that and having autopilot initialized and this fixes it.
This commit is contained in:
parent
d7e4151fcb
commit
7073ba4ed2
|
@ -461,6 +461,11 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (*
|
|||
s.Shutdown()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
// Initialize Autopilot. This must happen before starting leadership monitoring
|
||||
// as establishing leadership could attempt to use autopilot and cause a panic.
|
||||
s.initAutopilot(config)
|
||||
|
||||
// Start monitoring leadership. This must happen after Serf is set up
|
||||
// since it can fire events when leadership is obtained.
|
||||
|
@ -477,9 +482,6 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (*
|
|||
// Start the metrics handlers.
|
||||
go s.sessionStats()
|
||||
|
||||
// Initialize Autopilot
|
||||
s.initAutopilot(config)
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue