mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
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:
parent
43f9280a5d
commit
2c318bfee2
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user