Skip to content
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

Merged

Conversation

pcrespov
Copy link
Member

What do these changes do?

How to test

cd services/web/server
make install-dev
pytest -vv tests/unit/isolated/test_utils_rate_limiting.py

@pcrespov pcrespov self-assigned this Sep 21, 2022
@pcrespov pcrespov added this to the vaporwave milestone Sep 21, 2022
@pcrespov pcrespov marked this pull request as ready for review September 21, 2022 11:42
@codecov
Copy link

codecov bot commented Sep 21, 2022

Codecov Report

Merging #3379 (4c100c7) into master (4fc72ac) will decrease coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           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             
Flag Coverage 螖
integrationtests 68.6% <77.7%> (-0.1%) 猬囷笍
unittests 79.8% <100.0%> (-0.1%) 猬囷笍

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage 螖
...c/simcore_service_webserver/utils_rate_limiting.py 100.0% <100.0%> (酶)
...ector_v2/modules/comp_scheduler/background_task.py 87.5% <0.0%> (-8.4%) 猬囷笍
.../simcore_service_catalog/db/repositories/groups.py 64.8% <0.0%> (-8.2%) 猬囷笍
...rector_v2/modules/comp_scheduler/base_scheduler.py 91.1% <0.0%> (-1.3%) 猬囷笍
...tor_v2/modules/dynamic_sidecar/scheduler/_utils.py 89.6% <0.0%> (-1.2%) 猬囷笍
...imcore_service_webserver/garbage_collector_core.py 62.0% <0.0%> (-0.7%) 猬囷笍
.../director/src/simcore_service_director/producer.py 67.3% <0.0%> (-0.3%) 猬囷笍
...rvice_datcore_adapter/utils/requests_decorators.py 83.7% <0.0%> (+8.1%) 猬嗭笍

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤

@pcrespov pcrespov force-pushed the fix/rate-limit-retry-after-header branch from 738a06c to 5f98f3f Compare September 21, 2022 18:29
Copy link
Member

@sanderegg sanderegg left a 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))
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

@pcrespov pcrespov Sep 21, 2022

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

@sonarcloud
Copy link

sonarcloud bot commented Sep 21, 2022

Kudos, SonarCloud Quality Gate passed!聽 聽 Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@pcrespov pcrespov merged commit fef0500 into ITISFoundation:master Sep 21, 2022
@pcrespov pcrespov deleted the fix/rate-limit-retry-after-header branch September 21, 2022 21:46
@elisabettai
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants