Fixed the raw_exec_driver tests
This commit is contained in:
parent
83882eca3f
commit
02db2e5735
|
@ -103,9 +103,7 @@ func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle,
|
|||
return nil, fmt.Errorf("unable to find the nomad binary: %v", err)
|
||||
}
|
||||
pluginConfig := &plugin.ClientConfig{
|
||||
HandshakeConfig: plugins.HandshakeConfig,
|
||||
Plugins: plugins.PluginMap,
|
||||
Cmd: exec.Command(bin, "executor"),
|
||||
Cmd: exec.Command(bin, "executor"),
|
||||
}
|
||||
|
||||
executor, pluginClient, err := d.executor(pluginConfig)
|
||||
|
@ -132,11 +130,10 @@ func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle,
|
|||
h := &execHandle{
|
||||
pluginClient: pluginClient,
|
||||
executor: executor,
|
||||
//cmd: cmd,
|
||||
killTimeout: d.DriverContext.KillTimeout(task),
|
||||
logger: d.logger,
|
||||
doneCh: make(chan struct{}),
|
||||
waitCh: make(chan *cstructs.WaitResult, 1),
|
||||
killTimeout: d.DriverContext.KillTimeout(task),
|
||||
logger: d.logger,
|
||||
doneCh: make(chan struct{}),
|
||||
waitCh: make(chan *cstructs.WaitResult, 1),
|
||||
}
|
||||
go h.run()
|
||||
return h, nil
|
||||
|
@ -156,9 +153,7 @@ func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, erro
|
|||
reattachConfig := id.PluginConfig.PluginConfig()
|
||||
|
||||
pluginConfig := &plugin.ClientConfig{
|
||||
HandshakeConfig: plugins.HandshakeConfig,
|
||||
Plugins: plugins.PluginMap,
|
||||
Reattach: reattachConfig,
|
||||
Reattach: reattachConfig,
|
||||
}
|
||||
executor, client, err := d.executor(pluginConfig)
|
||||
if err != nil {
|
||||
|
@ -179,6 +174,8 @@ func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, erro
|
|||
}
|
||||
|
||||
func (d *ExecDriver) executor(config *plugin.ClientConfig) (plugins.Executor, *plugin.Client, error) {
|
||||
config.HandshakeConfig = plugins.HandshakeConfig
|
||||
config.Plugins = plugins.PluginMap
|
||||
config.SyncStdout = d.config.LogOutput
|
||||
config.SyncStderr = d.config.LogOutput
|
||||
executorClient := plugin.NewClient(config)
|
||||
|
|
|
@ -100,11 +100,7 @@ func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandl
|
|||
return nil, fmt.Errorf("unable to find the nomad binary: %v", err)
|
||||
}
|
||||
pluginConfig := &plugin.ClientConfig{
|
||||
HandshakeConfig: plugins.HandshakeConfig,
|
||||
Plugins: plugins.PluginMap,
|
||||
Cmd: exec.Command(bin, "executor"),
|
||||
SyncStdout: d.config.LogOutput,
|
||||
SyncStderr: d.config.LogOutput,
|
||||
Cmd: exec.Command(bin, "executor"),
|
||||
}
|
||||
|
||||
executor, pluginClient, err := d.executor(pluginConfig)
|
||||
|
@ -138,6 +134,10 @@ func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandl
|
|||
return h, nil
|
||||
}
|
||||
func (d *RawExecDriver) executor(config *plugin.ClientConfig) (plugins.Executor, *plugin.Client, error) {
|
||||
config.HandshakeConfig = plugins.HandshakeConfig
|
||||
config.Plugins = plugins.PluginMap
|
||||
config.SyncStdout = d.config.LogOutput
|
||||
config.SyncStderr = d.config.LogOutput
|
||||
executorClient := plugin.NewClient(config)
|
||||
rpcClient, err := executorClient.Client()
|
||||
if err != nil {
|
||||
|
@ -154,8 +154,8 @@ func (d *RawExecDriver) executor(config *plugin.ClientConfig) (plugins.Executor,
|
|||
|
||||
type rawExecId struct {
|
||||
KillTimeout time.Duration
|
||||
PluginConfig *plugin.ReattachConfig
|
||||
UserPid int
|
||||
PluginConfig *plugins.ExecutorReattachConfig
|
||||
}
|
||||
|
||||
func (d *RawExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error) {
|
||||
|
@ -164,18 +164,8 @@ func (d *RawExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, e
|
|||
return nil, fmt.Errorf("Failed to parse handle '%s': %v", handleID, err)
|
||||
}
|
||||
|
||||
bin, err := discover.NomadExecutable()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to find the nomad binary: %v", err)
|
||||
}
|
||||
|
||||
pluginConfig := &plugin.ClientConfig{
|
||||
HandshakeConfig: plugins.HandshakeConfig,
|
||||
Plugins: plugins.PluginMap,
|
||||
Cmd: exec.Command(bin, "executor"),
|
||||
Reattach: id.PluginConfig,
|
||||
SyncStdout: d.config.LogOutput,
|
||||
SyncStderr: d.config.LogOutput,
|
||||
Reattach: id.PluginConfig.PluginConfig(),
|
||||
}
|
||||
executor, client, err := d.executor(pluginConfig)
|
||||
if err != nil {
|
||||
|
@ -199,7 +189,7 @@ func (d *RawExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, e
|
|||
func (h *rawExecHandle) ID() string {
|
||||
id := rawExecId{
|
||||
KillTimeout: h.killTimeout,
|
||||
PluginConfig: h.pluginClient.ReattachConfig(),
|
||||
PluginConfig: plugins.NewExecutorReattachConfig(h.pluginClient.ReattachConfig()),
|
||||
UserPid: h.userPid,
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,8 @@ func TestRawExecDriver_StartOpen_Wait(t *testing.T) {
|
|||
case <-time.After(time.Duration(testutil.TestMultiplier()*5) * time.Second):
|
||||
t.Fatalf("timeout")
|
||||
}
|
||||
handle.Kill()
|
||||
handle2.Kill()
|
||||
}
|
||||
|
||||
func TestRawExecDriver_Start_Artifact_basic(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue