-
Notifications
You must be signed in to change notification settings - Fork 2.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
gRPC Plugin framework #1461
gRPC Plugin framework #1461
Conversation
Still a work in progress. Related to issue jaegertracing#422. Leverages Hashicorp's go-plugin. New set of protos for the use of plugin maintainers. Missing tests. Still need to create a plugin binary for the memory backend. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Added Memory GRPC Plugin. Renamed packages (jaegertracing#422) Renamed packages from "external" to "grpc". Changed storage type to "grpc-plugin". Added cmd/memory-grpc-plugin that uses the memory backend as a grpc plugin. Added go-plugin dependency to Glide. Added task to generate plugin protos to Makefile. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Refactored gRPC storage plugin protos Now makes use of protos from model/proto/model.proto and removed mapping functions. Plugin invoker calls the plugin binary directly instead of relying on sh. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Refactored gRPC plugin protos to use defined models Removed mapping code. Removed used of sh, calling plugin binary directly. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Removed .editorconfig file Signed-off-by: Olivier Boucher <info@olivierboucher.com> Added support for gRPC plugin configuration Configuration file is passed down to the plugin through the --config argument. It is the plugin's responsability to parse the file and initialize itself. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Added benchmark for noop SpanWriter vs gRPC based noop plugin Fixed issues related to proto changes. Deleted memory-grpc-plugin since it was no longer relevant. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Updated gRPC plugin & protos to implement latest SpanReader Added dependencies to Gopkg.lock since Glide -> dep transition happened recently. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Fixed proto generation introduced when switching to Dep Changed json tags to match when TraceID was not a proto. Signed-off-by: Olivier Boucher <info@olivierboucher.com> proto fix Fixed issue introduced moving TraceID to model.proto Added proper annotations to storage.proto instead of exposing TraceID in model.proto. Tests are back to green. Signed-off-by: Olivier Boucher <info@olivierboucher.com> Added tests for gRPC storage factory and options Moved DependencyLink to model.proto since it had to be used and the existing struct did not implement any Marshaler/Unmarshaler methods. Changed storage configuration to allow testing via mocks. Added DependencyReader interface to the StoragePlugin interface. Signed-off-by: Olivier Boucher <info@olivierboucher.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
I've taken the work performed by Olivier, squashed his commits and then rebased onto current master. Fixed up the code to work with the new plugin protobuf model. |
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.
make sure to run make fmt lint
. The lint step, especially, fails with many issues.
pkg/grpc/config/config.go
Outdated
VersionedPlugins: map[int]plugin.PluginSet{ | ||
1: shared.PluginMap, | ||
}, | ||
Cmd: exec.Command(c.PluginBinary, "--config", c.PluginConfigurationFile), |
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.
pull up to a variable and disable gosec rule:
// #nosec G204
cmd := exec.Command(c.PluginBinary, "--config", c.PluginConfigurationFile)
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
I'm not sure what the best way to add this stuff to the integration tests would be. Possibly to just let it be used with whatever third party grpc plugin is chosen to run? I also see that crossdock is broken, I'm not sure how to go about fixing that. |
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.
there are a lot of conflicts with master, could you try resolving them?
pkg/grpc/config/config.go
Outdated
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package config |
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.
this import would read pkg/grpc/config
, which doesn't look right considering that it's specific to storage. Any reason not to have it under plugin/storage/grpc
?
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.
I had just left it as it was when Olivier wrote it, now moved.
the crossdock failure is probably unrelated, but we need to get up to date with master where there may be fixes for it. |
Signed-off-by: Charles Dixon <chvckd@gmail.com>
I saw that you pushed a change to the other gRPC plugin framework PR with empty test files, do you want me to pull that over to this too? |
Oh it's probably because I have the old remote in my local repo with the same branch name. Yes, I wanted to get the tests and coverage running. |
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
depsReaderClient storage_v1.DependenciesReaderPluginClient | ||
} | ||
|
||
// DependencyReader implements shared.StoragePlugin. |
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.
If GRPCClient doesn't implement StoragePlugin then go-plugin fails to type assert the plugin on creation.
Signed-off-by: Charles Dixon <chvckd@gmail.com>
examples/memory-store/main.go
Outdated
@@ -0,0 +1,65 @@ | |||
// Copyright (c) 2018 The Jaeger Authors. |
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.
I think it would be more accurate to call this dir memstore-plugin, since it's an example of storage plugin, not the memory store
plugin/storage/grpc/factory_test.go
Outdated
} | ||
|
||
func (mp *mockPlugin) SpanReader() spanstore.Reader { | ||
return mp |
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.
small clean-up: can return new mock storage types (e.g. from storage/spanstore/mocks) and remove the actual storage methods with panics below.
plugin/storage/grpc/grpc.go
Outdated
) | ||
|
||
func Serve(implementation shared.StoragePlugin) { | ||
plugin.Serve(&plugin.ServeConfig{ |
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 this simply delegate to ServeWithGRPCServer ?
const spanBatchSize = 1000 | ||
|
||
// GRPCServer implements shared.StoragePlugin and reads/writes spans and dependencies | ||
type GRPCServer 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.
does this type need to be public? Looks like it's only used by StorageGRPCPlugin
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
func (s *GRPCStorageIntegrationTestSuite) initialize() error { | ||
s.logger, _ = testutils.NewLogger() | ||
gopath := os.Getenv("GOPATH") | ||
path := gopath + "/src/github.com/jaegertracing/jaeger/examples/memstore-plugin/memstore-plugin" |
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.
This hardcoded path feels flakey and requires that the memstore-plugin is already built. I don't really see any better way of doing it though.
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.
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
Signed-off-by: Charles Dixon <chvckd@gmail.com>
I'm unsure if I've done something to upset the crossdock part of ci or if something is broken ci side. |
it keeps getting stuck on installing elasticcurator, which isn't even necessary for crossdock tests. I tried locally, it worked fine, let me restart again. |
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.
👏 👏 👏 🎉 🎉 🎉 🎈 🎈 🎈
@@ -0,0 +1,15 @@ | |||
// Copyright (c) 2018 The Jaeger Authors. |
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.
this file should be removed (packages with main() are excluded from coverage automatically)
} | ||
|
||
// Build instantiates a StoragePlugin | ||
func (c *Configuration) Build() (shared.StoragePlugin, error) { |
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.
this file comes up with large gap in coverage, but we can actually test it using examples/memstore-plugin/
} | ||
|
||
// GRPCServer is used by go-plugin to create a grpc plugin server | ||
func (p *StorageGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { |
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 probably add simple tests exercising GRPCServer/GRPCClient methods. I was actually thinking that it would be great to have tests that actually spin up the server and use the client to talk to it. I suppose this is what the integration test is doing, so we should find a way to use it to enhance coverage.
Note to self:
STORAGE=grpc-plugin go test -v -coverpkg ./plugin/storage/grpc/shared -coverprofile coverage.out ./plugin/storage/integration
func (s *GRPCStorageIntegrationTestSuite) initialize() error { | ||
s.logger, _ = testutils.NewLogger() | ||
gopath := os.Getenv("GOPATH") | ||
path := gopath + "/src/github.com/jaegertracing/jaeger/examples/memstore-plugin/memstore-plugin" |
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.
W00t! 🎉 |
Which problem is this PR solving?
Issue #422 POC
Short description of the changes
Plugin based storage backend
This is an extension of the work in #1214 which appears to have become stale.