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

fix(internal/retry): Simplify gRPC status code mapping of retry error #8196

Merged

Conversation

atollena
Copy link
Contributor

@atollena atollena commented Jul 3, 2023

gRPC v1.55.0 that this project depends on came with a change in semantic for status.FromError such that the gRPC status of wrapped errors is returned. The implementation of GRPCStatus in internal/retry code was doing just that. Removing GRPCStatus entirely makes the code much easier to understand: at the moment, status.FromError calls GRPCStatus which in turns calls status.FromError and it's not immediately obvious why this can't result in infinite recursion.

A previous change I made to this code made sure this method never returns Status.OK (#8128), but I failed to realize that since this project depends on gRPC 1.55 that already handles wrapped errors in status.FromError, we can simply remove the implementation of GRPCStatus and let gRPC status.FromError handle unwrapping.

Note that I barely had to change the tests, but there IS a slight change in behavior: the message of the wrapping error is included in the gRPC error. I think it's fine, bet let me know if you think otherwise (for the same reasons discussed in grpc/grpc-go#6150).

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Jul 3, 2023
@atollena
Copy link
Contributor Author

atollena commented Jul 3, 2023

Thanks to @dfawley for suggesting this here: grpc/grpc-go#6374 (comment)

@atollena atollena force-pushed the antoine/simplify-retry-error branch from 800df30 to 017c367 Compare July 3, 2023 07:51
@conventional-commit-lint-gcf
Copy link

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

gRPC v1.55.0 with a change in semantic for status.FromError such that the gRPC status of wrapped
errors is returned when defined. The implementation of GRPCStatus in internal/retry code was doing
just that. Removing GRPCStatus entirely makes the code much easier to understand: at the moment,
status.FromError calls GRPCStatus which in turns calls status.FromError and it's not immediately
obvious why this cannot result in infinite recursion.

A previous change I made to this code made sure this method never returns
status Code.OK (googleapis#8128), but I failed to realize that
since this project depends on gRPC 1.55 that already handles wrapped errors in status.FromError, we
can simply remove the implementation of `GRPCStatus` and let gRPC status.FromError handle
unwrapping.

Note that I barely had to change the tests, but there *IS* a slight change in behavior: the message
of the wrapping error is included in the gRPC error. I think it's fine, bet let me know if you think
otherwise (for the same reasons discussed in grpc/grpc-go#6150).
@atollena atollena force-pushed the antoine/simplify-retry-error branch from 017c367 to 6a7ac3a Compare July 3, 2023 07:53
@atollena atollena changed the title [internal/retry] Simplify gRPC status code mapping of retry error fix(internal/retry): Simplify gRPC status code mapping of retry error Jul 3, 2023
@atollena atollena marked this pull request as ready for review July 3, 2023 08:39
@atollena atollena requested a review from a team as a code owner July 3, 2023 08:39
@noahdietz
Copy link
Contributor

I think this would be fine to do. I'm hoping that folks aren't matching error strings anymore at this point, and instead using errors.Is. Thank you again @atollena

@codyoss any concerns?

@noahdietz noahdietz self-assigned this Jul 5, 2023
@codyoss
Copy link
Member

codyoss commented Jul 5, 2023

@noahdietz nope seems fine to me as well. Error strings are undefined behavior in my eyes -- at least for this instance.

@noahdietz
Copy link
Contributor

noahdietz commented Jul 5, 2023

@atollena I'm updating your branch and will get it merged. I'll wait until the continuous integration tests pass upon merging to cut a release, but will ping you on the release when it happens.

@noahdietz noahdietz added the automerge: exact Summon MOG for automerging, but approvals need to be against the latest commit label Jul 5, 2023
@noahdietz noahdietz added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 5, 2023
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 5, 2023
@gcf-merge-on-green gcf-merge-on-green bot merged commit e8b224a into googleapis:main Jul 5, 2023
8 checks passed
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge: exact Summon MOG for automerging, but approvals need to be against the latest commit label Jul 5, 2023
@atollena
Copy link
Contributor Author

atollena commented Jul 6, 2023

Thank you for merging.

@atollena atollena deleted the antoine/simplify-retry-error branch July 6, 2023 14:36
gcf-merge-on-green bot pushed a commit that referenced this pull request Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants