-
Notifications
You must be signed in to change notification settings - Fork 21
fix: improve rescan image task to prevent too many requests #501
base: main
Are you sure you want to change the base?
Conversation
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.
Sleeping 3 seconds is too arbitrary.
How about using asyncio.Semaphore
?
Let's rewrite using https://aiolimiter.readthedocs.io/en/latest/ to limit both the number of concurrent requests in a moment and the number requests within a unit period. |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #501 +/- ##
==========================================
- Coverage 48.87% 48.86% -0.01%
==========================================
Files 54 54
Lines 9025 9024 -1
==========================================
- Hits 4411 4410 -1
Misses 4614 4614 see 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
* Also apply different rate limit configs for Docker Hub
We need to make the rate limiter instances persistent to cope with multiple rescan requests. |
This requires the following design to cope with HA setup (multi-node multi-process architecture) of managers:
|
* TODO: we need a per-registry global lock support
If use public docker registry(not stable image in cr.backend.ai), we request info to docker.hub. In execution, docker.hub disconnected our connection for rescan-image task, because too many requests is occured. The following output shows the problem.
So I insert
asyncio.sleep()
in the fetch loop. I solved the problem, But I think that any idea is better than me exists. Welcome any other idea!