-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
build: move to new protobuf library #10019
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @DStrand1 for this PR! It's very much appreciated. My only concern, beside some smaller comments, is moving the protocol buffer files into Telegraf instead of importing them from their upstream location. Can you please either revert this to use the upstream version or elaborate on why this is needed?
// Required embed to maintain compatibility | ||
dialout.UnimplementedGRPCMdtDialoutServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate a bit on why it is needed? It was not there previously and I don't see how it is used in the code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protoc-gen-go-grpc
requires that this be embedded in any struct that uses the proto-gRPC generated types, as it is meant to provide easy forward-compatibility if the generator changes, so that implemented server code doesn't break.
More realistically though, there is an inaccessible member function mustEmbedUnimplementedGRPCMdtDialoutServer()
created as part of the generated code, that without this embed in the struct, calling dialout.RegisterGRPCMdtDialoutServer()
on line 171 would give an error. Since it is inaccessible, embedding this is the best way to resolve the issue, and is recommended in a generated code comment (from dialout_grpc.pb.go#71-73
):
// UnimplementedGRPCMdtDialoutServer must be embedded to have forward compatible implementations.
type UnimplementedGRPCMdtDialoutServer struct {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. Can you please summarize this as a comment in the code as otherwise someone will remove this and stuff starts to break. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment here?
// Required embed to maintain compatibility | |
dialout.UnimplementedGRPCMdtDialoutServer | |
// Though unused in the code, required by protoc-gen-go-rpc to maintain (forward-)compatibility | |
dialout.UnimplementedGRPCMdtDialoutServer |
plugins/serializers/prometheusremotewrite/prometheusremotewrite.go
Outdated
Show resolved
Hide resolved
With regards to copying-in Cisco_telemetry_mdt: The two options for these Riemann_listener: This one I was able to change the |
AFAICS there is an open pull-request with this origin https://github.com/sbezverk/nx-telemetry-proto/tree/mod_update. You could use a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice update @DStrand1! I have some more comments and a request to also get rid of the riemann
stuff which also fails in CI. Can you please fix this upstream or in a fork of the upstream repo? I really want to avoid to open this box...
// Required embed to maintain compatibility | ||
dialout.UnimplementedGRPCMdtDialoutServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment here?
// Required embed to maintain compatibility | |
dialout.UnimplementedGRPCMdtDialoutServer | |
// Though unused in the code, required by protoc-gen-go-rpc to maintain (forward-)compatibility | |
dialout.UnimplementedGRPCMdtDialoutServer |
@@ -204,7 +204,7 @@ func (rsl *riemannListener) read(conn net.Conn) { | |||
riemannReturnErrorResponse(conn, "Failed to unmarshal") | |||
return | |||
} | |||
riemannEvents := riemanngo.ProtocolBuffersToEvents(messagePb.Events) | |||
riemannEvents := protocolBuffersToEvents(messagePb.Events) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why you need a copy of the received events? Can't you directly iterate on the events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could directly iterate over the events, but since we are now using an updated fork of the riemann
repo (i.e., not including our own copy of the ProtocolBuffersToEvents()
function in Telegraf), I think it is cleaner to call this function in riemanngo
instead of handling the logic from there ourselves
- move to forked riemann-client-go lib until PR is merged into main
📦 Looks like new artifacts were built from this PR. Expand this list to get them here! 🐯Artifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work @DStrand1! Code looks good to me and I keep my fingers crossed for you to get your PRs accepted upstream.
Not a reviewer but wanted to stop by and say thanks for fantastic work in this PR 🙏🏼 |
@sspaink exactly. We can get rid of some pretty old libs with this PR and we shouldn't wait for upstream to get out of their holes... ;-) |
(cherry picked from commit ddeb6ec)
This PR upgrades Telegraf to use the new
google.golang.org/protobuf
library over the deprecatedgithub.com/golang/protobuf
and abandonedgithub.com/gogo/protobuf
. This matches similar work performed in IDPE, InfluxDB, Chronograf, Kapacitor, and InfluxCLI.Summaries of major changes:
jti_openconfig_telemetry
input pluginThe JTI Openconfig plugin was using the
golang
protobuf, and I simply regenerated the existing.proto
files with the new protobuf library.stackdriver
input/output pluginStackdriver was using the
golang
protobuf, and was primarily using it for the known types, which exist in the new Protobuf in an API-compatible way, so these were replaced with the new references.riemann_listener
input pluginThe Riemann Listener plugin was using the
gogo
protobuf, and I resolved this by copying the riemann repo's.proto
file and generating a new.pb.go
file using the new protobuf library.cisco_telemetry_mdt
input pluginThe Cisco Telemetry plugin was using a library of pre-generated
.pb.go
files, which lived undergithub.com/cisco-ie/nx-telemetry-proto
. Instead of depending on this library, which was using thegolang
protobuf, I instead copied in the.proto
files from the original repo and generated new files using the new protobuf library.prometheus
serializer pluginThe Prometheus plugin was using the
gogo
protobuf, however Prometheus generates their.pb.go
files withMarshal()
andUnmarshal()
functions on the proto structs, so Proto was removed from this in favor of directly calling these functions.The end result of this PR is depending on 3 less libraries (
gogo/protobuf
,golang/protobuf
, andcisco-ie/nx-telemetry-proto
), keeping Protobuf consistent across the repo, and avoiding future issues that arise from the deprecated/abandoned repos.