mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +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"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
appcschema "github.com/appc/spec/schema"
|
appcschema "github.com/appc/spec/schema"
|
||||||
@ -46,6 +47,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/securitycontext"
|
"k8s.io/kubernetes/pkg/securitycontext"
|
||||||
"k8s.io/kubernetes/pkg/types"
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
|
utilexec "k8s.io/kubernetes/pkg/util/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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([]string{}, "enter", fmt.Sprintf("--app=%s", id.appName), id.uuid)
|
||||||
args = append(args, cmd...)
|
args = append(args, cmd...)
|
||||||
|
|
||||||
result, err := r.runCommand(args...)
|
result, err := r.buildCommand(args...).CombinedOutput()
|
||||||
return []byte(strings.Join(result, "\n")), err
|
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 {
|
func (r *Runtime) AttachContainer(containerID string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user