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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(internal/gensupport): add configurable retry #1324

Merged
merged 10 commits into from Dec 13, 2021

Conversation

tritone
Copy link
Contributor

@tritone tritone commented Dec 1, 2021

Extend SendAndRetryRequest to allow retry options (backoff and
ErrorFunc) to be passed in. Add a surface to the generated code
for storage to allow the manual layer to choose whether the request
is retried.

Idempotency considerations will be handled at the manual layer.

I tested this out via the manual layer by verifying that the
ObjectsInsertCall only retries now when WithRetry() is applied.

I still need to update the generator to ensure that the changes in
the generated file will persist and probably add some tests as well.
Thought I'd try and get an initial review first.

Extend SendAndRetryRequest to allow retry options (backoff and
ErrorFunc) to be passed in. Add a surface to the generated code
for storage to allow the manual layer to choose whether the request
is retried.

I tested this out via the manual layer by verifying that the
ObjectsInsertCall only retries now when WithRetry() is applied.

I still need to update the generator to ensure that the changes in
the generated file will persist and probably add some tests as well.
Thought I'd try and get an initial review first.
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 1, 2021
@tritone tritone requested review from codyoss, noahdietz and a team December 1, 2021 06:34
tritone added a commit to tritone/google-cloud-go that referenced this pull request Dec 9, 2021
@tritone tritone marked this pull request as ready for review December 9, 2021 22:56
@tritone tritone requested review from yoshi-approver and a team as code owners December 9, 2021 22:56
Copy link
Contributor

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

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

Seems fine to me, but I'll let @codyoss approve.

google-api-go-generator/gen.go Outdated Show resolved Hide resolved
Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

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

LGTM, just one main question on retries for resumable upload in general

"which errors are considered retryable. By default, exponetial backoff will be" +
"applied using gax defaults, and the following errors are retried:" +
"\n\n" +
"- HTTP responses with codes 429, 502, 503, and 504." +
Copy link
Member

Choose a reason for hiding this comment

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

Could the error codes be pulled from gax instead of string literals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seeing as this is just a one-off comment and these values are not likely to change, I don't think it's work adding extra complexity to the templating in order to accomplish this.

@@ -50,7 +52,7 @@ func send(ctx context.Context, client *http.Client, req *http.Request) (*http.Re
// If ctx is non-nil, it calls all hooks, then sends the request with
// req.WithContext, then calls any functions returned by the hooks in
// reverse order.
func SendRequestWithRetry(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {
func SendRequestWithRetry(ctx context.Context, client *http.Client, req *http.Request, retry *RetryConfig) (*http.Response, error) {
Copy link
Member

Choose a reason for hiding this comment

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

The only thing I think will be an issue is that the remote offset is not considered in the case Storage has progressed and the client is now unaligned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that work will have to come in a separate PR. This PR doesn't change the mechanics of the resumption strategy.

Copy link
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@tritone tritone merged commit 8d2eca8 into googleapis:main Dec 13, 2021
@tritone tritone deleted the write-retry branch December 13, 2021 20:48
tritone added a commit to tritone/google-cloud-go that referenced this pull request Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants