-
Notifications
You must be signed in to change notification settings - Fork 4.7k
BZ 1388319 handle -1 in maxScheduledImageImportsPerMinute #13315
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
Conversation
|
||
var limiter flowcontrol.RateLimiter = nil | ||
if c.Options.ImagePolicyConfig.MaxScheduledImageImportsPerMinute == -1 { | ||
limiter = flowcontrol.NewTokenBucketRateLimiter(math.MaxFloat32, math.MaxInt32) |
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.
THere's an unlimited rate limiter (which is a hardcoded no-op to succeed). Use that instead. Also, you should have <=0, because someone could call this code with 0.
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.
I was looking for something like that and didn't see it. I'll look again.
Any negative number greater that -1 is rejected in ValidateImagePolicyConfig
but I'll change this anyway
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.
NewFakeNeverRateLimiter
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.
heh, I was going to use it but I ignored it because of the "fake" in the name and only saw it being used in tests so I didn't want to shoot myself in the foot. Thanks.
b437825
to
4992e26
Compare
[test] |
Evaluated for origin test up to 4992e26 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/230/) (Base Commit: 0009bfa) |
LGTM [merge] |
Evaluated for origin merge up to 4992e26 |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/104/) (Base Commit: 906adf9) (Image: devenv-rhel7_6072) |
master panics when setting -1 in maxScheduledImageImportsPerMinute though it should be handled. It is specific, validated value and was documented as unlimited.
This checks for -1 and sets the limiter to the
NewFakeAlwaysRateLimiter
. This name is confusing but it looks like it is the one that won't block on accept and is used in tests to turn off limiting@mfojtik @smarterclayton WDYT? The other option, I suppose, is to remove the validation and just have users set this to a very high value themselves.