Skip to content

Commit be127c2

Browse files
authored
Allow periodicFunc to execute "now" (openbao#1129)
* Small mainline code change for flakey test -- allow periodicFunc to fire if it is exactly the time to run Signed-off-by: Geoff Wilson <[email protected]> * Add changelog Signed-off-by: Geoff Wilson <[email protected]> --------- Signed-off-by: Geoff Wilson <[email protected]>
1 parent 5092363 commit be127c2

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

changelog/1129.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
vault: addresses a timing issue revealed in OIDC_PeriodicFunc test
3+
```

vault/identity_store_oidc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ func (i *IdentityStore) oidcPeriodicFunc(ctx context.Context) {
20002000
// be run at any time safely, but there is no need to invoke them (which
20012001
// might be somewhat expensive if there are many roles/keys) if we're not
20022002
// past any rotation/expiration TTLs.
2003-
if now.After(nextRun) {
2003+
if now.Equal(nextRun) || now.After(nextRun) {
20042004
// Initialize to a fairly distant next run time. This will be brought in
20052005
// based on key rotation times.
20062006
nextRun = now.Add(24 * time.Hour)

vault/identity_store_oidc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ func TestOIDC_PeriodicFunc(t *testing.T) {
11371137
i := 0
11381138
for currentCycle <= lastCycle {
11391139
// sleep for a rotation period
1140-
time.Sleep(testSet.namedKey.RotationPeriod + (10 * time.Millisecond))
1140+
time.Sleep(testSet.namedKey.RotationPeriod)
11411141
c.identityStore.oidcPeriodicFunc(ctx)
11421142
if currentCycle == testSet.testCases[i].cycle {
11431143
namedKeyEntry, _ := storage.Get(ctx, namedKeyConfigPath+testSet.namedKey.name)

0 commit comments

Comments
 (0)