From 1b8cdb2a167920b0a998d7caa4d0c0f4651bf7e5 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Wed, 24 Feb 2021 20:18:24 +0100 Subject: [PATCH 1/2] Improve container_start to improve startup of short living containers --- 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..651120f8 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 } From 6dd22f73f3defec87ca6ba3aad7740f998eb741e Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Wed, 24 Feb 2021 20:24:47 +0100 Subject: [PATCH 2/2] Gofmt --- api/container_start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/container_start.go b/api/container_start.go index 651120f8..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, []string{"running","exited"}) + err = c.ContainerWait(timeout, name, []string{"running", "exited"}) return err }