-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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): provide wrapping for retried errors #4797
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, if an operation is retried until it times out, we give an error string that covers both the context error and the service error. However, this was implemented before Go 1.13 error wrapping. With this change, the error string stays the same, but we provide wrapping semantics so users can introspect context errors and gRPC/HTTP errors from the returned error.
google-cla
bot
added
the
cla: yes
This human has signed the Contributor License Agreement.
label
Sep 23, 2021
tritone
force-pushed
the
ctx-err-wrap
branch
from
September 23, 2021 17:24
ae1cdf3
to
2a99f7a
Compare
tritone
changed the title
feat(internal): provide wrapping for retried errors [WIP]
feat(internal): provide wrapping for retried errors
Sep 23, 2021
shollyman
approved these changes
Sep 23, 2021
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 wrapping of the real error seems like the big improvement here. I like it.
crwilcox
approved these changes
Sep 23, 2021
codyoss
approved these changes
Sep 23, 2021
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.
LGTM!
crwilcox
approved these changes
Sep 23, 2021
tritone
added
the
automerge
Merge the pull request once unit tests and other checks pass.
label
Sep 23, 2021
gcf-merge-on-green
bot
removed
the
automerge
Merge the pull request once unit tests and other checks pass.
label
Sep 23, 2021
tritone
added a commit
to tritone/google-cloud-go
that referenced
this pull request
Sep 23, 2021
This piggybacks on googleapis#4797 to allow storage to expose wrapped service errors when a call retries without success until timeout or cancellation. I also updated all checks for context sentinel errors in storage to use xerrors.Is instead of strict equality. Users of this package should do the same. I'll update the documentation on errors from this package in a subsequent PR. We will have to bump the dependency on the root module before merging this change I believe. Fixes googleapis#4197
tritone
added a commit
to tritone/google-cloud-go
that referenced
this pull request
Sep 24, 2021
Based on googleapis#4797, we should use xerrors.As for googleapi errors.
tritone
added a commit
to tritone/google-cloud-go
that referenced
this pull request
Sep 24, 2021
Based on googleapis#4797, we should use xerrors.As for googleapi errors.
tritone
added a commit
to tritone/google-cloud-go
that referenced
this pull request
Sep 24, 2021
Fix up type assertions with googleapi.Error to use xerrors.As. In bigquery, this was only required in integration tests and in the package docs. Follows from googleapis#4797 and similar to some of the fixes in storage in googleapis#4802 (storage required additional changes though).
codyoss
pushed a commit
that referenced
this pull request
Sep 27, 2021
Based on #4797, we should use xerrors.As for googleapi errors.
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
Oct 5, 2021
This piggybacks on #4797 to allow storage to expose wrapped service errors when a call retries without success until timeout or cancellation. I also updated all checks for context sentinel errors in storage to use xerrors.Is instead of strict equality. Users of this package should do the same. I'll update the documentation on errors from this package in a subsequent PR. We will have to bump the dependency on the root module before merging this change I believe. Fixes #4197
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This modifies the retry code to allow both context and service errors to be available when the call was retried until hitting a context deadline or cancelation.
This preserves the error string as it is currently put together by internal/annotate; for example a googleapi error from storage looks like this:
object.Attrs: retry failed with context deadline exceeded; last error: googleapi: got HTTP response code 503 with body: {"code":"503","message":{"error":{"message":"Retry Test: Caused a 503"}}}
Go 1.13 error semantics can be used to introspect the underlying context and service errors; here are some examples:
internal.Retry is used by the storage, datastore and bigquery clients, as well as integration tests for compute and pubsub. I want to make sure to check this with everyone affected.