diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-02 20:23:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-02 20:23:26 +0100 |
commit | 47c4ea39196cedac87e7a4e4c1ead54ed9d7ed50 (patch) | |
tree | 64ce3ceb630aaecf993b1747bf8ba7f3f3af170f /libpod | |
parent | f9a476833bc8461dd246db0b31f542ad4a6d7587 (diff) | |
parent | 09048731000e73b44a0243a0339d8c122eb8a165 (diff) | |
download | podman-47c4ea39196cedac87e7a4e4c1ead54ed9d7ed50.tar.gz podman-47c4ea39196cedac87e7a4e4c1ead54ed9d7ed50.tar.bz2 podman-47c4ea39196cedac87e7a4e4c1ead54ed9d7ed50.zip |
Merge pull request #5347 from baude/apiv2wait
rework apiv2 wait endpoint|binding
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_api.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index dabbe27dc..aa932e0b8 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -624,6 +624,26 @@ func (c *Container) WaitWithInterval(waitTimeout time.Duration) (int32, error) { } } +func (c *Container) WaitForConditionWithInterval(waitTimeout time.Duration, condition define.ContainerStatus) (int32, error) { + if !c.valid { + return -1, define.ErrCtrRemoved + } + if condition == define.ContainerStateStopped || condition == define.ContainerStateExited { + return c.WaitWithInterval(waitTimeout) + } + for { + state, err := c.State() + if err != nil { + return -1, err + } + if state == condition { + break + } + time.Sleep(waitTimeout) + } + return -1, nil +} + // Cleanup unmounts all mount points in container and cleans up container storage // It also cleans up the network stack func (c *Container) Cleanup(ctx context.Context) error { |