Commit 4e8e4a57 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #25636 from zhouhaibing089/delnode-fix

Automatic merge from submit-queue use monotonic now in TestDelNode Fixes https://github.com/kubernetes/kubernetes/issues/24971. Briefly, the rate_limited_queue uses a `container/heap` to store values, and use this data structure to ensure we can always fetch the value with the minimum `processAt`. However, in some extreme condition, the continuous call to `time.Now()` would get the same value, which causes some unpredictable order in the queue, this fix uses a monotonic `now()` to avoid that. @smarterclayton please take a look.
parents 025b0172 af3e2357
...@@ -62,6 +62,13 @@ func TestAddNode(t *testing.T) { ...@@ -62,6 +62,13 @@ func TestAddNode(t *testing.T) {
} }
func TestDelNode(t *testing.T) { func TestDelNode(t *testing.T) {
defer func() { now = time.Now }()
var tick int64
now = func() time.Time {
t := time.Unix(tick, 0)
tick++
return t
}
evictor := NewRateLimitedTimedQueue(flowcontrol.NewFakeAlwaysRateLimiter()) evictor := NewRateLimitedTimedQueue(flowcontrol.NewFakeAlwaysRateLimiter())
evictor.Add("first") evictor.Add("first")
evictor.Add("second") evictor.Add("second")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment