Skip to content

Commit

Permalink
podman create: building local pause image: do not read ignore files
Browse files Browse the repository at this point in the history
Make sure to ignore local {container,docker}ignore files when building a
local pause image.  Otherwise, we may mistakenly not be able to copy
catatonit into the build container.

Fixes: #13529
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Mar 17, 2022
1 parent fa33f35 commit ff54aaa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions pkg/specgen/generate/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ENTRYPOINT ["/catatonit", "-P"]`, catatonitPath)
CommonBuildOpts: &buildahDefine.CommonBuildOptions{},
Output: imageName,
Quiet: true,
IgnoreFile: "/dev/null", // makes sure to not read a local .ignorefile (see #13529)
IIDFile: "/dev/null", // prevents Buildah from writing the ID on stdout
}
if _, _, err := rt.Build(context.Background(), buildOptions, tmpF.Name()); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions test/system/010-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ Labels.created_at | 20[0-9-]\\\+T[0-9:]\\\+Z
run_podman inspect --format '{{.ID}}' $IMAGE
imageID=$output

run_podman version --format "{{.Server.Version}}-{{.Server.Built}}"
pauseImage=localhost/podman-pause:$output
pauseImage=$(pause_image)
run_podman inspect --format '{{.ID}}' $pauseImage
pauseID=$output

Expand Down
11 changes: 10 additions & 1 deletion test/system/070-build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ EOF
done
}

# Regression test for #9867
# Regression test for #9867 and #13529
# Make sure that if you exclude everything in context dir, that
# the Containerfile/Dockerfile in the context dir are used
@test "podman build with ignore '*'" {
Expand All @@ -620,6 +620,15 @@ cat >$tmpdir/.dockerignore <<EOF
*
EOF

# Prior to the fix for #13529, pod-create would fail with 'error building
# at STEP COPY .../catatonit' because of the local .dockerignore file was
# used.
pushd "${tmpdir}"
run_podman pod create
run_podman pod rm $output
run_podman rmi $(pause_image)
popd

run_podman build -t build_test $tmpdir

# Rename Containerfile to Dockerfile
Expand Down
8 changes: 1 addition & 7 deletions test/system/200-pod.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ load helpers
function teardown() {
run_podman pod rm -f -t 0 -a
run_podman rm -f -t 0 -a
run_podman image list --format '{{.ID}} {{.Repository}}'
while read id name; do
if [[ "$name" =~ /podman-pause ]]; then
run_podman rmi $id
fi
done <<<"$output"

run_podman ? rmi $(pause_image)
basic_teardown
}

Expand Down
9 changes: 9 additions & 0 deletions test/system/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ function journald_unavailable() {
return 1
}

# Returns the name of the local pause image.
function pause_image() {
# This function is intended to be used as '$(pause_image)', i.e.
# our caller wants our output. run_podman() messes with output because
# it emits the command invocation to stdout, hence the redirection.
run_podman version --format "{{.Server.Version}}-{{.Server.Built}}" >/dev/null
echo "localhost/podman-pause:$output"
}

###########################
# _add_label_if_missing # make sure skip messages include rootless/remote
###########################
Expand Down

0 comments on commit ff54aaa

Please sign in to comment.