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

Base go-plugin client/server #4574

Merged
merged 4 commits into from
Aug 13, 2018
Merged

Base go-plugin client/server #4574

merged 4 commits into from
Aug 13, 2018

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Aug 12, 2018

This PR implements a client/server wrapping for a base plugin type.

@dadgar dadgar requested a review from nickethier August 12, 2018 23:00
return nil
}

func (p *PluginBase) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, 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 doesn’t implement the go plugin interface correctly. It wants a context from the context package instead of the older x/net one.

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: github.com/hashicorp/nomad/plugins/base/base.proto
// source: github.com/hashicorp/nomad/plugins/base/proto/base.proto
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a way too disable go vet on protobuf generated code, this and the other driver plugin proto generated code always result in go vet warnings because it can't correctly resolve usages.

Copy link
Member

@nickethier nickethier left a comment

Choose a reason for hiding this comment

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

Mostly some questions, looking great!

}
)

type PluginBase struct {
Copy link
Member

Choose a reason for hiding this comment

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

Comment that this implements the go-plugin GRPCPlugin interface


// PluginApiVersion returns the version of the Nomad plugin API it is built
// against.
PluginApiVersion string
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to model these versions as github.com/coreos/go-semver/semver.Version ptrs? Or may be add Getters to the struct that return that type? Just pondering if we should do some sort of validation on these version strings since they'll later be used for load ordering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will use this to parse as semver: https://github.com/hashicorp/go-version
Simpler to keep using this library and expose a primitive type for all languages over protobuf.

Copy link
Member

Choose a reason for hiding this comment

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

I agree over protobuf. But a helper here in the go interface layer might be nice. Don't want to bikeshed this.

@@ -0,0 +1,35 @@
package shared
Copy link
Member

Choose a reason for hiding this comment

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

Did you intend to put these in the github.com/hashicorp/nomad/plugins/base package and have the package named shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! Was a refactoring accident.

PluginInfoF: knownType,
}

conn, server := plugin.TestGRPCConn(t, func(s *grpc.Server) {
Copy link
Member

Choose a reason for hiding this comment

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

You might want to use TestPluginGRPCConn and dispense a basePluginClient.

@@ -20,8 +20,9 @@ service BasePlugin {
// PluginType enumerates the type of plugins Nomad supports
enum PluginType {
UNKNOWN = 0;
DRIVER = 1;
DEVICE = 2;
BASE = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Why is BASE considered a plugin type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't! Was being lazy for testing.

@@ -312,12 +312,15 @@
{"path":"github.com/ulikunitz/xz/internal/hash","checksumSHA1":"vjnTkzNrMs5Xj6so/fq0mQ6dT1c=","revision":"0c6b41e72360850ca4f98dc341fd999726ea007f","revisionTime":"2017-06-05T21:53:11Z"},
{"path":"github.com/ulikunitz/xz/internal/xlog","checksumSHA1":"m0pm57ASBK/CTdmC0ppRHO17mBs=","revision":"0c6b41e72360850ca4f98dc341fd999726ea007f","revisionTime":"2017-06-05T21:53:11Z"},
{"path":"github.com/ulikunitz/xz/lzma","checksumSHA1":"2vZw6zc8xuNlyVz2QKvdlNSZQ1U=","revision":"0c6b41e72360850ca4f98dc341fd999726ea007f","revisionTime":"2017-06-05T21:53:11Z"},
{"path":"github.com/vmihailenco/msgpack","checksumSHA1":"t9A/EE2GhHFPHzK+ksAKgKW9ZC8=","revision":"b5e691b1eb52a28c05e67ab9df303626c095c23b","revisionTime":"2018-06-13T09:15:15Z"},
{"path":"github.com/vmihailenco/msgpack/codes","checksumSHA1":"OcTSGT2v7/2saIGq06nDhEZwm8I=","revision":"b5e691b1eb52a28c05e67ab9df303626c095c23b","revisionTime":"2018-06-13T09:15:15Z"},
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the difference between the codec methods in https://github.com/hashicorp/go-msgpack which we already vendor, and this new library? Would be helpful to document or comment on why we need two different vendored libraries to deal with msgpack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an import of the go-cty/messagepack package. I have a todo to look and see if we can replace the message pack library there with the one we use.

@dadgar dadgar merged commit a58faf0 into master Aug 13, 2018
@dadgar dadgar deleted the f-base-go-plugin branch August 13, 2018 18:10
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants