Attempt to make more thorough use of cached copies of images during
integration tests, except in tests which need to pull a new image while
they're running, either because they test pulling directly, or because
they expect to pull a given image for a non-default platform or for
multiple platforms.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Regular primitive bats uses assertions like '[ $foo = something ]'.
These are worthless for debugging: when they fail, all you know
is that foo is not "something" but you don't know what foo _is_.
Find and replace those assertions with 'assert', which is
more informative. Instances found via:
$ ack '^ *\[' tests/*.bats
There are many matches for 'test' (instead of '[') but those
mostly look like file-existence ones, which are less evil
than string-check tests. I'm leaving those be for now.
Signed-off-by: Ed Santiago <santiago@redhat.com>
In linux, directory can contains colon.
Add support to mount path contains colon.
buildah run --volume /root/a\\🅱️/root/test:O
Signed-off-by: chenk008 <kongchen28@gmail.com>
Overlay mounts should work like volume bind mounts and preserve the
underlyng source directories permissions.
Fixes: https://github.com/containers/podman/issues/9947
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Fix a mismatch between "$permissions" being set and "$permission" being
read.
Don't expect changes made to an overlay mount in a working container to
persist between subsequent "buildah run" invocations, since they don't.
Use 'stat -c %a' rather than 'ls -l | cut -f1 -d " "' to read the
permissions on a mount upper directory, so that different versions of
"ls" appending "." to "drwxrwx---" (or not) doesn't cause unexpected
mismatches.
Create a file in the lower directory before checking that our attempt to
remove it in the upper layer succeeds.
Expect error code 1 when "buildah run $container ls" can't find a file
which we know whouldn't exist, rather than 125.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When we're using the overlay driver (which means we know overlay is
available), use it to make volumes appear to be writeable during RUN
instructions instead of saving/restoring their contents.
This avoids having to copy the contents of the volume directory before
each RUN instruction, and having to remove and extract the contents
after each RUN instruction, which should be faster, particularly if the
amount of content in that volume location is large.
For empty directories, it will at least avoid adding an "opaque"
notation for the directory in a layer that might otherwise be empty.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
We are setting the permissions based on the dest dir rather
then the source dir. Since we want this to work identical to a bind
mount, we need to have the permissions align.
There is also an issue where overlays on existing mounts is blowing up.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
When we mount over a destination directory inside of the container
we need to preserve the mode of the destination.
Needed to fix: https://github.com/containers/podman/issues/8801
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Buildah run was exiting with the correct exit code, when a container
failed. Buildah bud was not, so this should fix this.
Also switched to the proper exit codes when containers fail. When
Buildah fails to execute it will exit with a 125 exit code like
Podman does. If a command fails to execute inside of a container
we will exit with a 126. Currently we do not support the 127 for
exiting when the command does not exist.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Replace this pattern:
cid=$(buildah ...)
with:
run_buildah ...
cid=$output
As a special case, if the buildah command is 'from' and the
string 'scratch' does not appear in the arguments, add '--quiet'.
Otherwise we'll get Pulling messages as part of $output. This
is an overkill solution.
For ease of review, this commit was entirely machine-generated via:
$ perl -pi -e 's{^(\s+)(\S+)=\$\(buildah (.*)\)$}{$indent=$1;$var=$2;$cmd=$3; $cmd =~ s/(\bfrom)\s(?!.*scratch)/$1 --quiet $2/; "${indent}run_buildah $cmd\n$indent$var=\$output"}e' *.bats
Signed-off-by: Ed Santiago <santiago@redhat.com>
Closes: #2029
Approved by: rhatdan
PR #1935 removed the default --debug logging; so all run_buildah
calls now use the default (error). It is safe to remove unnecessary
instances of --log-level=error .
For ease of review, this commit was entirely machine-generated via:
$ perl -pi -e 's/ --log-level=error / /' *.bats
Signed-off-by: Ed Santiago <santiago@redhat.com>
Closes: #2029
Approved by: rhatdan
The previous log-level implementation does not seem to work, which is
now fixed and aligns to other projects like podman and CRI-O. Therefore
the `--debug` flag has been deprecated and is now hidden.
Added documentation as well as integration tests.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1811
Approved by: rhatdan
Overlay mounts allow buildah bud and buildah from to
specify a directory on the disk that will be mounted
as an overlay into the container, where the overlay can be written to
but when the RUN or buildah run exits, the modified files will dissapear.
The basic idea is to be able to mount cache from the disk for things like yum/dnf/apt
to be able to be used and modified in the contianer on a run command, but to be
kept fresh for each RUN.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #1560
Approved by: giuseppe