rate limit: fix initialize defaults (#10536)
This commit is contained in:
parent
058532406b
commit
3bce568535
|
@ -0,0 +1,4 @@
|
|||
```release-note:bug
|
||||
core: Fix rate limit resource quota migration from 1.5.x to 1.6.x by ensuring `purgeInterval` and
|
||||
`staleAge` are set appropriately.
|
||||
```
|
|
@ -138,6 +138,17 @@ func (rlq *RateLimitQuota) initialize(logger log.Logger, ms *metricsutil.Cluster
|
|||
rlq.ID = id
|
||||
}
|
||||
|
||||
// Set purgeInterval if coming from a previous version where purgeInterval was
|
||||
// not defined.
|
||||
if rlq.purgeInterval == 0 {
|
||||
rlq.purgeInterval = DefaultRateLimitPurgeInterval
|
||||
}
|
||||
|
||||
// Set staleAge if coming from a previous version where staleAge was not defined.
|
||||
if rlq.staleAge == 0 {
|
||||
rlq.staleAge = DefaultRateLimitStaleAge
|
||||
}
|
||||
|
||||
rlStore, err := memorystore.New(&memorystore.Config{
|
||||
Tokens: uint64(math.Round(rlq.Rate)), // allow 'rlq.Rate' number of requests per 'Interval'
|
||||
Interval: rlq.Interval, // time interval in which to enforce rate limiting
|
||||
|
|
Loading…
Reference in New Issue