kubelet/rkt: return util/exec.ExitError if exec probing fails.

This enables the prober to return probe.Failure instead of
probe.Unknown.
This commit is contained in:
Yifan Gu 2015-10-07 18:38:01 -07:00
parent 43f9280a5d
commit 2c318bfee2

View File

@ -27,6 +27,7 @@ import (
"path"
"strconv"
"strings"
"syscall"
"time"
appcschema "github.com/appc/spec/schema"
@ -46,6 +47,7 @@ import (
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
utilexec "k8s.io/kubernetes/pkg/util/exec"
)
const (
@ -1108,8 +1110,25 @@ func (r *Runtime) RunInContainer(containerID string, cmd []string) ([]byte, erro
args := append([]string{}, "enter", fmt.Sprintf("--app=%s", id.appName), id.uuid)
args = append(args, cmd...)
result, err := r.runCommand(args...)
return []byte(strings.Join(result, "\n")), err
result, err := r.buildCommand(args...).CombinedOutput()
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
err = &rktExitError{exitErr}
}
}
return result, err
}
// rktExitError implemets /pkg/util/exec.ExitError interface.
type rktExitError struct{ *exec.ExitError }
var _ utilexec.ExitError = &rktExitError{}
func (r *rktExitError) ExitStatus() int {
if status, ok := r.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus()
}
return 0
}
func (r *Runtime) AttachContainer(containerID string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error {