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

runtime: rewrite query.go in new protoreflect #1272

Merged
merged 1 commit into from
May 14, 2020
Merged

Conversation

johanbrandhorst
Copy link
Collaborator

Replaces lots of go reflection with protoreflect from APIv2. This is an essential part of rooting out the old API from our packages. Unfortunately, we also lose the capability to support gogoproto stdtime and stdduration types, since they cannot be represented in the new reflection interface.

If you do want to review this, I suggest opening the new file separately, the diff is mostly unhelpful since it's a complete rewrite.

Copy link
Contributor

@dsnet dsnet left a comment

Choose a reason for hiding this comment

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

Changes overall look good to me.

@johanbrandhorst johanbrandhorst force-pushed the rewrite-query-go branch 2 times, most recently from 751ca15 to 8bee367 Compare May 8, 2020 21:39
@johanbrandhorst
Copy link
Collaborator Author

johanbrandhorst commented May 8, 2020

EDIT: worked around this issue by avoiding ptypes.

Seeing a really strange bazel build error:

[396 / 639] 1 / 10 tests; GoCompilePkg external/org_golang_google_grpc/internal/channelz/linux_amd64_race_stripped/go_default_library%/google.golang.org/grpc/internal/channelz.a; 1s processwrapper-sandbox ... (16 actions running)
ERROR: /src/grpc-gateway/runtime/BUILD.bazel:5:1: GoCompilePkg runtime/linux_amd64_race_stripped/go_default_library%/github.com/grpc-ecosystem/grpc-gateway/v2/runtime.a failed (Exit 1) builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64_race -tags race -src runtime/context.go -src runtime/convert.go -src runtime/doc.go -src ... (remaining 77 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
compilepkg: error running subcommand: exit status 2
/root/.cache/_grpc_gateway_bazel/sandbox/processwrapper-sandbox/534/execroot/grpc_ecosystem_grpc_gateway/runtime/query.go:260:12: cannot assign *timestamp.Timestamp to msg (type protoreflect.ProtoMessage) in multiple assignment:
	*timestamp.Timestamp does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
/root/.cache/_grpc_gateway_bazel/sandbox/processwrapper-sandbox/534/execroot/grpc_ecosystem_grpc_gateway/runtime/query.go:272:7: cannot use ptypes.DurationProto(d) (type *duration.Duration) as type protoreflect.ProtoMessage in assignment:
	*duration.Duration does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
/root/.cache/_grpc_gateway_bazel/sandbox/processwrapper-sandbox/534/execroot/grpc_ecosystem_grpc_gateway/runtime/query.go:329:9: undefined: "github.com/golang/protobuf/proto".MessageV2
INFO: Elapsed time: 92.311s, Critical Path: 73.69s

Meanwhile, go build ./... works fine. It's like bazel is using the wrong version of github.com/golang/protobuf (pre-v1.4.0), but repositories.bzl seems to be up to date, so what's going on?

@drigz please help me like you have with all my other bazel issues 😂.

@johanbrandhorst johanbrandhorst force-pushed the rewrite-query-go branch 3 times, most recently from 8dec3ac to 6125843 Compare May 9, 2020 19:22
@johanbrandhorst johanbrandhorst force-pushed the rewrite-query-go branch 2 times, most recently from 945f194 to 279b3b9 Compare May 9, 2020 21:00
@johanbrandhorst
Copy link
Collaborator Author

Great, it's actually not fixed, because now we're getting this error instead:

/root/.cache/_grpc_gateway_bazel/sandbox/processwrapper-sandbox/9/execroot/grpc_ecosystem_grpc_gateway/runtime/query.go:343:9: undefined: "github.com/golang/protobuf/proto".MessageV2

I'll revert the change and go back to ptypes and just wait for the next release of rules_go.

@drigz
Copy link
Contributor

drigz commented May 11, 2020

Did you find https://nullset.xyz/2020/04/20/bazel-go-and-protobufs/? Does it help?

bazel-contrib/rules_go#2395 was closed a week and a half ago, so maybe using rules_go from master is easier than excising uses of the new APIv2.

@johanbrandhorst
Copy link
Collaborator Author

Did you find https://nullset.xyz/2020/04/20/bazel-go-and-protobufs/? Does it help?

bazelbuild/rules_go#2395 was closed a week and a half ago, so maybe using rules_go from master is easier than excising uses of the new APIv2.

Thanks Rodrigo, I took some time to investigate the error and landed on the same conclusion as you. I actually upgraded to rules_go from master to test it, and it does work (the bazel build is now failing for other reasons), but I'm going to back out the change again and simply wait for the next release to drop before merging this.

Thanks again for all your help 😍.

@johanbrandhorst johanbrandhorst force-pushed the rewrite-query-go branch 2 times, most recently from 48701d6 to 02d5e27 Compare May 14, 2020 09:00
@johanbrandhorst johanbrandhorst merged commit 43ced79 into v2 May 14, 2020
@johanbrandhorst johanbrandhorst deleted the rewrite-query-go branch May 14, 2020 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants