openconfig / gnmi

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

Alternative to SubscribeResponse_Error #132

Closed sspaink closed 1 year ago

sspaink commented 1 year ago

The type SubscribeResponse_Error has been marked as deprecated https://github.com/openconfig/gnmi/blob/480bf53a74d21bb0a82d5d716264874de1070120/proto/gnmi/gnmi.pb.go#L1372-L1375

We are using this type to report the error code and message, but it isn't clear how the suggested package google.golang.org/genproto/googleapis/rpc/status should be used instead. Could someone please suggest the correct way to fix this? There doesn't seem a way to get the rpc status from the reply?

https://github.com/influxdata/telegraf/blob/master/plugins/inputs/gnmi/gnmi.go#L315-L322

func (c *GNMI) handleSubscribeResponse(worker *Worker, reply *gnmiLib.SubscribeResponse) {
    switch response := reply.Response.(type) {
    case *gnmiLib.SubscribeResponse_Update:
        c.handleSubscribeResponseUpdate(worker, response)
    case *gnmiLib.SubscribeResponse_Error:
        c.Log.Errorf("Subscribe error (%d), %q", response.Error.Code, response.Error.Message) //nolint:staticcheck
    }
}
gcsl commented 1 year ago

The RPC status message does not appear in the application level message. Rather it is returned as the error, in this case for a stream.Recv() call here.

https://github.com/influxdata/telegraf/blob/master/plugins/inputs/gnmi/gnmi.go#L303

sspaink commented 1 year ago

Thank you for the quick response! Just using the returned error does seem nicer.