-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add support for dockerhub rate-limiting #19984
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.
this is a great contribution. thank you very much.. We need to give it a test
Head branch was pushed to by a user without write access
Thank you too, I just sqished some style related bugs, we'll see how it goes now. |
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.
fixed/explained in Fix: review - ...
commits.
bd59e2d
to
55be54b
Compare
cc483a2
to
b443030
Compare
|
701420e
to
43f6e95
Compare
Fixed, 'retry' is now used ONLY when last response was 429 and we waited. |
From the perspective of Harbor core, adding retry would result in more GET or HEAD requests to the upstream Docker registry, potentially increasing the chances of hitting rate limits. Personally, I believe it's better to fail early and inform the client of the failure ASAP. This allows the client to decide whether to implement retry on their end. Hiding the retry functionality on the server side would inevitably increase response time, which could lead to timeouts for some clients. This approach doesn't seem practical to me. |
d1a4f00
to
4ee91bf
Compare
d366a14
to
5e8ecfc
Compare
Signed-off-by: Jiri Vrba <[email protected]>
Is there anybody to help me with this PR? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19984 +/- ##
==========================================
- Coverage 67.56% 66.22% -1.34%
==========================================
Files 991 1045 +54
Lines 109181 113531 +4350
Branches 2719 2845 +126
==========================================
+ Hits 73768 75188 +1420
- Misses 31449 34234 +2785
- Partials 3964 4109 +145
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@wy65701436 can we get some indication for @Grimm75 in what direction to move? |
This PR is being marked stale due to a period of inactivty. If this PR is still relevant, please comment or remove the stale label. Otherwise, this PR will close in 30 days. |
Hey @wy65701436 @stonezdj can you check that please! |
@Grimm75, we are ready to go. Can you add a test to your function, to bump up the codecov? |
// - Allows 2 more attempts before giving up. | ||
// Reason: Observed (02/2024) penalty for hitting the limit is 120s, normal reset is 60s, | ||
// so it is better to not hit the wall. | ||
func (a *adapter) limitAwareDo(method string, path string, body io.Reader) (*http.Response, error) { |
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.
- The PR is not complete yet, as there are some missing test cases and the low test coverage. It is blocked from merging.
- In addition, I find there is too much logging into info, We can put all in debug, especially since we now can handle the rate limit there is nothing to info about.
- I would allow one info statement, when we reach/hit the limit. Other information is relevant for debut only.
I believe we should avoid implementing hidden retry logic on the server side, and I’ve shared my personal opinion on this matter. @Vad1mo @OrlinVasilev We can discuss this in the community meeting if you think it's necessary.
|
Add support for dockerhub API rate-limiting
Added function which wraps around
client.Do()
and:retry-after
header.appropriately if rate-limit depletion is eminent.
And replaced calls to
client.Do()
with wrapped one.See:
https://docs.docker.com/docker-hub/api/latest/#tag/rate-limiting
PS: Above docs are incorrect about
x-retry-after
header -name
andcontent
doesn't match observed headers from dockerhub, which areretry-after
(withoutx-
) and content is positive integer - number of seconds to wait, conforming to RFC9110 10.2.3.Issue being fixed
Fixes #19967
Please indicate you've done the following: