Skip to content

Commit

Permalink
Merge pull request kubernetes#40159 from euank/beware-of-shadows
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 40011, 40159)

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

```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue authored Jan 20, 2017
2 parents c752a03 + d55776e commit 54ff406
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/kubelet/dockertools/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (*NsenterExecHandler) ExecInContainer(client DockerInterface, container *do
args = append(args, container.Config.Env...)
args = append(args, cmd...)
command := exec.Command(nsenter, args...)
var cmdErr error
if tty {
p, err := kubecontainer.StartPty(command)
if err != nil {
Expand All @@ -75,7 +76,7 @@ func (*NsenterExecHandler) ExecInContainer(client DockerInterface, container *do
go io.Copy(stdout, p)
}

err = command.Wait()
cmdErr = command.Wait()
} else {
if stdin != nil {
// Use an os.Pipe here as it returns true *os.File objects.
Expand All @@ -97,13 +98,13 @@ func (*NsenterExecHandler) ExecInContainer(client DockerInterface, container *do
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 err
return cmdErr
}

// NativeExecHandler executes commands in Docker containers using Docker's exec API.
Expand Down

0 comments on commit 54ff406

Please sign in to comment.