Don't log EOF error when using podman --remote build with an empty context directory.

Closes #15921.

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
This commit is contained in:
Romain Geissler
2023-07-28 20:00:53 +00:00
parent b6a52f1f8b
commit 4ee31dc37f
2 changed files with 15 additions and 2 deletions

View File

@ -675,9 +675,10 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
}
defer p.Close()
_, err = p.Readdir(1)
if err != io.EOF {
if err == nil {
return nil // non empty root dir, need to return
} else if err != nil {
}
if err != io.EOF {
logrus.Errorf("While reading directory %v: %v", path, err)
}
}

View File

@ -1097,6 +1097,18 @@ EOF
run_podman rmi -f build_test
}
@test "podman build empty context dir" {
buildcontextdir=$PODMAN_TMPDIR/emptydir
mkdir -p $buildcontextdir
containerfile=$PODMAN_TMPDIR/Containerfile
echo FROM scratch >$containerfile
run_podman build -t build_test -f $containerfile $buildcontextdir
assert "$output" !~ "EOF" "output should not contain EOF error"
run_podman rmi -f build_test
}
function teardown() {
# A timeout or other error in 'build' can leave behind stale images
# that podman can't even see and which will cascade into subsequent