-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix the flake in scheduling_queue_test #74611
fix the flake in scheduling_queue_test #74611
Conversation
8e40352
to
a7866e4
Compare
/assign @bsalamat |
flushBackoffQ := func() operation { | ||
return func() { | ||
// wait for pod to complete backoff. | ||
time.Sleep(time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you collaborate why this is needed? And it seems to be able to transfer to a more grace solution like channel or wait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Thanks. I transfer to a more grace solution. Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @denkensk for your quick fix. I think we can improve the test further to avoid similar issues in the future and to have better control over test cases. Please see my comment.
flushBackoffQ := func() operation { | ||
return func() { | ||
// wait for pod to complete backoff. | ||
time.Sleep(time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better approach is to use NewPriorityQueueWithClock
instead of NewPriorityQueue
at line 1122 and pass a FakeClock
(k8s.io/apimachinery/pkg/util/clock) to it. You can then control the time with the fake clock, for example by calling its Step
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thank you for your help.
1fbe499
to
1a92402
Compare
Test is ok. PTAL @bsalamat thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @denkensk! Just a couple of minor comments.
}, | ||
expected: []*podInfo{pInfo1, pInfo2}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
queue = NewPriorityQueue(nil) | ||
queue = NewPriorityQueueWithClock(nil, clock.NewFakeClock(time.Now())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.Now() changes every time you read it. In order to have a robust test, please read it once in the beginning of the function and use that time here and for initializing pInfo1
and pInfo2
in lines 1026 and 1030.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Thanks for your advice. Done
flushBackoffQ := func() operation { | ||
return func() { | ||
queue.clock.(*clock.FakeClock).Step(queue.podBackoff.MaxDuration()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to Step
2 seconds here instead of MaxDuration
. That would be a more precise test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thanks
1a92402
to
471679f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Thanks, @denkensk!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, denkensk The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind failing-test
/kind flake
/sig scheduling
What this PR does / why we need it:
seeing a flake in scheduling unit tests - https://storage.googleapis.com/k8s-gubernator/triage/index.html?pr=1&text=Unable%20to%20find%20backoff%20value
Which issue(s) this PR fixes:
Fixes #73700 (comment)