Commit 54ff4067 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #40159 from euank/beware-of-shadows

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 ```
parents c752a03b d55776e8
......@@ -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 {
......@@ -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.
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment