Fix docker exec logic. Without this patch, kubelet was not receiving any output from docker exec

and was incorrectly handling the output.
pull/6/head
Vishnu Kannan 2015-05-04 16:01:32 -07:00
parent fbe3ec7513
commit ec01265643
2 changed files with 6 additions and 11 deletions

View File

@ -17,7 +17,6 @@ limitations under the License.
package dockertools package dockertools
import ( import (
"bufio"
"bytes" "bytes"
"errors" "errors"
"fmt" "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) return nil, fmt.Errorf("failed to run in container - Exec setup failed - %v", err)
} }
var buf bytes.Buffer var buf bytes.Buffer
wrBuf := bufio.NewWriter(&buf)
startOpts := docker.StartExecOptions{ startOpts := docker.StartExecOptions{
Detach: false, Detach: false,
Tty: false, Tty: false,
OutputStream: wrBuf, OutputStream: &buf,
ErrorStream: wrBuf, ErrorStream: &buf,
RawTerminal: false, RawTerminal: false,
} }
errChan := make(chan error, 1) err = dm.client.StartExec(execObj.ID, startOpts)
go func() {
errChan <- dm.client.StartExec(execObj.ID, startOpts) return buf.Bytes(), err
}()
wrBuf.Flush()
return buf.Bytes(), <-errChan
} }
// ExecInContainer uses nsenter to run the command inside the container identified by containerID. // ExecInContainer uses nsenter to run the command inside the container identified by containerID.

View File

@ -43,7 +43,7 @@ func (pr execProber) Probe(e uexec.Cmd) (probe.Result, error) {
if err != nil { if err != nil {
return probe.Unknown, err return probe.Unknown, err
} }
if strings.ToLower(string(data)) != defaultHealthyOutput { if !strings.HasPrefix(strings.ToLower(string(data)), defaultHealthyOutput) {
return probe.Failure, nil return probe.Failure, nil
} }
return probe.Success, nil return probe.Success, nil