-
Notifications
You must be signed in to change notification settings - Fork 26
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Fixes Retry-After
header in global_rate_limit_route
#3379
馃悰 Fixes Retry-After
header in global_rate_limit_route
#3379
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3379 +/- ##
========================================
- Coverage 83.0% 83.0% -0.1%
========================================
Files 811 811
Lines 34410 34416 +6
Branches 1358 1358
========================================
- Hits 28570 28567 -3
- Misses 5659 5668 +9
Partials 181 181
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
馃憤
738a06c
to
5f98f3f
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.
not sure I understand why we do not use an external rate limiter, but it was already there I guess.
t1 = time.time() | ||
futures.append(asyncio.create_task(client.get("/"))) | ||
tasks.append(asyncio.create_task(client.get("/"))) | ||
time.sleep(time_between_requests - (time.time() - t1)) |
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.
Question: why sync sleep instead of asyncio 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.
not sure I understand why we do not use an external rate limiter, but it was already there I guess.
Yes it was there already. This is just a fix and some cleanup
@sanderegg Is there a way to rate limit specific entrypoints in our reverse proxy? If so, perhaps we could create a maintenance issue and add it.
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.
Question: why sync sleep instead of asyncio here?
It was already there ... it paces the rate in which it hits the entrypoint ... but on second thoughts, if the tasks does not execute, the time.sleep
will block it and might cause flaky test . I will change it Did not work, not sure why ... left a note for a more illuminating moment
Kudos, SonarCloud Quality Gate passed!聽 聽 0 Bugs No Coverage information |
@pcrespov, description of this one (or title) could be made more clear. ;) But I leave it up to decide if you want to change it. |
What do these changes do?
Retry-After
header in global_rate_limit_routeRetry-After
is a relative time in secs, not absolute: see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429How to test
cd services/web/server make install-dev pytest -vv tests/unit/isolated/test_utils_rate_limiting.py