-
Notifications
You must be signed in to change notification settings - Fork 39.4k
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 for TestWithMaxWaitRateLimiter test case failure #105312
Fix for TestWithMaxWaitRateLimiter test case failure #105312
Conversation
Hi @Karthik-K-N. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @mkumatag |
/ok-to-test |
/assign @caesarxuchao |
/priority important-soon |
@@ -191,7 +191,7 @@ func TestWithMaxWaitRateLimiter(t *testing.T) { | |||
} | |||
} | |||
|
|||
for i := 100; i < 5100; i++ { | |||
for i := 100; i <= 5100; i++ { |
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.
Hi, @Karthik-K-N, thanks for looking into the flake! I don't think this is enough to fix the flake though. Because the DefaultControllerRateLimiter
uses a real-time clock underneath, if this test gets suspended by the golang scheduler when executing line 195, we can still get a <500s
return value at line 201.
I think instead of using DefaultControllerRateLimiter
, we should make a fake limiter, which returns steadily increasing delay every time When()
is called, and we verify that MaxWaitRateLimiter
respects the 500s maximum even if the fake limiter returns >500s delay.
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 @caesarxuchao for your inputs, I have added a new commit with a simple fake rate limiter which will either return base delay duration or max delay based on the limit set, This will help to test the MaxWaitRateLimiter
. Could you please take a look
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 few nits. Otherwise lgtm. Can you squash the commits?
var _ RateLimiter = &FakeRateLimiter{} | ||
|
||
// FakeControllerRateLimiter is a constructor for a rate limiter for a workqueue. | ||
func FakeControllerRateLimiter(baseDelay, maxDelay time.Duration, limit int) RateLimiter { |
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.
This wrapper function seems redundant. Can we just use NewFakeRateLimiter
?
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.
Removed the wrapper function
@@ -236,3 +236,42 @@ func (w WithMaxWaitRateLimiter) Forget(item interface{}) { | |||
func (w WithMaxWaitRateLimiter) NumRequeues(item interface{}) int { | |||
return w.limiter.NumRequeues(item) | |||
} | |||
|
|||
var _ RateLimiter = &FakeRateLimiter{} |
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.
Let's move these fakes to default_rate_limiters_test.go
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.
Move to default_rate_limiters_test.go file
return &FakeRateLimiter{ | ||
baseDelay: baseDelay, | ||
maxDelay: maxDelay, | ||
limit: limit, |
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.
threshold
sounds more accurate than limit
here.
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.
renamed to threshold
} | ||
} | ||
|
||
type FakeRateLimiter struct { |
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.
How about StepRateLimiter
since the output of this rate limiter is a step function? A more descriptive name gives us space to add other types of fake rate limiters in the future.
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.
Renamed to StepRateLimiter
21f2493
to
7134657
Compare
/lgtm Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: caesarxuchao, Karthik-K-N 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
What this PR does / why we need it:
This PR fixes the rate limiter test case failure
Which issue(s) this PR fixes:
Fixes #105311
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: