mirror of https://github.com/k3s-io/k3s
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
parent
fbe3ec7513
commit
ec01265643
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue