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