Skip to content

Commit

Permalink
backport of commit 3c2faf2 (#20040)
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 38affc2 commit 8cb2715
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vault/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type RollbackManager struct {
shutdown bool
shutdownCh chan struct{}
shutdownLock sync.Mutex
stopTicker chan struct{}
quitContext context.Context

core *Core
Expand All @@ -67,6 +68,7 @@ func NewRollbackManager(ctx context.Context, logger log.Logger, backendsFunc fun
inflight: make(map[string]*rollbackState),
doneCh: make(chan struct{}),
shutdownCh: make(chan struct{}),
stopTicker: make(chan struct{}),
quitContext: ctx,
core: core,
}
Expand All @@ -91,6 +93,10 @@ func (m *RollbackManager) Stop() {
m.inflightAll.Wait()
}

func (m *RollbackManager) StopTicker() {
close(m.stopTicker)
}

// run is a long running routine to periodically invoke rollback
func (m *RollbackManager) run() {
m.logger.Info("starting rollback manager")
Expand All @@ -105,6 +111,10 @@ func (m *RollbackManager) run() {
case <-m.shutdownCh:
m.logger.Info("stopping rollback manager")
return

case <-m.stopTicker:
m.logger.Info("stopping rollback manager ticker for tests")
tick.Stop()
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions vault/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,10 @@ func (c *TestClusterCore) stop() error {
return nil
}

func (c *TestClusterCore) StopAutomaticRollbacks() {
c.rollback.StopTicker()
}

func (c *TestClusterCore) GrabRollbackLock() {
// Ensure we don't hold this lock while there are in flight rollbacks.
c.rollback.inflightAll.Wait()
Expand Down

0 comments on commit 8cb2715

Please sign in to comment.