mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Merge pull request #3480 from mheon/potential_ps_test_fix
Restart failed containers in tests
This commit is contained in:
@ -530,6 +530,19 @@ func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
|
|||||||
if hc.ExitCode() == 0 {
|
if hc.ExitCode() == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// Restart container if it's not running
|
||||||
|
ps := p.Podman([]string{"ps", "--no-trunc", "--q", "--filter", fmt.Sprintf("id=%s", cid)})
|
||||||
|
ps.WaitWithDefaultTimeout()
|
||||||
|
if ps.ExitCode() == 0 {
|
||||||
|
if !strings.Contains(ps.OutputToString(), cid) {
|
||||||
|
fmt.Printf("Container %s is not running, restarting", cid)
|
||||||
|
restart := p.Podman([]string{"restart", cid})
|
||||||
|
restart.WaitWithDefaultTimeout()
|
||||||
|
if restart.ExitCode() != 0 {
|
||||||
|
return errors.Errorf("unable to restart %s", cid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
fmt.Printf("Waiting for %s to pass healthcheck\n", cid)
|
fmt.Printf("Waiting for %s to pass healthcheck\n", cid)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user