From 5262e42d62db381ba4d48430cf6679d834229c03 Mon Sep 17 00:00:00 2001 From: Danielle Tomlinson Date: Thu, 29 Nov 2018 14:59:53 +0100 Subject: [PATCH] fixup: executorplugin: fix rkt build --- client/driver/exec.go | 8 ++++---- client/driver/java.go | 8 ++++---- client/driver/qemu.go | 8 ++++---- client/driver/raw_exec.go | 8 ++++---- client/driver/rkt.go | 7 ++++--- client/driver/structs/structs.go | 14 -------------- client/driver/utils.go | 14 +++++++------- command/executor_plugin.go | 9 ++++----- drivers/exec/driver.go | 4 ++-- drivers/java/driver.go | 4 ++-- drivers/qemu/driver.go | 4 ++-- drivers/rawexec/driver.go | 4 ++-- drivers/rkt/driver.go | 4 ++-- plugins/drivers/utils/utils.go | 15 +++++++-------- .../executor}/executor_plugin.go | 2 +- .../executor}/executor_plugin_pre_0_9_0.go | 2 +- .../executor}/plugins.go | 16 +++++++++++++++- 17 files changed, 65 insertions(+), 66 deletions(-) rename {client/driver/executor_plugin => plugins/executor}/executor_plugin.go (99%) rename {client/driver/executor_plugin => plugins/executor}/executor_plugin_pre_0_9_0.go (99%) rename {client/driver/executor_plugin => plugins/executor}/plugins.go (79%) diff --git a/client/driver/exec.go b/client/driver/exec.go index 01e04bce1..b83899d76 100644 --- a/client/driver/exec.go +++ b/client/driver/exec.go @@ -12,12 +12,12 @@ import ( "github.com/hashicorp/go-multierror" "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/driver/executor_plugin" dstructs "github.com/hashicorp/nomad/client/driver/structs" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/helper/fields" "github.com/hashicorp/nomad/nomad/structs" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/mitchellh/mapstructure" ) @@ -110,7 +110,7 @@ func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse } pluginLogFile := filepath.Join(ctx.TaskDir.Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: d.config.LogLevel, FSIsolation: true, @@ -176,7 +176,7 @@ type execId struct { KillTimeout time.Duration MaxKillTimeout time.Duration UserPid int - PluginConfig *executorplugin.PluginReattachConfig + PluginConfig *pexecutor.PluginReattachConfig } func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error) { @@ -223,7 +223,7 @@ func (h *execHandle) ID() string { Version: h.version, KillTimeout: h.killTimeout, MaxKillTimeout: h.maxKillTimeout, - PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), + PluginConfig: pexecutor.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), UserPid: h.userPid, } diff --git a/client/driver/java.go b/client/driver/java.go index 7766d27d2..d4317e126 100644 --- a/client/driver/java.go +++ b/client/driver/java.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/go-plugin" "github.com/mitchellh/mapstructure" - "github.com/hashicorp/nomad/client/driver/executor_plugin" dstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" @@ -27,6 +26,7 @@ import ( "github.com/hashicorp/nomad/helper" "github.com/hashicorp/nomad/helper/fields" "github.com/hashicorp/nomad/nomad/structs" + pexecutor "github.com/hashicorp/nomad/plugins/executor" ) const ( @@ -239,7 +239,7 @@ func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse } pluginLogFile := filepath.Join(ctx.TaskDir.Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: d.config.LogLevel, FSIsolation: true, @@ -308,7 +308,7 @@ type javaId struct { Version string KillTimeout time.Duration MaxKillTimeout time.Duration - PluginConfig *executorplugin.PluginReattachConfig + PluginConfig *pexecutor.PluginReattachConfig TaskDir string UserPid int ShutdownSignal string @@ -360,7 +360,7 @@ func (h *javaHandle) ID() string { Version: h.version, KillTimeout: h.killTimeout, MaxKillTimeout: h.maxKillTimeout, - PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), + PluginConfig: pexecutor.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), UserPid: h.userPid, TaskDir: h.taskDir, ShutdownSignal: h.shutdownSignal, diff --git a/client/driver/qemu.go b/client/driver/qemu.go index 21c84d833..b5c6dd7c4 100644 --- a/client/driver/qemu.go +++ b/client/driver/qemu.go @@ -17,13 +17,13 @@ import ( "github.com/coreos/go-semver/semver" plugin "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/client/driver/executor_plugin" dstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/helper/fields" "github.com/hashicorp/nomad/nomad/structs" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/mitchellh/mapstructure" ) @@ -312,7 +312,7 @@ func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse d.logger.Printf("[DEBUG] driver.qemu: starting QemuVM command: %q", strings.Join(args, " ")) pluginLogFile := filepath.Join(ctx.TaskDir.Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: d.config.LogLevel, } @@ -373,7 +373,7 @@ type qemuId struct { KillTimeout time.Duration MaxKillTimeout time.Duration UserPid int - PluginConfig *executorplugin.PluginReattachConfig + PluginConfig *pexecutor.PluginReattachConfig ShutdownSignal string } @@ -422,7 +422,7 @@ func (h *qemuHandle) ID() string { Version: h.version, KillTimeout: h.killTimeout, MaxKillTimeout: h.maxKillTimeout, - PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), + PluginConfig: pexecutor.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), UserPid: h.userPid, ShutdownSignal: h.shutdownSignal, } diff --git a/client/driver/raw_exec.go b/client/driver/raw_exec.go index 5da9c34b4..ee52639c4 100644 --- a/client/driver/raw_exec.go +++ b/client/driver/raw_exec.go @@ -14,7 +14,6 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/driver/executor_plugin" dstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" @@ -22,6 +21,7 @@ import ( "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/helper/fields" "github.com/hashicorp/nomad/nomad/structs" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/mitchellh/mapstructure" ) @@ -143,7 +143,7 @@ func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (*StartRespo } pluginLogFile := filepath.Join(ctx.TaskDir.Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: d.config.LogLevel, } @@ -202,7 +202,7 @@ type rawExecId struct { KillTimeout time.Duration MaxKillTimeout time.Duration UserPid int - PluginConfig *executorplugin.PluginReattachConfig + PluginConfig *pexecutor.PluginReattachConfig ShutdownSignal string } @@ -253,7 +253,7 @@ func (h *rawExecHandle) ID() string { Version: h.version, KillTimeout: h.killTimeout, MaxKillTimeout: h.maxKillTimeout, - PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), + PluginConfig: pexecutor.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), UserPid: h.userPid, ShutdownSignal: h.shutdownSignal, } diff --git a/client/driver/rkt.go b/client/driver/rkt.go index fb26b0ad9..49e8ca56a 100644 --- a/client/driver/rkt.go +++ b/client/driver/rkt.go @@ -35,6 +35,7 @@ import ( "github.com/hashicorp/nomad/helper" "github.com/hashicorp/nomad/helper/fields" "github.com/hashicorp/nomad/nomad/structs" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/mitchellh/mapstructure" ) @@ -114,7 +115,7 @@ type rktHandle struct { // disk type rktPID struct { UUID string - PluginConfig *PluginReattachConfig + PluginConfig *pexecutor.PluginReattachConfig ExecutorPid int KillTimeout time.Duration MaxKillTimeout time.Duration @@ -625,7 +626,7 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, } pluginLogFile := filepath.Join(ctx.TaskDir.Dir, fmt.Sprintf("%s-executor.out", task.Name)) - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: d.config.LogLevel, } @@ -787,7 +788,7 @@ func (h *rktHandle) ID() string { // Return a handle to the PID pid := &rktPID{ UUID: h.uuid, - PluginConfig: NewPluginReattachConfig(h.pluginClient.ReattachConfig()), + PluginConfig: pexecutor.NewPluginReattachConfig(h.pluginClient.ReattachConfig()), KillTimeout: h.killTimeout, MaxKillTimeout: h.maxKillTimeout, ExecutorPid: h.executorPid, diff --git a/client/driver/structs/structs.go b/client/driver/structs/structs.go index 5fc4a3a57..1ad716073 100644 --- a/client/driver/structs/structs.go +++ b/client/driver/structs/structs.go @@ -55,17 +55,3 @@ type CheckResult struct { // Err is the error that a check returned Err error } - -// ExecutorConfig is the config that Nomad passes to the executor -type ExecutorConfig struct { - - // LogFile is the file to which Executor logs - LogFile string - - // LogLevel is the level of the logs to putout - LogLevel string - - // FSIsolation if set will use an executor implementation that support - // filesystem isolation - FSIsolation bool -} diff --git a/client/driver/utils.go b/client/driver/utils.go index 9b1c3c415..9676484c5 100644 --- a/client/driver/utils.go +++ b/client/driver/utils.go @@ -15,11 +15,11 @@ import ( "github.com/hashicorp/go-multierror" "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/config" - "github.com/hashicorp/nomad/client/driver/executor_plugin" dstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/helper/discover" "github.com/hashicorp/nomad/nomad/structs" + pexecutor "github.com/hashicorp/nomad/plugins/executor" ) // cgroupsMounted returns true if the cgroups are mounted on a system otherwise @@ -32,7 +32,7 @@ func cgroupsMounted(node *structs.Node) bool { // createExecutor launches an executor plugin and returns an instance of the // Executor interface func createExecutor(w io.Writer, clientConfig *config.Config, - executorConfig *dstructs.ExecutorConfig) (executor.Executor, *plugin.Client, error) { + executorConfig *pexecutor.ExecutorConfig) (executor.Executor, *plugin.Client, error) { c, err := json.Marshal(executorConfig) if err != nil { @@ -46,8 +46,8 @@ func createExecutor(w io.Writer, clientConfig *config.Config, config := &plugin.ClientConfig{ Cmd: exec.Command(bin, "executor", string(c)), } - config.HandshakeConfig = executorplugin.HandshakeConfig - config.Plugins = executorplugin.GetPluginMap(w, hclog.LevelFromString(clientConfig.LogLevel), executorConfig.FSIsolation) + config.HandshakeConfig = pexecutor.HandshakeConfig + config.Plugins = pexecutor.GetPluginMap(w, hclog.LevelFromString(clientConfig.LogLevel), executorConfig.FSIsolation) config.MaxPort = clientConfig.ClientMaxPort config.MinPort = clientConfig.ClientMinPort @@ -72,11 +72,11 @@ func createExecutor(w io.Writer, clientConfig *config.Config, } func createExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executor.Executor, *plugin.Client, error) { - config.HandshakeConfig = executorplugin.HandshakeConfig + config.HandshakeConfig = pexecutor.HandshakeConfig // Setting this to DEBUG since the log level at the executor server process // is already set, and this effects only the executor client. - config.Plugins = executorplugin.GetPluginMap(w, hclog.Debug, false) + config.Plugins = pexecutor.GetPluginMap(w, hclog.Debug, false) executorClient := plugin.NewClient(config) rpcClient, err := executorClient.Client() @@ -88,7 +88,7 @@ func createExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executo if err != nil { return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) } - executorPlugin, ok := raw.(*executorplugin.ExecutorRPC) + executorPlugin, ok := raw.(*pexecutor.ExecutorRPC) if !ok { return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw) } diff --git a/command/executor_plugin.go b/command/executor_plugin.go index a7969a074..ac322aa0c 100644 --- a/command/executor_plugin.go +++ b/command/executor_plugin.go @@ -8,8 +8,7 @@ import ( hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/client/driver/executor_plugin" - dstructs "github.com/hashicorp/nomad/client/driver/structs" + "github.com/hashicorp/nomad/plugins/executor" ) type ExecutorPluginCommand struct { @@ -33,7 +32,7 @@ func (e *ExecutorPluginCommand) Run(args []string) int { return 1 } config := args[0] - var executorConfig dstructs.ExecutorConfig + var executorConfig executor.ExecutorConfig if err := json.Unmarshal([]byte(config), &executorConfig); err != nil { return 1 } @@ -43,8 +42,8 @@ func (e *ExecutorPluginCommand) Run(args []string) int { return 1 } plugin.Serve(&plugin.ServeConfig{ - HandshakeConfig: executorplugin.HandshakeConfig, - Plugins: executorplugin.GetPluginMap( + HandshakeConfig: executor.HandshakeConfig, + Plugins: executor.GetPluginMap( stdo, hclog.LevelFromString(executorConfig.LogLevel), executorConfig.FSIsolation, diff --git a/drivers/exec/driver.go b/drivers/exec/driver.go index 97b1d6ad7..14eca02c3 100644 --- a/drivers/exec/driver.go +++ b/drivers/exec/driver.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/consul-template/signals" hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - dstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" @@ -19,6 +18,7 @@ import ( "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -286,7 +286,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru handle.Config = cfg pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", FSIsolation: true, diff --git a/drivers/java/driver.go b/drivers/java/driver.go index a0beee822..a9ac5a0fb 100644 --- a/drivers/java/driver.go +++ b/drivers/java/driver.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/consul-template/signals" "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - dstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" @@ -21,6 +20,7 @@ import ( "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -320,7 +320,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru handle.Config = cfg pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } diff --git a/drivers/qemu/driver.go b/drivers/qemu/driver.go index 77274d964..2a37aa6b5 100644 --- a/drivers/qemu/driver.go +++ b/drivers/qemu/driver.go @@ -16,13 +16,13 @@ import ( "github.com/coreos/go-semver/semver" "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - dstructs "github.com/hashicorp/nomad/client/driver/structs" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -414,7 +414,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru d.logger.Debug("starting QemuVM command ", "args", strings.Join(args, " ")) pluginLogFile := filepath.Join(cfg.TaskDir().Dir, fmt.Sprintf("%s-executor.out", cfg.Name)) - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } diff --git a/drivers/rawexec/driver.go b/drivers/rawexec/driver.go index 3163ec1de..e182764ef 100644 --- a/drivers/rawexec/driver.go +++ b/drivers/rawexec/driver.go @@ -13,13 +13,13 @@ import ( "github.com/hashicorp/consul-template/signals" hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - dstructs "github.com/hashicorp/nomad/client/driver/structs" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -313,7 +313,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru handle.Config = cfg pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out") - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } diff --git a/drivers/rkt/driver.go b/drivers/rkt/driver.go index 6411c0b99..8a137d510 100644 --- a/drivers/rkt/driver.go +++ b/drivers/rkt/driver.go @@ -25,7 +25,6 @@ import ( "github.com/hashicorp/go-plugin" "github.com/hashicorp/go-version" "github.com/hashicorp/nomad/client/config" - dstructs "github.com/hashicorp/nomad/client/driver/structs" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/env" "github.com/hashicorp/nomad/drivers/shared/eventer" @@ -33,6 +32,7 @@ import ( "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" + pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -604,7 +604,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru } pluginLogFile := filepath.Join(cfg.TaskDir().Dir, fmt.Sprintf("%s-executor.out", cfg.Name)) - executorConfig := &dstructs.ExecutorConfig{ + executorConfig := &pexecutor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } diff --git a/plugins/drivers/utils/utils.go b/plugins/drivers/utils/utils.go index 6328a38ee..5790c3278 100644 --- a/plugins/drivers/utils/utils.go +++ b/plugins/drivers/utils/utils.go @@ -12,14 +12,13 @@ import ( plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" - "github.com/hashicorp/nomad/client/driver/executor_plugin" - dstructs "github.com/hashicorp/nomad/client/driver/structs" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/env" "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/helper/discover" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/base" + pexecutor "github.com/hashicorp/nomad/plugins/executor" ) const ( @@ -65,7 +64,7 @@ func CgroupsMounted(node *structs.Node) bool { // CreateExecutor launches an executor plugin and returns an instance of the // Executor interface func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDriverConfig, - executorConfig *dstructs.ExecutorConfig) (executor.Executor, *plugin.Client, error) { + executorConfig *pexecutor.ExecutorConfig) (executor.Executor, *plugin.Client, error) { c, err := json.Marshal(executorConfig) if err != nil { @@ -79,8 +78,8 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri config := &plugin.ClientConfig{ Cmd: exec.Command(bin, "executor", string(c)), } - config.HandshakeConfig = executorplugin.HandshakeConfig - config.Plugins = executorplugin.GetPluginMap(w, level, executorConfig.FSIsolation) + config.HandshakeConfig = pexecutor.HandshakeConfig + config.Plugins = pexecutor.GetPluginMap(w, level, executorConfig.FSIsolation) if driverConfig != nil { config.MaxPort = driverConfig.ClientMaxPort @@ -112,11 +111,11 @@ 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 = executorplugin.HandshakeConfig + config.HandshakeConfig = pexecutor.HandshakeConfig // Setting this to DEBUG since the log level at the executor server process // is already set, and this effects only the executor client. - config.Plugins = executorplugin.GetPluginMap(w, hclog.Debug, false) + config.Plugins = pexecutor.GetPluginMap(w, hclog.Debug, false) executorClient := plugin.NewClient(config) rpcClient, err := executorClient.Client() @@ -128,7 +127,7 @@ func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executo if err != nil { return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) } - executorPlugin, ok := raw.(*executorplugin.ExecutorRPC) + executorPlugin, ok := raw.(*pexecutor.ExecutorRPC) if !ok { return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw) } diff --git a/client/driver/executor_plugin/executor_plugin.go b/plugins/executor/executor_plugin.go similarity index 99% rename from client/driver/executor_plugin/executor_plugin.go rename to plugins/executor/executor_plugin.go index 70d3fa8c2..a31d9eb80 100644 --- a/client/driver/executor_plugin/executor_plugin.go +++ b/plugins/executor/executor_plugin.go @@ -1,4 +1,4 @@ -package executorplugin +package executor import ( "encoding/gob" diff --git a/client/driver/executor_plugin/executor_plugin_pre_0_9_0.go b/plugins/executor/executor_plugin_pre_0_9_0.go similarity index 99% rename from client/driver/executor_plugin/executor_plugin_pre_0_9_0.go rename to plugins/executor/executor_plugin_pre_0_9_0.go index ad3f53617..50775d7f2 100644 --- a/client/driver/executor_plugin/executor_plugin_pre_0_9_0.go +++ b/plugins/executor/executor_plugin_pre_0_9_0.go @@ -1,4 +1,4 @@ -package executorplugin +package executor /* import ( diff --git a/client/driver/executor_plugin/plugins.go b/plugins/executor/plugins.go similarity index 79% rename from client/driver/executor_plugin/plugins.go rename to plugins/executor/plugins.go index da8f439d4..fba04ccfa 100644 --- a/client/driver/executor_plugin/plugins.go +++ b/plugins/executor/plugins.go @@ -1,4 +1,4 @@ -package executorplugin +package executor import ( "io" @@ -8,6 +8,20 @@ import ( "github.com/hashicorp/go-plugin" ) +// ExecutorConfig is the config that Nomad passes to the executor +type ExecutorConfig struct { + + // LogFile is the file to which Executor logs + LogFile string + + // LogLevel is the level of the logs to putout + LogLevel string + + // FSIsolation if set will use an executor implementation that support + // filesystem isolation + FSIsolation bool +} + var HandshakeConfig = plugin.HandshakeConfig{ ProtocolVersion: 1, MagicCookieKey: "NOMAD_PLUGIN_MAGIC_COOKIE",