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

Enable DefaultHTTPErrorHandler and Upgrade grpc-gateway to v2 #369

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

Jeffwan
Copy link
Collaborator

@Jeffwan Jeffwan commented Jul 10, 2022

Why are these changes needed?

  1. Upgrade grpc-gateway version
  2. Make sure grpc status code can be convert to HTTP code correctly

Related issue number

#364

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@@ -4,14 +4,16 @@ import (
"context"
"flag"

"google.golang.org/protobuf/encoding/protojson"

Copy link
Collaborator

Choose a reason for hiding this comment

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

should run gofmt here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me rerun it

@@ -4,6 +4,8 @@ import (
"context"
"fmt"

"k8s.io/apimachinery/pkg/api/errors"

"github.com/ray-project/kuberay/apiserver/pkg/model"

Copy link
Collaborator

@scarlet25151 scarlet25151 Jul 11, 2022

Choose a reason for hiding this comment

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

nit: need to remove space here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is some fmt issue that goimports and gofmt can not detect. that's why CI pass. I manually update the format and it also works

1. Enable `runtime.DefaultHTTPErrorHandler` to convert gRPC status code to HTTP code.
2. Since we use custom error struct, we need to implement `GRPCStatus` to make sure grpc-go can recognize the error code in our struct,
Otherwise, it will always return codes.Unknown(2), that's the reason we always see code 2 and HTTP 500 in the past.
@Jeffwan
Copy link
Collaborator Author

Jeffwan commented Jul 11, 2022

@scarlet25151 comments addressed. Please take another look

Copy link
Collaborator

@scarlet25151 scarlet25151 left a comment

Choose a reason for hiding this comment

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

LGTM.

@Jeffwan Jeffwan merged commit f4da025 into ray-project:master Jul 11, 2022
@Jeffwan Jeffwan deleted the fix_status_code branch July 11, 2022 17:53
lowang-bh pushed a commit to lowang-bh/kuberay that referenced this pull request Sep 24, 2023
…oject#369)

* Upgrade grpc-gateway to v2

* Customize error and enable DefaultHTTPErrorHandler

1. Enable `runtime.DefaultHTTPErrorHandler` to convert gRPC status code to HTTP code.
2. Since we use custom error struct, we need to implement `GRPCStatus` to make sure grpc-go can recognize the error code in our struct,
Otherwise, it will always return codes.Unknown(2), that's the reason we always see code 2 and HTTP 500 in the past.
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.

2 participants