mirror of
https://github.com/hashicorp/vault.git
synced 2026-06-11 09:51:16 -04:00
Only log stopping rollback manager once (#20041)
When testing the Rollback Manager's one-time invocation in Enterprise, it was noticed that due to the channel being closed, we'd always hit this case and thus spam logs rather quickly with this message. Switch to a boolean flip to log this once, as it is not executed in parallel and thus doesn't need a sync.Once. This only affected anyone calling the test core's StopAutomaticRollbacks() helper. Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
This commit is contained in:
parent
211fd80f68
commit
871bf52c61
1 changed files with 11 additions and 1 deletions
|
|
@ -96,6 +96,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)
|
||||
}
|
||||
|
|
@ -104,6 +110,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 {
|
||||
|
|
@ -116,7 +123,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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue