Skip to content

Commit

Permalink
Not converting the abs path relative to task dir for drivers which en…
Browse files Browse the repository at this point in the history
…force FS isolation only in linux
  • Loading branch information
diptanu committed Jun 12, 2016
1 parent 752b9ab commit 12f3da9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
42 changes: 15 additions & 27 deletions client/driver/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,6 @@ func (e *UniversalExecutor) LaunchCmd(command *ExecCommand, ctx *ExecutorContext
e.ctx = ctx
e.command = command

// configuring the task dir
if err := e.configureTaskDir(); err != nil {
return nil, err
}

// configuring the chroot, cgroup and enters the plugin process in the
// chroot
if err := e.configureIsolation(); err != nil {
return nil, err
}

// setting the user of the process
if command.User != "" {
e.logger.Printf("[DEBUG] executor: running command as %s", command.User)
Expand All @@ -249,15 +238,12 @@ func (e *UniversalExecutor) LaunchCmd(command *ExecCommand, ctx *ExecutorContext
}
}

// Setup the loggers
if err := e.configureLoggers(); err != nil {
// configuring the task dir
if err := e.configureTaskDir(); err != nil {
return nil, err
}
e.cmd.Stdout = e.lro
e.cmd.Stderr = e.lre

e.ctx.TaskEnv.Build()

// Look up the binary path and make it executable
absPath, err := e.lookupBin(ctx.TaskEnv.ReplaceEnv(command.Cmd))
if err != nil {
Expand All @@ -268,19 +254,14 @@ func (e *UniversalExecutor) LaunchCmd(command *ExecCommand, ctx *ExecutorContext
return nil, err
}

// Determine the path to run as it may have to be relative to the chroot.
path := absPath
if e.command.FSIsolation {
rel, err := filepath.Rel(e.taskDir, absPath)
if err != nil {
return nil, err
}
path = rel
e.cmd.Path = absPath
// configuring the chroot, cgroup and enters the plugin process in the
// chroot
if err := e.configureIsolation(); err != nil {
return nil, err
}

// Set the commands arguments
e.cmd.Path = path
e.cmd.Args = append([]string{path}, ctx.TaskEnv.ParseAndReplace(command.Args)...)
e.cmd.Args = append([]string{e.cmd.Path}, ctx.TaskEnv.ParseAndReplace(command.Args)...)
e.cmd.Env = ctx.TaskEnv.EnvList()

// Apply ourselves into the cgroup. The executor MUST be in the cgroup
Expand All @@ -290,6 +271,13 @@ func (e *UniversalExecutor) LaunchCmd(command *ExecCommand, ctx *ExecutorContext
return nil, err
}

// Setup the loggers
if err := e.configureLoggers(); err != nil {
return nil, err
}
e.cmd.Stdout = e.lro
e.cmd.Stderr = e.lre

// Start the process
if err := e.cmd.Start(); err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions client/driver/executor/executor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ func (e *UniversalExecutor) configureChroot() error {
return err
}

rel, err := filepath.Rel(e.taskDir, e.cmd.Path)
if err != nil {
return err
}
e.cmd.Path = rel

return nil
}

Expand Down

0 comments on commit 12f3da9

Please sign in to comment.