Unless we've been asked to stop, most failures should not result in (#7732)
waitForLeadership returning.
This commit is contained in:
parent
22ac66c922
commit
9dd18d8487
10
vault/ha.go
10
vault/ha.go
|
@ -387,6 +387,7 @@ func (c *Core) runStandby(doneCh, manualStepDownCh, stopCh chan struct{}) {
|
|||
// active.
|
||||
func (c *Core) waitForLeadership(newLeaderCh chan func(), manualStepDownCh, stopCh chan struct{}) {
|
||||
var manualStepDown bool
|
||||
var firstIteration = true
|
||||
for {
|
||||
// Check for a shutdown
|
||||
select {
|
||||
|
@ -399,19 +400,24 @@ func (c *Core) waitForLeadership(newLeaderCh chan func(), manualStepDownCh, stop
|
|||
if manualStepDown {
|
||||
time.Sleep(manualStepDownSleepPeriod)
|
||||
manualStepDown = false
|
||||
} else if !firstIteration {
|
||||
// If we restarted the for loop due to an error, wait a second
|
||||
// so that we don't busy loop if the error persists.
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
firstIteration = false
|
||||
|
||||
// Create a lock
|
||||
uuid, err := uuid.GenerateUUID()
|
||||
if err != nil {
|
||||
c.logger.Error("failed to generate uuid", "error", err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
lock, err := c.ha.LockWith(CoreLockPath, uuid)
|
||||
if err != nil {
|
||||
c.logger.Error("failed to create lock", "error", err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
// Attempt the acquisition
|
||||
|
|
Loading…
Reference in New Issue