Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more msg when exec probe timeout #106201

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/kubelet/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/probe/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 3 additions & 0 deletions pkg/probe/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"strings"
"testing"
"time"

"k8s.io/kubernetes/pkg/probe"
)
Expand Down Expand Up @@ -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{
Expand Down