Add an API for Attach over HTTP API

The new APIv2 branch provides an HTTP-based remote API to Podman.
The requirements of this are, unfortunately, incompatible with
the existing Attach API. For non-terminal attach, we need append
a header to what was copied from the container, to multiplex
STDOUT and STDERR; to do this with the old API, we'd need to copy
into an intermediate buffer first, to handle the headers.

To avoid this, provide a new API to handle all aspects of
terminal and non-terminal attach, including closing the hijacked
HTTP connection. This might be a bit too specific, but for now,
it seems to be the simplest approach.

At the same time, add a Resize endpoint. This needs to be a
separate endpoint, so our existing channel approach does not work
here.

I wanted to rework the rest of attach at the same time (some
parts of it, particularly how we start the Attach session and how
we do resizing, are (in my opinion) handled much better here.
That may still be on the table, but I wanted to avoid breaking
existing APIs in this already massive change.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
Matthew Heon
2020-01-10 13:37:10 -05:00
parent db00ee97e9
commit ac47e80b07
14 changed files with 950 additions and 2 deletions

View File

@ -0,0 +1,19 @@
package config
const (
// BufSize is the size of buffers passed in to sockets
BufSize = 8192
// ConnSockBufSize is the size of the socket used for
// to attach to the container
ConnSockBufSize = 32768
// WinResizeEvent is the event code the caller program will
// send along the ctrl fd to signal conmon to resize
// the pty window
WinResizeEvent = 1
// ReopenLogsEvent is the event code the caller program will
// send along the ctrl fd to signal conmon to reopen the log files
ReopenLogsEvent = 2
// TimedOutMessage is the message sent back to the caller by conmon
// when a container times out
TimedOutMessage = "command timed out"
)

View File

@ -0,0 +1,7 @@
// +build !windows
package config
const (
ContainerAttachSocketDir = "/var/run/crio"
)

View File

@ -0,0 +1,7 @@
// +build windows
package config
const (
ContainerAttachSocketDir = "C:\\crio\\run\\"
)