From bf21e157fc5124fbce0a44cae2f6a608b6cd466f Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Thu, 25 Feb 2021 07:30:52 +0100 Subject: [PATCH] Improve container_start to handle short living containers (#91) --- api/container_start.go | 2 +- api/container_wait.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/container_start.go b/api/container_start.go index cedf3249..71d6f886 100644 --- a/api/container_start.go +++ b/api/container_start.go @@ -28,6 +28,6 @@ func (c *API) ContainerStart(ctx context.Context, name string) error { timeout, cancel := context.WithTimeout(ctx, time.Second*10) defer cancel() - err = c.ContainerWait(timeout, name, "running") + err = c.ContainerWait(timeout, name, []string{"running", "exited"}) return err } diff --git a/api/container_wait.go b/api/container_wait.go index ac83a28c..e3e393e1 100644 --- a/api/container_wait.go +++ b/api/container_wait.go @@ -4,12 +4,13 @@ import ( "context" "fmt" "net/http" + "strings" ) // ContainerWait waits on a container to met a given condition -func (c *API) ContainerWait(ctx context.Context, name string, condition string) error { +func (c *API) ContainerWait(ctx context.Context, name string, conditions []string) error { - res, err := c.Post(ctx, fmt.Sprintf("/v1.0.0/libpod/containers/%s/wait?condition=%s", name, condition), nil) + res, err := c.Post(ctx, fmt.Sprintf("/v1.0.0/libpod/containers/%s/wait?condition=%s", name, strings.Join(conditions, "&condition=")), nil) if err != nil { return err }