Skip to content

Commit

Permalink
Improve container_start to handle short living containers (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
towe75 authored Feb 25, 2021
1 parent 64d9535 commit bf21e15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/container_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 3 additions & 2 deletions api/container_wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit bf21e15

Please sign in to comment.