mirror of https://github.com/minio/minio.git
run IAM purge routines deterministically every hr (#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.
This commit is contained in:
parent
f85c28e960
commit
c4239ced22
|
@ -406,6 +406,7 @@ func (sys *IAMSys) periodicRoutines(ctx context.Context, baseInterval time.Durat
|
||||||
timer := time.NewTimer(waitInterval())
|
timer := time.NewTimer(waitInterval())
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
|
|
||||||
|
lastPurgeHour := -1
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
|
@ -421,9 +422,9 @@ func (sys *IAMSys) periodicRoutines(ctx context.Context, baseInterval time.Durat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following actions are performed about once in 4 times that
|
// Run purge routines once in each hour.
|
||||||
// IAM is refreshed:
|
if refreshStart.Hour() != lastPurgeHour {
|
||||||
if r.Intn(4) == 0 {
|
lastPurgeHour = refreshStart.Hour()
|
||||||
// Poll and remove accounts for those users who were removed
|
// Poll and remove accounts for those users who were removed
|
||||||
// from LDAP/OpenID.
|
// from LDAP/OpenID.
|
||||||
if sys.LDAPConfig.Enabled() {
|
if sys.LDAPConfig.Enabled() {
|
||||||
|
|
Loading…
Reference in New Issue