From 7f3f49139694e447a05522efce97d3f8516d0ea2 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 9 Jul 2018 14:17:41 -0500 Subject: create conmon sockets when getting their paths when using the getattachsockets endpoint, which returns the sockets needed to create and use a terminal, we should check if the container is just in the configured state. if so, we need to perform a container init to have conmon create the required sockets so we can attach to them prior to starting the container. Signed-off-by: baude Closes: #1067 Approved by: jwhonce --- pkg/varlinkapi/containers.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pkg/varlinkapi') diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index 391bbb350..6678b6f7a 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -462,6 +462,20 @@ func (i *LibpodAPI) GetAttachSockets(call ioprojectatomicpodman.VarlinkCall, nam if err != nil { return call.ReplyContainerNotFound(name) } + + status, err := ctr.State() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + + // If the container hasn't been run, we need to run init + // so the conmon sockets get created. + if status == libpod.ContainerStateConfigured || status == libpod.ContainerStateStopped { + if err := ctr.Init(getContext()); err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + } + s := ioprojectatomicpodman.Sockets{ Container_id: ctr.ID(), Io_socket: ctr.AttachSocketPath(), -- cgit v1.2.3-54-g00ecf