-
Notifications
You must be signed in to change notification settings - Fork 10
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
[WIP] Handle errors #44
Conversation
da3667d
to
789410c
Compare
Do you need this? they should be independent as you work at transport level. I mean if this is ready, I won't wait for #49.
AFAIS We already have unittests, let's open a different issue for integration tests, also maybe @kyrcha could take care of it.
AFAIR there was already a fix for this in ghsync. |
I have reproduced (I think) all of the possible HTTP codes:
for this issue #40 so tests will be added for such matters. |
c7d5921
to
00086cf
Compare
@se7entyse7en Yes, the rebase over #49 is needed; i.e. it's also causing the current conflict. @se7entyse7en No, the issue about the ruined body was not added in |
Its RoundTrip method will return ErrRateLimit or ErrAbuseRateLimit if any of these API limits are reached. Signed-off-by: David Pordomingo <[email protected]>
- document it - ensure it does not return errors but the ones from Transport.RoundTrip - retry also 500 errors - log last error and the number of retries Signed-off-by: David Pordomingo <[email protected]>
And enhance how the Transport are added Signed-off-by: David Pordomingo <[email protected]>
Since the Request.Body and Response.Body are read from any transport.RoundTrip, it is needed to restore them before reusing it again; otherwise, the Request.Body or Response.Body won't be readable. Signed-off-by: David Pordomingo <[email protected]>
00086cf
to
ee869d8
Compare
. |
I'll create a new PR from an upstream branch |
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 will wait for the new PR for the rest
out []string | ||
} | ||
|
||
func (l *LoggerMock) First() string { |
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.
First
or better Pop
?
|
||
"github.com/src-d/metadata-retrieval/utils" |
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.
According to previous reviews by @lwsanty the metadata-retrieval variables should be in the middle. I am guessing it is better if we build a linter for that matter.
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.
Thanks. Will do.
depends on #49 [implement MultiToken]
fix #3 [handle RateLimit errors]
fix #18 [handle Abuse errors]
TODO
Retry
+RateLimit
(Could be added in a new PR, or also in this PR)Changes grom
ghsync
github.RetryTransport
, not bygithub.RateLimitTransport
Also needed:
retryTransport
:Transport.RoundTrip
Response
&Request
when read fromTransport
Request.Body
andResponse.Body
are read from anytransport.RoundTrip
,it is needed to restore them before reusing it again;
otherwise, their
Body
won't be readable from other nestedTransport
.How does it work?
Trying to fetch an
org
with a GH token under anAbuseRateLimmit
block, whosequota
also expired:github.Downloader
tries to get the data, but GH answers with n403, AbuseRateLimmit
,github.RateLimitTransport
, and the lock is enabled for the time specified by the headers from the403, AbuseRateLimmit
; the error is bubbled upgithub.RetryTransport
, and retriedgithub.RateLimitTransport
is locked, so it sleeps till the lock expires.AbuseRateLimmit
will disappear, but in this example, it appeared aRateLimmit
for that same query which is intercepted again bygithub.RateLimitTransport
, and the lock is enabled again for the time specified by the headers from the200, StatusOk
; the error is bubbled upgithub.RetryTransport
, and retriedgithub.RateLimitTransport
is locked, so it sleeps till the lock expires.