mirror of
https://github.com/containers/podman.git
synced 2025-10-16 18:53:19 +08:00
container_api: do not wait for healtchecks if stopped
do not wait for the healthcheck status to change if the container is stopped. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -781,6 +781,14 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(wantedHealthStates) > 0 {
|
if len(wantedHealthStates) > 0 {
|
||||||
|
// even if we are interested only in the health check
|
||||||
|
// check that the container is still running to avoid
|
||||||
|
// waiting until the timeout expires.
|
||||||
|
state, err := c.State()
|
||||||
|
if err != nil {
|
||||||
|
trySend(-1, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
status, err := c.HealthCheckStatus()
|
status, err := c.HealthCheckStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
trySend(-1, err)
|
trySend(-1, err)
|
||||||
@ -790,6 +798,10 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
|||||||
trySend(-1, nil)
|
trySend(-1, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if state != define.ContainerStateCreated && state != define.ContainerStateRunning && state != define.ContainerStatePaused {
|
||||||
|
trySend(-1, define.ErrCtrStopped)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
Reference in New Issue
Block a user