Merge pull request #106201 from yxxhero/fea_106111

Add more msg when exec probe timeout
This commit is contained in:
Kubernetes Prow Robot 2021-11-15 17:51:37 -08:00 committed by GitHub
commit 39af75af30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -271,11 +271,11 @@ func (eic *execInContainer) Output() ([]byte, error) {
}
func (eic *execInContainer) SetDir(dir string) {
//unimplemented
// unimplemented
}
func (eic *execInContainer) SetStdin(in io.Reader) {
//unimplemented
// unimplemented
}
func (eic *execInContainer) SetStdout(out io.Writer) {
@ -287,11 +287,11 @@ func (eic *execInContainer) SetStderr(out io.Writer) {
}
func (eic *execInContainer) SetEnv(env []string) {
//unimplemented
// unimplemented
}
func (eic *execInContainer) Stop() {
//unimplemented
// unimplemented
}
func (eic *execInContainer) Start() error {

View File

@ -72,7 +72,8 @@ func (pr execProber) Probe(e exec.Cmd) (probe.Result, string, error) {
timeoutErr, ok := err.(*TimeoutError)
if ok {
if utilfeature.DefaultFeatureGate.Enabled(features.ExecProbeTimeout) {
return probe.Failure, string(data), nil
// When exec probe timeout, data is empty, so we should return timeoutErr.Error() as the stdout.
return probe.Failure, timeoutErr.Error(), nil
}
klog.Warningf("Exec probe timed out after %s but ExecProbeTimeout feature gate was disabled", timeoutErr.Timeout())

View File

@ -21,6 +21,7 @@ import (
"io"
"strings"
"testing"
"time"
"k8s.io/kubernetes/pkg/probe"
)
@ -122,6 +123,8 @@ func TestExec(t *testing.T) {
{probe.Unknown, true, "", "", fmt.Errorf("test error")},
// Unhealthy
{probe.Failure, false, "Fail", "", &fakeExitError{true, 1}},
// Timeout
{probe.Failure, false, "", "command testcmd timed out", NewTimeoutError(fmt.Errorf("command testcmd timed out"), time.Second)},
}
for i, test := range tests {
fake := FakeCmd{