backport of commit 0ac2fa19aa (#20707)

Co-authored-by: Alexander Scheel <alex.scheel@hashicorp.com>
This commit is contained in:
hc-github-team-secure-vault-core
2023-05-22 15:00:31 -04:00
committed by GitHub
parent 4aff0037d0
commit 9ef24f6487
2 changed files with 14 additions and 9 deletions

View File

@@ -50,15 +50,6 @@ func runUnifiedTransfer(sc *storageContext) {
return
}
if !status.lastRun.IsZero() {
// We have run before, we only run again if we have
// been requested to forceRerun, and we haven't run since our
// minimum delay
if !(status.forceRerun.Load() && time.Since(status.lastRun) < minUnifiedTransferDelay) {
return
}
}
if !config.UnifiedCRL {
// Feature is disabled, no need to run
return
@@ -77,6 +68,17 @@ func runUnifiedTransfer(sc *storageContext) {
}
defer status.isRunning.Store(false)
// Because access to lastRun is not locked, we need to delay this check
// until after we grab the isRunning CAS lock.
if !status.lastRun.IsZero() {
// We have run before, we only run again if we have
// been requested to forceRerun, and we haven't run since our
// minimum delay.
if !(status.forceRerun.Load() && time.Since(status.lastRun) < minUnifiedTransferDelay) {
return
}
}
// Reset our flag before we begin, we do this before we start as
// we can't guarantee that we can properly parse/fix the error from an
// error that comes in from the revoke API after that. This will

3
changelog/20701.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-notes:bug
secrets/pki: Fix race during runUnifiedTransfer when deciding to skip re-running a test within a short window.
```