Skip to content

Commit

Permalink
add more msg when exec probe timeout
Browse files Browse the repository at this point in the history
Signed-off-by: yxxhero <[email protected]>
  • Loading branch information
yxxhero committed Nov 6, 2021
1 parent 08bf546 commit 4211826
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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

0 comments on commit 4211826

Please sign in to comment.