Merge pull request #5347 from baude/apiv2wait

rework apiv2 wait endpoint|binding
This commit is contained in:
OpenShift Merge Robot
2020-03-02 20:23:26 +01:00
committed by GitHub
13 changed files with 161 additions and 60 deletions

View File

@ -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 {