Skip to content

Commit

Permalink
backport of commit 871bf52 (hashicorp#20063)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Scheel <alex.scheel@hashicorp.com>
  • Loading branch information
1 parent 4308cb2 commit 95af348
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vault/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func (m *RollbackManager) Stop() {
m.inflightAll.Wait()
}

// StopTicker stops the automatic Rollback manager's ticker, causing us
// to not do automatic rollbacks. This is useful for testing plugin's
// periodic function's behavior, without trying to race against the
// rollback manager proper.
//
// THIS SHOULD ONLY BE CALLED FROM TEST HELPERS.
func (m *RollbackManager) StopTicker() {
close(m.stopTicker)
}
Expand All @@ -101,6 +107,7 @@ func (m *RollbackManager) StopTicker() {
func (m *RollbackManager) run() {
m.logger.Info("starting rollback manager")
tick := time.NewTicker(m.period)
logTestStopOnce := false
defer tick.Stop()
defer close(m.doneCh)
for {
Expand All @@ -113,7 +120,10 @@ func (m *RollbackManager) run() {
return

case <-m.stopTicker:
m.logger.Info("stopping rollback manager ticker for tests")
if !logTestStopOnce {
m.logger.Info("stopping rollback manager ticker for tests")
logTestStopOnce = true
}
tick.Stop()
}
}
Expand Down

0 comments on commit 95af348

Please sign in to comment.