Skip to content

Commit

Permalink
Fix race condition in running ls container in a pod
Browse files Browse the repository at this point in the history
All of the tests has an assumption that RunLsContainer and RunLsContainerInPod completes
the container before returning.  But since the container is running
in back ground mode, the container could be still running before tools
attempt to remove it. Removing the "-d" from the command fixes the
container to match the assumption.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed May 25, 2021
1 parent a6f0ac2 commit 9ab3fd8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,14 @@ func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionInteg
podmanArgs = append(podmanArgs, "-d", ALPINE, "ls")
session := p.Podman(podmanArgs)
session.WaitWithDefaultTimeout()
return session, session.ExitCode(), session.OutputToString()
if session.ExitCode() != 0 {
return session, session.ExitCode(), session.OutputToString()
}
cid := session.OutputToString()

wsession := p.Podman([]string{"wait", cid})
wsession.WaitWithDefaultTimeout()
return session, wsession.ExitCode(), cid
}

// RunNginxWithHealthCheck runs the alpine nginx container with an optional name and adds a healthcheck into it
Expand All @@ -431,7 +438,14 @@ func (p *PodmanTestIntegration) RunLsContainerInPod(name, pod string) (*PodmanSe
podmanArgs = append(podmanArgs, "-d", ALPINE, "ls")
session := p.Podman(podmanArgs)
session.WaitWithDefaultTimeout()
return session, session.ExitCode(), session.OutputToString()
if session.ExitCode() != 0 {
return session, session.ExitCode(), session.OutputToString()
}
cid := session.OutputToString()

wsession := p.Podman([]string{"wait", cid})
wsession.WaitWithDefaultTimeout()
return session, wsession.ExitCode(), cid
}

// BuildImage uses podman build and buildah to build an image
Expand Down

0 comments on commit 9ab3fd8

Please sign in to comment.