gRPC Backend Plugins (#3808)

* Add grpc plugins

* Add grpc plugins

* Translate wrap info to/from proto

* Add nil checks

* Fix nil marshaling errors

* Provide logging through the go-plugin logger

* handle errors in the messages

* Update the TLS config so bidirectional connections work

* Add connectivity checks

* Restart plugin and add timeouts where context is not availible

* Add the response wrap data into the grpc system implementation

* Add leaseoptions to pb.Auth

* Add an error translator

* Add tests for translating the proto objects

* Fix rename of function

* Add tracing to plugins for easier debugging

* Handle plugin crashes with the go-plugin context

* Add test for grpcStorage

* Add tests for backend and system

* Bump go-plugin for GRPCBroker

* Remove RegisterLicense

* Add casing translations for new proto messages

* Use doneCtx in grpcClient

* Use doneCtx in grpcClient

* s/shutdown/shut down/
This commit is contained in:
Brian Kassouf
2018-01-18 13:49:20 -08:00
committed by GitHub
parent 94878e558d
commit 03f6108822
35 changed files with 5988 additions and 78 deletions

View File

@@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"crypto/rsa"
"encoding/gob"
"errors"
"fmt"
"time"
@@ -44,13 +45,13 @@ type BackendPluginClient struct {
client *plugin.Client
sync.Mutex
*backendPluginClient
logical.Backend
}
// Cleanup calls the RPC client's Cleanup() func and also calls
// the go-plugin's client Kill() func
func (b *BackendPluginClient) Cleanup() {
b.backendPluginClient.Cleanup()
b.Backend.Cleanup()
b.client.Kill()
}
@@ -122,13 +123,34 @@ func newPluginClient(sys pluginutil.RunnerUtil, pluginRunner *pluginutil.PluginR
return nil, err
}
var backend logical.Backend
var transport string
// We should have a logical backend type now. This feels like a normal interface
// implementation but is in fact over an RPC connection.
backendRPC := raw.(*backendPluginClient)
switch raw.(type) {
case *backendPluginClient:
backend = raw.(*backendPluginClient)
transport = "netRPC"
case *backendGRPCPluginClient:
backend = raw.(*backendGRPCPluginClient)
transport = "gRPC"
default:
return nil, errors.New("Unsupported plugin client type")
}
// Wrap the backend in a tracing middleware
if logger.IsTrace() {
backend = &backendTracingMiddleware{
logger: logger,
transport: transport,
typeStr: pluginRunner.Name,
next: backend,
}
}
return &BackendPluginClient{
client: client,
backendPluginClient: backendRPC,
client: client,
Backend: backend,
}, nil
}