Merge pull request #26666 from euank/fix-wrong-err

Automatic merge from submit-queue

rkt: Wrap exec errors as utilexec.ExitError

This is needed by the exec prober to distinguish error types and exit
codes correctly. Without this, the exec prober used for liveness probes
doesn't identify errors correctly and restarts aren't triggered. Fixes #26456

An alternative, and preferable solution would be to use utilexec
everywhere, but that change is much more involved and should come at a
later date. Unfortunately, until that change is made, writing tests for
this is quite difficult.

cc @yifan-gu @sjpotter
This commit is contained in:
k8s-merge-robot 2016-06-04 05:11:16 -07:00
commit 8e091e254f

View File

@ -1876,6 +1876,13 @@ func (r *rktExitError) ExitStatus() int {
return 0
}
func newRktExitError(e error) error {
if exitErr, ok := e.(*exec.ExitError); ok {
return &rktExitError{exitErr}
}
return e
}
func (r *Runtime) AttachContainer(containerID kubecontainer.ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error {
return fmt.Errorf("unimplemented")
}
@ -1910,7 +1917,7 @@ func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []s
if stdout != nil {
go io.Copy(stdout, p)
}
return command.Wait()
return newRktExitError(command.Wait())
}
if stdin != nil {
// Use an os.Pipe here as it returns true *os.File objects.
@ -1919,7 +1926,7 @@ func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []s
// of the pipe.
r, w, err := r.os.Pipe()
if err != nil {
return err
return newRktExitError(err)
}
go io.Copy(w, stdin)
@ -1931,7 +1938,7 @@ func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []s
if stderr != nil {
command.Stderr = stderr
}
return command.Run()
return newRktExitError(command.Run())
}
// PortForward executes socat in the pod's network namespace and copies