From ec0126564352b4e7258164a151b8a4aca1de0154 Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Mon, 4 May 2015 16:01:32 -0700 Subject: [PATCH] Fix docker exec logic. Without this patch, kubelet was not receiving any output from docker exec and was incorrectly handling the output. --- pkg/kubelet/dockertools/manager.go | 15 +++++---------- pkg/probe/exec/exec.go | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/kubelet/dockertools/manager.go b/pkg/kubelet/dockertools/manager.go index 20113701925..d31896fd0b5 100644 --- a/pkg/kubelet/dockertools/manager.go +++ b/pkg/kubelet/dockertools/manager.go @@ -17,7 +17,6 @@ limitations under the License. package dockertools import ( - "bufio" "bytes" "errors" "fmt" @@ -898,20 +897,16 @@ func (dm *DockerManager) RunInContainer(containerID string, cmd []string) ([]byt return nil, fmt.Errorf("failed to run in container - Exec setup failed - %v", err) } var buf bytes.Buffer - wrBuf := bufio.NewWriter(&buf) startOpts := docker.StartExecOptions{ Detach: false, Tty: false, - OutputStream: wrBuf, - ErrorStream: wrBuf, + OutputStream: &buf, + ErrorStream: &buf, RawTerminal: false, } - errChan := make(chan error, 1) - go func() { - errChan <- dm.client.StartExec(execObj.ID, startOpts) - }() - wrBuf.Flush() - return buf.Bytes(), <-errChan + err = dm.client.StartExec(execObj.ID, startOpts) + + return buf.Bytes(), err } // ExecInContainer uses nsenter to run the command inside the container identified by containerID. diff --git a/pkg/probe/exec/exec.go b/pkg/probe/exec/exec.go index a34db08508b..ce1858d0542 100644 --- a/pkg/probe/exec/exec.go +++ b/pkg/probe/exec/exec.go @@ -43,7 +43,7 @@ func (pr execProber) Probe(e uexec.Cmd) (probe.Result, error) { if err != nil { return probe.Unknown, err } - if strings.ToLower(string(data)) != defaultHealthyOutput { + if !strings.HasPrefix(strings.ToLower(string(data)), defaultHealthyOutput) { return probe.Failure, nil } return probe.Success, nil