openconfig / gnmi

gRPC Network Management Interface
Apache License 2.0
459 stars 196 forks source link

For gnmi_ext.proto, run protoc with github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto (this is for reflections). #170

Open hyun-arista opened 6 months ago

hyun-arista commented 6 months ago

The Problem

gNMI server reflections is basically facing the same issue as mentioned in https://github.com/fullstorydev/grpcurl/issues/22. When the gnmi_ext.proto file gets compiled with path proto/gnmi_ext/gnmi_ext.proto, gNMI server reflection breaks with the following error:

Failed to resolve symbol "gnmi.gNMI": file "proto/gnmi/gnmi.proto" included an unresolvable reference to ".gnmi_ext.Extension"

The Proposal

If gnmi_ext.proto gets compiled with github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto, gNMI server reflections work. So, I modified the gnmi_ext.proto portion in compile_protos.sh to (only the go binding):

protoc -I=$proto_imports_go --go_out=${GOPATH}/src --go_opt=paths=source_relative github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto

I assumed that the github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto path is under ${GOPATH}/src. $proto_imports_go includes ${GOPATH}/src so the go binding should be generated under ${GOPATH}/src/github.com/openconfig/gnmi/proto/gnmi_ext/.

Manual Testing

In my case, I have gnmi_ext.proto under /vendor/github.com/openconfig/gnmi/proto/gnmi_ext/. When I did

protoc -I=vendor --go_out=vendor --go_opt=paths=source_relative github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto

The generated go binding's source is identified as github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto and the gNMI server reflections work.

A Request

This is a message to the reviewer of this pull request. Please modify the python binding portion of compile_protos.sh if necessary. Also, please compile_protos.sh to modify gnmi_ext.pb.go under ${GOPATH}/src/github.com/openconfig/gnmi/proto/gnmi_ext/. Thank you.