From 17d14d7f520349c68b9ebfc8470fc34901c78677 Mon Sep 17 00:00:00 2001 From: Danielle Tomlinson Date: Fri, 30 Nov 2018 10:59:23 +0100 Subject: [PATCH] executors: Unify go-plugin handshake --- command/executor_plugin.go | 3 ++- plugins/drivers/utils/utils.go | 4 ++-- plugins/executor/plugins.go | 6 ------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/command/executor_plugin.go b/command/executor_plugin.go index ac322aa0c..e9741fb90 100644 --- a/command/executor_plugin.go +++ b/command/executor_plugin.go @@ -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), diff --git a/plugins/drivers/utils/utils.go b/plugins/drivers/utils/utils.go index 5790c3278..41a62a2b1 100644 --- a/plugins/drivers/utils/utils.go +++ b/plugins/drivers/utils/utils.go @@ -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. diff --git a/plugins/executor/plugins.go b/plugins/executor/plugins.go index fba04ccfa..d2478e568 100644 --- a/plugins/executor/plugins.go +++ b/plugins/executor/plugins.go @@ -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)