diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-05-13 12:30:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 12:30:14 -0700 |
commit | 71f66f03c5dcf8ab65c741e64c60ce12b01218a8 (patch) | |
tree | 3000cb5cb03f019dd8b18386330552ca109e2612 /libpod | |
parent | 886b2cc4b10c32611b45da983fa9d1318d38356a (diff) | |
parent | b6113e2b9ea8f397e345a09335c26f953994c6f4 (diff) | |
download | podman-71f66f03c5dcf8ab65c741e64c60ce12b01218a8.tar.gz podman-71f66f03c5dcf8ab65c741e64c60ce12b01218a8.tar.bz2 podman-71f66f03c5dcf8ab65c741e64c60ce12b01218a8.zip |
Merge pull request #6203 from jwhonce/wip/attach
V2 attach bindings and test
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_api.go | 5 | ||||
-rw-r--r-- | libpod/oci_conmon_linux.go | 2 | ||||
-rw-r--r-- | libpod/util.go | 9 |
3 files changed, 9 insertions, 7 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index b31079b26..d366ffb84 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -285,6 +285,7 @@ func (c *Container) HTTPAttach(httpCon net.Conn, httpBuf *bufio.ReadWriter, stre logrus.Infof("Performing HTTP Hijack attach to container %s", c.ID()) + logSize := 0 if streamLogs { // Get all logs for the container logChan := make(chan *logs.LogLine) @@ -302,7 +303,7 @@ func (c *Container) HTTPAttach(httpCon net.Conn, httpBuf *bufio.ReadWriter, stre device := logLine.Device var header []byte headerLen := uint32(len(logLine.Msg)) - + logSize += len(logLine.Msg) switch strings.ToLower(device) { case "stdin": header = makeHTTPAttachHeader(0, headerLen) @@ -341,7 +342,7 @@ func (c *Container) HTTPAttach(httpCon net.Conn, httpBuf *bufio.ReadWriter, stre if err := c.ReadLog(logOpts, logChan); err != nil { return err } - logrus.Debugf("Done reading logs for container %s", c.ID()) + logrus.Debugf("Done reading logs for container %s, %d bytes", c.ID(), logSize) if err := <-errChan; err != nil { return err } diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index d59ff18ca..d1c1a1fc2 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -1704,6 +1704,8 @@ func httpAttachTerminalCopy(container *net.UnixConn, http *bufio.ReadWriter, cid buf := make([]byte, bufferSize) for { numR, err := container.Read(buf) + logrus.Debugf("Read fd(%d) %d/%d bytes for container %s", int(buf[0]), numR, len(buf), cid) + if numR > 0 { switch buf[0] { case AttachPipeStdout: diff --git a/libpod/util.go b/libpod/util.go index bdfd153ed..ba9f1fa05 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -249,9 +249,8 @@ func hijackWriteErrorAndClose(toWrite error, cid string, terminal bool, httpCon // length and stream. Accepts an integer indicating which stream we are sending // to (STDIN = 0, STDOUT = 1, STDERR = 2). func makeHTTPAttachHeader(stream byte, length uint32) []byte { - headerBuf := []byte{stream, 0, 0, 0} - lenBuf := []byte{0, 0, 0, 0} - binary.BigEndian.PutUint32(lenBuf, length) - headerBuf = append(headerBuf, lenBuf...) - return headerBuf + header := make([]byte, 8) + header[0] = stream + binary.BigEndian.PutUint32(header[4:], length) + return header } |