dockertools/nsenterexec: fix err shadow

The shadow of err meant the combination of `exec-handler=nsenter` +
`tty` + a non-zero exit code meant that the exit code would be LOST
FOREVER 👻

This isn't all that important since no one really used the nsenter exec
handler as I understand it
This commit is contained in:
Euan Kemp 2017-01-19 09:28:16 -08:00
parent fe69dcf861
commit d55776e85a

View File

@ -53,6 +53,7 @@ func (*NsenterExecHandler) ExecInContainer(client DockerInterface, container *do
args = append(args, container.Config.Env...) args = append(args, container.Config.Env...)
args = append(args, cmd...) args = append(args, cmd...)
command := exec.Command(nsenter, args...) command := exec.Command(nsenter, args...)
var cmdErr error
if tty { if tty {
p, err := kubecontainer.StartPty(command) p, err := kubecontainer.StartPty(command)
if err != nil { if err != nil {
@ -75,7 +76,7 @@ func (*NsenterExecHandler) ExecInContainer(client DockerInterface, container *do
go io.Copy(stdout, p) go io.Copy(stdout, p)
} }
err = command.Wait() cmdErr = command.Wait()
} else { } else {
if stdin != nil { if stdin != nil {
// Use an os.Pipe here as it returns true *os.File objects. // Use an os.Pipe here as it returns true *os.File objects.
@ -97,13 +98,13 @@ func (*NsenterExecHandler) ExecInContainer(client DockerInterface, container *do
command.Stderr = stderr command.Stderr = stderr
} }
err = command.Run() cmdErr = command.Run()
} }
if exitErr, ok := err.(*exec.ExitError); ok { if exitErr, ok := cmdErr.(*exec.ExitError); ok {
return &utilexec.ExitErrorWrapper{ExitError: exitErr} return &utilexec.ExitErrorWrapper{ExitError: exitErr}
} }
return err return cmdErr
} }
// NativeExecHandler executes commands in Docker containers using Docker's exec API. // NativeExecHandler executes commands in Docker containers using Docker's exec API.