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 <bbaude@redhat.com>

Closes: #1067
Approved by: jwhonce
This commit is contained in:
baude 2018-07-09 14:17:41 -05:00 committed by Atomic Bot
parent 1219a3cab3
commit 7f3f491396
1 changed files with 14 additions and 0 deletions

View File

@ -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(),