We import package ratelimit in Kubernetes and met a scenario, not sure whether the issue should be filed here.
The scenario is that when time happened moves backwards for any reason, func take that calculate the time to sleep would get a huge number here:
endTick := currentTick + (-avail+tb.quantum-1)/tb.quantum
endTime := tb.startTime.Add(time.Duration(endTick) * tb.fillInterval)
waitTime := endTime.Sub(now)
if waitTime > maxWait {
return 0, false
}
An available way for the issue might be adding a protection before calculating waitTime, say a comparision between now and startTime.
/cc @thockin