test/e2e: try to fix clean up after terminated build flake

It is failing with:
replacing mount point ".../root/overlay/xxx/merged": directory not empty

First, the build does not need network so ensure we don't leak network
allocations by killing it. Second, kill is always async so ensure to
wait for the actul build process exit.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-11-07 15:04:20 +01:00
parent 6a2f1cfecc
commit b63a210dd9

View File

@@ -12,6 +12,7 @@ import (
. "github.com/containers/podman/v6/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var pruneImage = fmt.Sprintf(`
@@ -601,7 +602,7 @@ var _ = Describe("Podman prune", func() {
err := os.WriteFile(containerFilePath, []byte(longBuildImage), 0o755)
Expect(err).ToNot(HaveOccurred())
build := podmanTest.Podman([]string{"build", "-f", containerFilePath, "-t", "podmanleaker"})
build := podmanTest.Podman([]string{"build", "--network=none", "-f", containerFilePath, "-t", "podmanleaker"})
// Build will never finish so let's wait for build to ask for SIGKILL to simulate a failed build that leaves stage containers.
matchedOutput := false
for range 900 {
@@ -616,6 +617,10 @@ var _ = Describe("Podman prune", func() {
Fail("Did not match special string in podman build")
}
// kill is async, wait for process exit here and make sure it was killed (137).
build.WaitWithDefaultTimeout()
Expect(build).To(Exit(137))
// Check Intermediate image of stage container
none := podmanTest.Podman([]string{"images", "-a"})
none.WaitWithDefaultTimeout()