From b20619e5b0dfa6c63b25c3fd9a7ae6188bee2b4c Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 17 Jun 2020 15:31:53 -0400 Subject: 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 --- pkg/domain/infra/abi/containers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/domain') diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 8e0ffc075..22de28a1c 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -999,7 +999,7 @@ func (ic *ContainerEngine) ContainerInit(ctx context.Context, namesOrIds []strin reports := make([]*entities.ContainerInitReport, 0, len(ctrs)) for _, ctr := range ctrs { report := entities.ContainerInitReport{Id: ctr.ID()} - err := ctr.Init(ctx) + err := ctr.Init(ctx, ctr.PodID() != "") // If we're initializing all containers, ignore invalid state errors if options.All && errors.Cause(err) == define.ErrCtrStateInvalid { -- cgit v1.2.3-54-g00ecf