Commit 75d333fe authored by Danielle Tomlinson's avatar Danielle Tomlinson
Browse files

client: Move executor plugins into own package

parent d4ef3b68
Showing with 30 additions and 25 deletions
+30 -25
......@@ -12,6 +12,7 @@ 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"
......@@ -175,7 +176,7 @@ type execId struct {
KillTimeout time.Duration
MaxKillTimeout time.Duration
UserPid int
PluginConfig *PluginReattachConfig
PluginConfig *executorplugin.PluginReattachConfig
}
func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error) {
......@@ -222,7 +223,7 @@ func (h *execHandle) ID() string {
Version: h.version,
KillTimeout: h.killTimeout,
MaxKillTimeout: h.maxKillTimeout,
PluginConfig: NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
UserPid: h.userPid,
}
......
package driver
package executorplugin
import (
"encoding/gob"
......
package driver
package executorplugin
/*
import (
......
package driver
package executorplugin
import (
"io"
......
......@@ -18,6 +18,7 @@ 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"
......@@ -307,7 +308,7 @@ type javaId struct {
Version string
KillTimeout time.Duration
MaxKillTimeout time.Duration
PluginConfig *PluginReattachConfig
PluginConfig *executorplugin.PluginReattachConfig
TaskDir string
UserPid int
ShutdownSignal string
......@@ -359,7 +360,7 @@ func (h *javaHandle) ID() string {
Version: h.version,
KillTimeout: h.killTimeout,
MaxKillTimeout: h.maxKillTimeout,
PluginConfig: NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
UserPid: h.userPid,
TaskDir: h.taskDir,
ShutdownSignal: h.shutdownSignal,
......
......@@ -17,6 +17,7 @@ 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"
......@@ -372,7 +373,7 @@ type qemuId struct {
KillTimeout time.Duration
MaxKillTimeout time.Duration
UserPid int
PluginConfig *PluginReattachConfig
PluginConfig *executorplugin.PluginReattachConfig
ShutdownSignal string
}
......@@ -421,7 +422,7 @@ func (h *qemuHandle) ID() string {
Version: h.version,
KillTimeout: h.killTimeout,
MaxKillTimeout: h.maxKillTimeout,
PluginConfig: NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
UserPid: h.userPid,
ShutdownSignal: h.shutdownSignal,
}
......
......@@ -14,6 +14,7 @@ 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"
......@@ -201,7 +202,7 @@ type rawExecId struct {
KillTimeout time.Duration
MaxKillTimeout time.Duration
UserPid int
PluginConfig *PluginReattachConfig
PluginConfig *executorplugin.PluginReattachConfig
ShutdownSignal string
}
......@@ -252,7 +253,7 @@ func (h *rawExecHandle) ID() string {
Version: h.version,
KillTimeout: h.killTimeout,
MaxKillTimeout: h.maxKillTimeout,
PluginConfig: NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
PluginConfig: executorplugin.NewPluginReattachConfig(h.pluginClient.ReattachConfig()),
UserPid: h.userPid,
ShutdownSignal: h.shutdownSignal,
}
......
......@@ -15,6 +15,7 @@ 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"
......@@ -45,8 +46,8 @@ func createExecutor(w io.Writer, clientConfig *config.Config,
config := &plugin.ClientConfig{
Cmd: exec.Command(bin, "executor", string(c)),
}
config.HandshakeConfig = HandshakeConfig
config.Plugins = GetPluginMap(w, hclog.LevelFromString(clientConfig.LogLevel), executorConfig.FSIsolation)
config.HandshakeConfig = executorplugin.HandshakeConfig
config.Plugins = executorplugin.GetPluginMap(w, hclog.LevelFromString(clientConfig.LogLevel), executorConfig.FSIsolation)
config.MaxPort = clientConfig.ClientMaxPort
config.MinPort = clientConfig.ClientMinPort
......@@ -71,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 = HandshakeConfig
config.HandshakeConfig = executorplugin.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 = GetPluginMap(w, hclog.Debug, false)
config.Plugins = executorplugin.GetPluginMap(w, hclog.Debug, false)
executorClient := plugin.NewClient(config)
rpcClient, err := executorClient.Client()
......@@ -87,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.(*ExecutorRPC)
executorPlugin, ok := raw.(*executorplugin.ExecutorRPC)
if !ok {
return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw)
}
......
......@@ -8,7 +8,7 @@ import (
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/driver"
"github.com/hashicorp/nomad/client/driver/executor_plugin"
dstructs "github.com/hashicorp/nomad/client/driver/structs"
)
......@@ -43,8 +43,8 @@ func (e *ExecutorPluginCommand) Run(args []string) int {
return 1
}
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: driver.HandshakeConfig,
Plugins: driver.GetPluginMap(
HandshakeConfig: executorplugin.HandshakeConfig,
Plugins: executorplugin.GetPluginMap(
stdo,
hclog.LevelFromString(executorConfig.LogLevel),
executorConfig.FSIsolation,
......
......@@ -12,7 +12,7 @@ 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"
"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"
......@@ -79,8 +79,8 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri
config := &plugin.ClientConfig{
Cmd: exec.Command(bin, "executor", string(c)),
}
config.HandshakeConfig = driver.HandshakeConfig
config.Plugins = driver.GetPluginMap(w, level, executorConfig.FSIsolation)
config.HandshakeConfig = executorplugin.HandshakeConfig
config.Plugins = executorplugin.GetPluginMap(w, level, executorConfig.FSIsolation)
if driverConfig != nil {
config.MaxPort = driverConfig.ClientMaxPort
......@@ -112,11 +112,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 = driver.HandshakeConfig
config.HandshakeConfig = executorplugin.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 = driver.GetPluginMap(w, hclog.Debug, false)
config.Plugins = executorplugin.GetPluginMap(w, hclog.Debug, false)
executorClient := plugin.NewClient(config)
rpcClient, err := executorClient.Client()
......@@ -128,7 +128,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.(*driver.ExecutorRPC)
executorPlugin, ok := raw.(*executorplugin.ExecutorRPC)
if !ok {
return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment