Skip to content
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

Merged
merged 38 commits into from May 5, 2019
Merged

Conversation

chvck
Copy link
Contributor

@chvck chvck commented Apr 5, 2019

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.

olivierboucher and others added 3 commits April 5, 2019 13:34
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>
@chvck
Copy link
Contributor Author

chvck commented Apr 5, 2019

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.

Copy link
Member

@yurishkuro yurishkuro left a 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.

VersionedPlugins: map[int]plugin.PluginSet{
1: shared.PluginMap,
},
Cmd: exec.Command(c.PluginBinary, "--config", c.PluginConfigurationFile),
Copy link
Member

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>
@chvck
Copy link
Contributor Author

chvck commented Apr 16, 2019

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.

Copy link
Member

@yurishkuro yurishkuro left a 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?

// See the License for the specific language governing permissions and
// limitations under the License.

package config
Copy link
Member

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?

Copy link
Contributor Author

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.

@yurishkuro
Copy link
Member

the crossdock failure is probably unrelated, but we need to get up to date with master where there may be fixes for it.

@chvck
Copy link
Contributor Author

chvck commented Apr 25, 2019

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?

@yurishkuro
Copy link
Member

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.
Copy link
Contributor Author

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>
@@ -0,0 +1,65 @@
// Copyright (c) 2018 The Jaeger Authors.
Copy link
Member

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

}

func (mp *mockPlugin) SpanReader() spanstore.Reader {
return mp
Copy link
Member

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.

)

func Serve(implementation shared.StoragePlugin) {
plugin.Serve(&plugin.ServeConfig{
Copy link
Member

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 {
Copy link
Member

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

chvck added 5 commits May 1, 2019 09:24
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"
Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chvck added 5 commits May 3, 2019 17:23
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>
@chvck
Copy link
Contributor Author

chvck commented May 5, 2019

I'm unsure if I've done something to upset the crossdock part of ci or if something is broken ci side.

@yurishkuro
Copy link
Member

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.

Main project automation moved this from In progress to Reviewer approved May 5, 2019
Copy link
Member

@yurishkuro yurishkuro left a 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.
Copy link
Member

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) {
Copy link
Member

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 {
Copy link
Member

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro yurishkuro changed the title WIP - gRPC Plugin framework gRPC Plugin framework May 5, 2019
@yurishkuro yurishkuro merged commit 8588c42 into jaegertracing:master May 5, 2019
Main project automation moved this from Reviewer approved to Done May 5, 2019
@yurishkuro yurishkuro mentioned this pull request May 5, 2019
8 tasks
@tiffon
Copy link
Member

tiffon commented May 5, 2019

W00t! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Main project
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants