grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

Update proto package imports to google.golang.org/protobuf/proto

Open delgec opened this issue 2 years ago • 13 comments

Hello everyone

Why is this dependency not removed?

It's deprecated and we are constantly receiving warnings in the our applications.

github.com/golang/protobuf v1.5.2

delgec avatar Apr 21 '22 13:04 delgec

We looked into this migration a year or two ago, but it's a non-trivial amount of work (due to the API changes) for a relatively small benefit (it's been rewritten internally to use the new library already).

dfawley avatar Apr 21 '22 21:04 dfawley

This was discussed in #5110

menghanl avatar Apr 21 '22 21:04 menghanl

...which was a dupe of #3554

I think we should have an issue for this open, but we have no upcoming plans to do anything here.

dfawley avatar Apr 21 '22 22:04 dfawley

I tried to remove all references to github.com/golang/protobuf, but stuck with the file testv3.pb.go in reflection/grpc_testing_not_regenerate, it's said that we should not regenerate the pb inside that package... I only came up with several possible solutions:

  • turn grpc_testing_not_regenerate into sub-module, but with this approach we need to add a replace directive to the root go.mod to enable go mod tidy
  • make reflection package pure of testing by moving all test code to the root test directory, but I think this will still cause the root module requires github.com/golang/protobuf

wdyt?

gunturaf avatar Apr 28 '22 04:04 gunturaf

FWIW I created https://github.com/golang/protobuf/issues/1442 so we can try to get a non-deprecated way of maintaining our existing API.

dfawley avatar May 10 '22 17:05 dfawley

Is there a path forward now that https://github.com/golang/protobuf/issues/1442 has been resolved? I may be able to contribute.

chriscasola avatar Apr 21 '23 20:04 chriscasola

@chriscasola : Please feel free to send us a PR. But please do keep in mind that old proto package is part of some of our APIs, and some of them are not marked experimental, and therefore cannot be changed.

easwars avatar Sep 19 '23 17:09 easwars

The worst thing out of this transition is this part of channelz/service/service_test.go. In order to be able to switch to google.golang.org/protobuf/proto It seems we somehow need to implement protoreflect.ProtoMessage and thus implement the following function by hand:

func (m *OtherSecurityValue) ProtoReflect() protoreflect.Message { return /*TBD*/ }

if anyone knows how to make OtherSecurityValue implement protoreflect.ProtoMessage properly, let me know because I'm almost done switching everything to google.golang.org/protobuf/proto (at least go test ./... says so).

Also, @easwars, I'm interested in knowing which APIs cannot be changed because old proto is part of them.

Clement-Jean avatar Oct 03 '23 08:10 Clement-Jean

Also, @easwars, I'm interested in knowing which APIs cannot be changed because old proto is part of them.

The last time we undertook this exercise, I vaguely remember the old proto package being part of some non-experimental APIs. But now:

easwars@minetop: grpc-go$ grep -r "github.com/golang/protobuf/proto" * | grep -v test | grep -v internal | grep -v examples
balancer/grpclb/grpclb_remote_balancer.go:      "github.com/golang/protobuf/proto"
credentials/credentials.go:     "github.com/golang/protobuf/proto"
encoding/proto/proto.go:        "github.com/golang/protobuf/proto"

The reference to the old proto package in:

  • grpclb: this is not part of the API. this is just a call to proto.Equal
  • credentials: there is a field of type proto.Message in OtherChannelzSecurityValue. But this is marked experimental
  • proto: this is the implementation of the proto encoder. Here also, it is not part of the API. I believe we can switch to the new proto package here.

easwars avatar Oct 06 '23 21:10 easwars

The worst thing out of this transition is this part of channelz/service/service_test.go

@dfawley is working on a major rewrite of the channelz implementation. He might have some ideas here.

easwars avatar Oct 06 '23 21:10 easwars

I removed the P3 label so that we track this in our weekly meeting to see if we can make progress.

easwars avatar Oct 13 '23 15:10 easwars

The worst thing out of this transition is this part of channelz/service/service_test.go.

Please just leave this part alone for now. I've rewritten these tests to not convert away from proto before checking the result; instead it builds the expected proto response and validates the actual response directly against the expectation.

I'm almost done switching everything to google.golang.org/protobuf/proto (at least go test ./... says so).

Woah that's great to hear! I'll assign this issue to you for now.

The part of proto that's in our API is the status package, around Details. With golang/protobuf#1442 resolved, we should have an alternative to use now instead of proto.Message.

dfawley avatar Oct 17 '23 18:10 dfawley

https://github.com/grpc/grpc-go/pull/6736 -- in flight to take a first pass at fixing the dependency

arvindbr8 avatar Oct 20 '23 21:10 arvindbr8

Thanks for the PRs @Clement-Jean . IIUC the only remaining thing is channelz, which is blocked on #6969.

dfawley avatar Mar 05 '24 18:03 dfawley

#6969 is closed now. @dfawley should this go forward?

pavelpatrin avatar Mar 20 '24 17:03 pavelpatrin

Yes, I think we're all clear now to finish it.

Unfortunately, it looks like we'll still keep the dependency in perpetuity because of testing in https://github.com/grpc/grpc-go/blob/cce163274b6cb9de2b2bf0bc742384e5755fee42/reflection/grpc_testing_not_regenerate/testv3.go#L41C9-L41C41

dfawley avatar Mar 20 '24 18:03 dfawley

This was closed by automation. Keeping this open and assigning it my self to verify the fix.

arvindbr8 avatar Apr 08 '24 16:04 arvindbr8