mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
rkt: Wrap exec errors as utilexec.ExitError
This is needed by the exec prober to distinguish error types and exit codes correctly. 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.
This commit is contained in:
parent
c1c0567e37
commit
40efc0fb33
@ -1857,6 +1857,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")
|
||||
}
|
||||
@ -1891,7 +1898,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.
|
||||
@ -1900,7 +1907,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)
|
||||
|
||||
@ -1912,7 +1919,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
|
||||
|
Loading…
Reference in New Issue
Block a user