diff --git a/.cirrus.yml b/.cirrus.yml index a20a9223e144..d3b80ccb8fcd 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -59,6 +59,7 @@ env: VM_IMAGE_NAME: # One of the "Google-cloud VM Images" (above) CTR_FQIN: # One of the "Container FQIN's" (above) CI_DESIRED_DATABASE: boltdb # One of "", "sqlite", "boltdb" + CI_DESIRED_STORAGE: overlay # overlay or vfs # Curl-command prefix for downloading task artifacts, simply add the # the url-encoded task name, artifact name, and path as a suffix. @@ -120,6 +121,7 @@ build_task: CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} CI_DESIRED_RUNTIME: crun CI_DESIRED_NETWORK: cni + CI_DESIRED_STORAGE: vfs # Catch invalid "TMPDIR == /tmp" assumptions; PR #19281 TMPDIR: /var/tmp - env: diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 7ca88417f78a..945f25684a7f 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -95,7 +95,7 @@ EPOCH_TEST_COMMIT="$CIRRUS_BASE_SHA" # contexts, such as host->container or root->rootless user # # List of envariables which must be EXACT matches -PASSTHROUGH_ENV_EXACT='CGROUP_MANAGER|DEST_BRANCH|DISTRO_NV|GOCACHE|GOPATH|GOSRC|NETWORK_BACKEND|OCI_RUNTIME|ROOTLESS_USER|SCRIPT_BASE|SKIP_USERNS|EC2_INST_TYPE|PODMAN_DB' +PASSTHROUGH_ENV_EXACT='CGROUP_MANAGER|DEST_BRANCH|DISTRO_NV|GOCACHE|GOPATH|GOSRC|NETWORK_BACKEND|OCI_RUNTIME|ROOTLESS_USER|SCRIPT_BASE|SKIP_USERNS|EC2_INST_TYPE|PODMAN_DB|STORAGE_FS' # List of envariable patterns which must match AT THE BEGINNING of the name. PASSTHROUGH_ENV_ATSTART='CI|LANG|LC_|TEST' diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh index d416299b4c85..d89748ac1bde 100755 --- a/contrib/cirrus/setup_environment.sh +++ b/contrib/cirrus/setup_environment.sh @@ -103,21 +103,19 @@ esac # shellcheck disable=SC2154 printf "[engine]\ndatabase_backend=\"$CI_DESIRED_DATABASE\"\n" > /etc/containers/containers.conf.d/92-db.conf -# For debian envs pre-configure storage driver as overlay. -# See: Discussion here https://github.com/containers/podman/pull/18510#discussion_r1189812306 -# for more details. -# TODO: remove this once all CI VM have newer buildah version. (i.e where buildah -# does not defaults to using `vfs` as storage driver) +# Force the requested storage driver; this applies only to system tests. # shellcheck disable=SC2154 -if [[ "$OS_RELEASE_ID" == "debian" ]]; then - showrun echo "conditional setup for debian" - conf=/etc/containers/storage.conf - if [[ -e $conf ]]; then - die "FATAL! INTERNAL ERROR! Cannot override $conf" - fi - msg "Overriding $conf, setting overlay (was: $buildah_storage)" - printf '[storage]\ndriver = "overlay"\nrunroot = "/run/containers/storage"\ngraphroot = "/var/lib/containers/storage"\n' >$conf +showrun echo "Setting up containers.conf for CI_DESIRED_STORAGE=$CI_DESIRED_STORAGE" +conf=/etc/containers/storage.conf +if [[ -e $conf ]]; then + die "FATAL! INTERNAL ERROR! Cannot override $conf" fi +cat <$conf +[storage] +driver = "$CI_DESIRED_STORAGE" +runroot = "/run/containers/storage" +graphroot = "/var/lib/containers/storage" +EOF if ((CONTAINER==0)); then # Not yet running inside a container showrun echo "conditional setup for CONTAINER == 0" @@ -199,6 +197,10 @@ case "$CI_DESIRED_DATABASE" in ;; esac +# shellcheck disable=SC2154 +showrun echo "about to set up for CI_DESIRED_STORAGE [=$CI_DESIRED_STORAGE]" +echo "STORAGE_FS=$CI_DESIRED_STORAGE" >>/etc/ci_environment + # Required to be defined by caller: The environment where primary testing happens # shellcheck disable=SC2154 showrun echo "about to set up for TEST_ENVIRON [=$TEST_ENVIRON]" diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 927b0407a018..48558cee40a4 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -973,13 +973,25 @@ func populateCache(podman *PodmanTestIntegration) { // rmAll removes the directory and its content, when running rootless we use // podman unshare to prevent any subuid/gid problems func rmAll(podmanBin string, path string) { + // When using overlay, podman leaves a stray mount behind. This + // leak causes remote tests to take a loooooong time, and time out. + overlayPath := path + "/root/overlay" + if _, err := os.Stat(overlayPath); err == nil { + umount := exec.Command("umount", overlayPath) + umount.Stdout = GinkgoWriter + umount.Stderr = GinkgoWriter + if err = umount.Run(); err != nil { + GinkgoWriter.Printf("Error umounting %s: %v\n", overlayPath, err) + } + } + // Remove cache dirs if isRootless() { // If rootless, os.RemoveAll() is failed due to permission denied cmd := exec.Command(podmanBin, "unshare", "rm", "-rf", path) cmd.Stdout = GinkgoWriter cmd.Stderr = GinkgoWriter - if err := cmd.Run(); err != nil { + if err = cmd.Run(); err != nil { GinkgoWriter.Printf("%v\n", err) } } else { diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go index 24c3de22abbf..bbe6c81b8c9a 100644 --- a/test/e2e/info_test.go +++ b/test/e2e/info_test.go @@ -185,6 +185,21 @@ var _ = Describe("Podman Info", func() { Expect(session.OutputToString()).To(Equal(want)) }) + It("Podman info: check desired storage driver", func() { + // defined in .cirrus.yml + want := os.Getenv("CI_DESIRED_STORAGE") + if want == "" { + if os.Getenv("CIRRUS_CI") == "" { + Skip("CI_DESIRED_STORAGE is not set--this is OK because we're not running under Cirrus") + } + Fail("CIRRUS_CI is set, but CI_DESIRED_STORAGE is not! See #20161") + } + session := podmanTest.Podman([]string{"info", "--format", "{{.Store.GraphDriverName}}"}) + session.WaitWithDefaultTimeout() + Expect(session).To(ExitCleanly()) + Expect(session.OutputToString()).To(Equal(want), ".Store.GraphDriverName from podman info") + }) + It("Podman info: check lock count", Serial, func() { // This should not run on architectures and OSes that use the file locks backend. // Which, for now, is Linux + RISCV and FreeBSD, neither of which are in CI - so diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 0fea12229ee6..8c4e9002ced5 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -66,6 +66,10 @@ var _ = Describe("Podman pull", func() { It("podman pull and run on split imagestore", func() { SkipIfRemote("podman-remote does not support setting external imagestore") + // Fails in run with "Error: creating container storage: creating read-write layer with ID "SHA1": Stat /.../root/overlay/SHA2/diff: ENOENT + if podmanTest.ImageCacheFS == "overlay" { + Skip("FIXME: #19748: test fails under overlayfs") + } imgName := "splitstoretest" // Make alpine write-able diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats index 7f865c512f4f..82530c392432 100644 --- a/test/system/001-basic.bats +++ b/test/system/001-basic.bats @@ -53,6 +53,7 @@ function setup() { 'Cgroups:{{.Host.CgroupsVersion}}+{{.Host.CgroupManager}}' 'Net:{{.Host.NetworkBackend}}' 'DB:{{.Host.DatabaseBackend}}' + 'Store:{{.Store.GraphDriverName}}' ) run_podman info --format "$(IFS='/' echo ${want[@]})" echo "# $output" >&3 diff --git a/test/system/005-info.bats b/test/system/005-info.bats index 54ee820cf02c..252cb12cf1b5 100644 --- a/test/system/005-info.bats +++ b/test/system/005-info.bats @@ -113,6 +113,22 @@ host.slirp4netns.executable | $expr_path is "$output" "$CI_DESIRED_DATABASE" "CI_DESIRED_DATABASE (from .cirrus.yml)" } +@test "podman info - confirm desired storage driver" { + if [[ -z "$CI_DESIRED_STORAGE" ]]; then + # When running in Cirrus, CI_DESIRED_STORAGE *must* be defined + # in .cirrus.yml so we can double-check that all CI VMs are + # using overlay or vfs as desired. + if [[ -n "$CIRRUS_CI" ]]; then + die "CIRRUS_CI is set, but CI_DESIRED_STORAGE is not! See #20161" + fi + + # Not running under Cirrus (e.g., gating tests, or dev laptop). + # Totally OK to skip this test. + skip "CI_DESIRED_STORAGE is unset--OK, because we're not in Cirrus" + fi + + is "$(podman_storage_driver)" "$CI_DESIRED_STORAGE" "podman storage driver is not CI_DESIRED_STORAGE (from .cirrus.yml)" +} # 2021-04-06 discussed in watercooler: RHEL must never use crun, even if # using cgroups v2. @@ -159,7 +175,7 @@ host.slirp4netns.executable | $expr_path @test "podman --root PATH info - basic output" { if ! is_remote; then run_podman --storage-driver=vfs --root ${PODMAN_TMPDIR}/nothing-here-move-along info --format '{{ .Store.GraphOptions }}' - is "$output" "map\[\]" "'podman --root should reset Graphoptions to []" + is "$output" "map\[\]" "'podman --root should reset GraphOptions to []" fi } diff --git a/test/system/010-images.bats b/test/system/010-images.bats index fafab6aa8e60..f6f6d0673e96 100644 --- a/test/system/010-images.bats +++ b/test/system/010-images.bats @@ -337,28 +337,34 @@ Deleted: $pauseID" @test "podman pull image with additional store" { skip_if_remote "only works on local" + # overlay or vfs + local storagedriver="$(podman_storage_driver)" + local imstore=$PODMAN_TMPDIR/imagestore local sconf=$PODMAN_TMPDIR/storage.conf cat >$sconf <>$test_script </dev/null; then die "Able to run 'ls $path' without error" @@ -67,8 +74,9 @@ else fi fi -exit 0 EOF + fi + echo "exit 0" >>$test_script chmod 755 $PODMAN_TMPDIR $test_script # get podman image and container storage directories diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 3fcd69a60ab9..abdcf336b468 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -564,6 +564,18 @@ function podman_runtime() { basename "${output:-[null]}" } +# Returns the storage driver, 'overlay' or 'vfs' +function podman_storage_driver() { + run_podman info --format '{{.Store.GraphDriverName}}' >/dev/null + # Should there ever be a new driver + case "$output" in + overlay) ;; + vfs) ;; + *) die "Unknown storage driver '$output'; if this is a new driver, please review uses of this function in tests." ;; + esac + echo "$output" +} + # rhbz#1895105: rootless journald is unavailable except to users in # certain magic groups; which our testuser account does not belong to # (intentional: that is the RHEL default, so that's the setup we test).