mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
libpod: wait another interval for healthcheck
wait for another interval when the container transitioned to "stopped" to give more time to the healthcheck status to change. Closes: https://github.com/containers/podman/issues/22760 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -767,7 +767,7 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
stoppedCount := 0
|
||||||
for {
|
for {
|
||||||
if len(wantedStates) > 0 {
|
if len(wantedStates) > 0 {
|
||||||
state, err := c.State()
|
state, err := c.State()
|
||||||
@ -784,10 +784,17 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
|
|||||||
// even if we are interested only in the health check
|
// even if we are interested only in the health check
|
||||||
// check that the container is still running to avoid
|
// check that the container is still running to avoid
|
||||||
// waiting until the timeout expires.
|
// waiting until the timeout expires.
|
||||||
state, err := c.State()
|
if stoppedCount > 0 {
|
||||||
if err != nil {
|
stoppedCount++
|
||||||
trySend(-1, err)
|
} else {
|
||||||
return
|
state, err := c.State()
|
||||||
|
if err != nil {
|
||||||
|
trySend(-1, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if state != define.ContainerStateCreated && state != define.ContainerStateRunning && state != define.ContainerStatePaused {
|
||||||
|
stoppedCount++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
status, err := c.HealthCheckStatus()
|
status, err := c.HealthCheckStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -798,7 +805,9 @@ 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 {
|
// wait for another waitTimeout interval to give the health check process some time
|
||||||
|
// to record the healthy status.
|
||||||
|
if stoppedCount > 1 {
|
||||||
trySend(-1, define.ErrCtrStopped)
|
trySend(-1, define.ErrCtrStopped)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user