summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-05-08 08:33:44 -0700
committerJhon Honce <jhonce@redhat.com>2020-05-13 11:49:17 -0700
commitb6113e2b9ea8f397e345a09335c26f953994c6f4 (patch)
tree5dfe310f20bc1b0ad5cadb84ef8416253df438ad /libpod
parentd147b3ee027580dd7afdeb0fa04d990ae1d2ee91 (diff)
downloadpodman-b6113e2b9ea8f397e345a09335c26f953994c6f4.tar.gz
podman-b6113e2b9ea8f397e345a09335c26f953994c6f4.tar.bz2
podman-b6113e2b9ea8f397e345a09335c26f953994c6f4.zip
WIP V2 attach bindings and test
* Add ErrLostSync to report lost of sync when de-mux'ing stream * Add logus.SetLevel(logrus.DebugLevel) when `go test -v` given * Add context to debugging messages Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go5
-rw-r--r--libpod/oci_conmon_linux.go2
-rw-r--r--libpod/util.go9
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
}