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

Add support for grpc error details and multiple errors #7

Merged
merged 2 commits into from
Aug 16, 2024

Conversation

dmcgowan
Copy link
Member

@dmcgowan dmcgowan commented Jun 6, 2024

When multiple errors are given, use details to encode errors into the grpc status and decode details back into errors.

This allows supporting multiple errdefs as well as any error type which can be marshaled with proto or registered with typeurl.

@dmcgowan dmcgowan changed the title Add support for grpc error details Add support for grpc error details and multiple errors Jun 6, 2024
errgrpc/grpc.go Outdated Show resolved Hide resolved
errgrpc/grpc.go Outdated Show resolved Hide resolved
@dmcgowan dmcgowan force-pushed the grpc-error-details branch 2 times, most recently from 2fd184b to b5a9ec0 Compare June 8, 2024 00:22
@dmcgowan
Copy link
Member Author

dmcgowan commented Jun 8, 2024

Updated and now handles a case where multi-errors get wrapped

@dmcgowan
Copy link
Member Author

Marking this back to draft, #9 should be considered first. We should also consider in the multi-error case using the collapsible errors introduced in the stacks PR.

@dmcgowan dmcgowan marked this pull request as draft June 21, 2024 05:16
@dmcgowan dmcgowan force-pushed the grpc-error-details branch 2 times, most recently from 57fa4b4 to 5596f37 Compare July 2, 2024 23:54
@dmcgowan dmcgowan marked this pull request as ready for review July 2, 2024 23:54
@dmcgowan
Copy link
Member Author

dmcgowan commented Jul 2, 2024

Updated, this is ready to review again.

Included better support for custom error types in the details similar to https://github.com/moby/buildkit/blob/master/util/grpcerrors/grpcerrors.go

The Is interface may be used to resolve if no other unwrap interface is
implemented. This interface is safe to use in this situation, unlike
errors.Is, since the error should not be unwrapped further.

Signed-off-by: Derek McGowan <derek@mcg.dev>
@dmcgowan
Copy link
Member Author

Updated for better resolution of primary error cause and handling of error details.

@AkihiroSuda
Copy link
Member

@stevvooe LGTY?

errgrpc/grpc.go Outdated
if isGRPC {
desc = s.Message()
code = s.Code()

Copy link
Member

Choose a reason for hiding this comment

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

nit: extra empty line

@AkihiroSuda AkihiroSuda requested a review from kzys August 15, 2024 17:11
When multiple errors are given, use details to encode errors into the
grpc status and decode details back into errors.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Copy link
Member

@kzys kzys left a comment

Choose a reason for hiding this comment

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

LGTM!

@AkihiroSuda AkihiroSuda merged commit 70440b8 into containerd:main Aug 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants