executors: Unify go-plugin handshake

This commit is contained in:
Danielle Tomlinson
2018-11-30 10:59:23 +01:00
parent 756325bcbd
commit 17d14d7f52
3 changed files with 4 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import (
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/plugins/base"
"github.com/hashicorp/nomad/plugins/executor"
)
@@ -42,7 +43,7 @@ func (e *ExecutorPluginCommand) Run(args []string) int {
return 1
}
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: executor.HandshakeConfig,
HandshakeConfig: base.Handshake,
Plugins: executor.GetPluginMap(
stdo,
hclog.LevelFromString(executorConfig.LogLevel),

View File

@@ -78,7 +78,7 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri
config := &plugin.ClientConfig{
Cmd: exec.Command(bin, "executor", string(c)),
}
config.HandshakeConfig = pexecutor.HandshakeConfig
config.HandshakeConfig = base.Handshake
config.Plugins = pexecutor.GetPluginMap(w, level, executorConfig.FSIsolation)
if driverConfig != nil {
@@ -111,7 +111,7 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri
// CreateExecutorWithConfig launches a plugin with a given plugin config
func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executor.Executor, *plugin.Client, error) {
config.HandshakeConfig = pexecutor.HandshakeConfig
config.HandshakeConfig = base.Handshake
// Setting this to DEBUG since the log level at the executor server process
// is already set, and this effects only the executor client.

View File

@@ -22,12 +22,6 @@ type ExecutorConfig struct {
FSIsolation bool
}
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "NOMAD_PLUGIN_MAGIC_COOKIE",
MagicCookieValue: "e4327c2e01eabfd75a8a67adb114fb34a757d57eee7728d857a8cec6e91a7255",
}
func GetPluginMap(w io.Writer, logLevel hclog.Level, fsIsolation bool) map[string]plugin.Plugin {
e := new(ExecutorPlugin)