mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00
Allow recursive dependency start with Init()
As part of APIv2 Attach, we need to be able to attach to freshly created containers (in ContainerStateConfigured). This isn't something Libpod is interested in supporting, so we use Init() to get the container into ContainerStateCreated, in which attach is possible. Problem: Init() will fail if dependencies are not started, so a fresh container in a fresh pod will fail. The simplest solution is to extend the existing recursive start code from Start() to Init(), allowing dependency containers to be started when we initialize the container (optionally, controlled via bool). Also, update some comments in container_api.go to make it more clear how some of our major API calls work. Fixes #6646 Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:

committed by
Matthew Heon

parent
3eb0ad04a8
commit
b20619e5b0
@ -385,7 +385,7 @@ func (i *VarlinkAPI) InitContainer(call iopodman.VarlinkCall, name string) error
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name, err.Error())
|
||||
}
|
||||
if err := ctr.Init(getContext()); err != nil {
|
||||
if err := ctr.Init(getContext(), false); err != nil {
|
||||
if errors.Cause(err) == define.ErrCtrStateInvalid {
|
||||
return call.ReplyInvalidState(ctr.ID(), err.Error())
|
||||
}
|
||||
@ -557,7 +557,7 @@ func (i *VarlinkAPI) GetAttachSockets(call iopodman.VarlinkCall, name string) er
|
||||
// If the container hasn't been run, we need to run init
|
||||
// so the conmon sockets get created.
|
||||
if status == define.ContainerStateConfigured || status == define.ContainerStateStopped {
|
||||
if err := ctr.Init(getContext()); err != nil {
|
||||
if err := ctr.Init(getContext(), false); err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user