Skip to content

Commit c4239ce

Browse files
authored
run IAM purge routines deterministically every hr (minio#20587)
Existing implementation runs IAM purge routines for expired LDAP and OIDC accounts with a probability of 0.25 after every IAM refresh. This change ensures that they are run once in each hour.
1 parent f85c28e commit c4239ce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/iam.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ func (sys *IAMSys) periodicRoutines(ctx context.Context, baseInterval time.Durat
406406
timer := time.NewTimer(waitInterval())
407407
defer timer.Stop()
408408

409+
lastPurgeHour := -1
409410
for {
410411
select {
411412
case <-timer.C:
@@ -421,9 +422,9 @@ func (sys *IAMSys) periodicRoutines(ctx context.Context, baseInterval time.Durat
421422
}
422423
}
423424

424-
// The following actions are performed about once in 4 times that
425-
// IAM is refreshed:
426-
if r.Intn(4) == 0 {
425+
// Run purge routines once in each hour.
426+
if refreshStart.Hour() != lastPurgeHour {
427+
lastPurgeHour = refreshStart.Hour()
427428
// Poll and remove accounts for those users who were removed
428429
// from LDAP/OpenID.
429430
if sys.LDAPConfig.Enabled() {

0 commit comments

Comments
 (0)