diff options
39 files changed, 306 insertions, 108 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index b77464bae..194bcae52 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,13 +24,13 @@ env: #### #### Cache-image names to test with (double-quotes around names are critical) #### - FEDORA_NAME: "fedora-33" - PRIOR_FEDORA_NAME: "fedora-32" + FEDORA_NAME: "fedora-34beta" + PRIOR_FEDORA_NAME: "fedora-33" UBUNTU_NAME: "ubuntu-2010" PRIOR_UBUNTU_NAME: "ubuntu-2004" # Google-cloud VM Images - IMAGE_SUFFIX: "c5501386583441408" + IMAGE_SUFFIX: "c5032481331085312" FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}" PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}" UBUNTU_CACHE_IMAGE_NAME: "ubuntu-${IMAGE_SUFFIX}" @@ -151,11 +151,11 @@ build_task: CTR_FQIN: ${FEDORA_CONTAINER_FQIN} # ID for re-use of build output _BUILD_CACHE_HANDLE: ${FEDORA_NAME}-build-${CIRRUS_BUILD_ID} - # - env: - # DISTRO_NV: ${PRIOR_FEDORA_NAME} - # VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} - # CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} - # _BUILD_CACHE_HANDLE: ${PRIOR_FEDORA_NAME}-build-${CIRRUS_BUILD_ID} + - env: + DISTRO_NV: ${PRIOR_FEDORA_NAME} + VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} + CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} + _BUILD_CACHE_HANDLE: ${PRIOR_FEDORA_NAME}-build-${CIRRUS_BUILD_ID} - env: DISTRO_NV: ${UBUNTU_NAME} VM_IMAGE_NAME: ${UBUNTU_CACHE_IMAGE_NAME} @@ -515,11 +515,11 @@ container_integration_test_task: _BUILD_CACHE_HANDLE: ${FEDORA_NAME}-build-${CIRRUS_BUILD_ID} VM_IMAGE_NAME: ${FEDORA_CACHE_IMAGE_NAME} CTR_FQIN: ${FEDORA_CONTAINER_FQIN} - # - env: - # DISTRO_NV: ${PRIOR_FEDORA_NAME} - # _BUILD_CACHE_HANDLE: ${PRIOR_FEDORA_NAME}-build-${CIRRUS_BUILD_ID} - # VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} - # CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} + - env: + DISTRO_NV: ${PRIOR_FEDORA_NAME} + _BUILD_CACHE_HANDLE: ${PRIOR_FEDORA_NAME}-build-${CIRRUS_BUILD_ID} + VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} + CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} gce_instance: *standardvm timeout_in: 90m env: @@ -703,7 +703,7 @@ vendor: .PHONY: vendor-in-container vendor-in-container: - podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.13 make vendor + podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.16 make vendor .PHONY: package package: ## Build rpm packages diff --git a/contrib/cirrus/pr-should-include-tests b/contrib/cirrus/pr-should-include-tests index e3c5d5da1..2bc06df50 100755 --- a/contrib/cirrus/pr-should-include-tests +++ b/contrib/cirrus/pr-should-include-tests @@ -32,6 +32,7 @@ fi # This is OK if the only files being touched are "safe" ones. filtered_changes=$(git diff --name-status $base $head | awk '{print $2}' | + fgrep -vx Makefile | fgrep -vx .cirrus.yml | fgrep -vx changelog.txt | fgrep -vx go.mod | diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh index 36878365d..86b8d78ef 100755 --- a/contrib/cirrus/setup_environment.sh +++ b/contrib/cirrus/setup_environment.sh @@ -50,14 +50,9 @@ echo -e "\n# Begin single-use VM global variables (${BASH_SOURCE[0]})" \ done <<<"$(passthrough_envars)" ) >> "/etc/ci_environment" -##### -##### FIXME. /etc/containers/storage.conf should have a driver name set -##### Remove when VMs updated -sed 's/^driver.*=.*""/driver = "overlay"/g' -i /etc/containers/storage.conf - # This is a possible manual maintenance gaff, check to be sure everything matches. # shellcheck disable=SC2154 -[[ "$DISTRO_NV" == "$OS_REL_VER" ]] || \ +[[ "$DISTRO_NV" =~ $OS_REL_VER ]] || \ die "Automation spec. '$DISTRO_NV'; actual host '$OS_REL_VER'" # Only allow this script to execute once @@ -200,7 +195,9 @@ case "$TEST_FLAVOR" in build) make clean ;; unit) ;; apiv2) ;& # use next item - compose) ;& + compose) + dnf install -y $PACKAGE_DOWNLOAD_DIR/podman-docker* + ;& # continue with next item int) ;& sys) ;& upgrade_test) ;& @@ -10,7 +10,7 @@ require ( github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b github.com/containernetworking/cni v0.8.1 github.com/containernetworking/plugins v0.9.1 - github.com/containers/buildah v1.20.0 + github.com/containers/buildah v1.20.1-0.20210402144408-36a37402d0c8 github.com/containers/common v0.35.4 github.com/containers/conmon v2.0.20+incompatible github.com/containers/image/v5 v5.10.5 @@ -43,7 +43,7 @@ require ( github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 github.com/mrunalp/fileutils v0.5.0 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect - github.com/onsi/ginkgo v1.16.0 + github.com/onsi/ginkgo v1.16.1 github.com/onsi/gomega v1.11.0 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 @@ -174,9 +174,8 @@ github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHV github.com/containernetworking/plugins v0.8.7/go.mod h1:R7lXeZaBzpfqapcAbHRW8/CYwm0dHzbz0XEjofx0uB0= github.com/containernetworking/plugins v0.9.1 h1:FD1tADPls2EEi3flPc2OegIY1M9pUa9r2Quag7HMLV8= github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8= -github.com/containers/buildah v1.20.0 h1:H8db/d2uSGm947mqjX0Iup6F0T9AnK3kS/ff9RCemZA= -github.com/containers/buildah v1.20.0/go.mod h1:8V3UBoTKBWU9AxNHb1MAKnZZ9oSoz/IsYyjeymrpl1s= -github.com/containers/common v0.35.3/go.mod h1:rMzxgD7nMGw++cEbsp+NZv0UJO4rgXbm7F7IbJPTwIE= +github.com/containers/buildah v1.20.1-0.20210402144408-36a37402d0c8 h1:RlqbDlfE3+qrq4bNTZG7NVPqCDzfZrgE/yicu0VAykQ= +github.com/containers/buildah v1.20.1-0.20210402144408-36a37402d0c8/go.mod h1:iowyscoAC5jwNDhs3c5CLGdBZ9FJk5UOoN2I5TdmXFs= github.com/containers/common v0.35.4 h1:szyWRncsHkBwCVpu1dkEOXUjkwCetlfcLmKJTwo1Sp8= github.com/containers/common v0.35.4/go.mod h1:rMzxgD7nMGw++cEbsp+NZv0UJO4rgXbm7F7IbJPTwIE= github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= @@ -586,8 +585,8 @@ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= github.com/onsi/ginkgo v1.15.2/go.mod h1:Dd6YFfwBW84ETqqtL0CPyPXillHgY6XhQH3uuCCTr/o= -github.com/onsi/ginkgo v1.16.0 h1:NBrNLB37exjJLxXtFOktx6CISBdS1aF8+7MwKlTV8U4= -github.com/onsi/ginkgo v1.16.0/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +github.com/onsi/ginkgo v1.16.1 h1:foqVmeWDD6yYpK+Yz3fHyNIxFYNxswxqNFjSKe+vI54= +github.com/onsi/ginkgo v1.16.1/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= diff --git a/pkg/api/Makefile b/pkg/api/Makefile index 6b24bfd83..6da5fb57e 100644 --- a/pkg/api/Makefile +++ b/pkg/api/Makefile @@ -5,6 +5,9 @@ SWAGGER_OUT ?= swagger.yaml validate: ${SWAGGER_OUT} swagger validate ${SWAGGER_OUT} +serve: ${SWAGGER_OUT} + swagger serve -F redoc -p=8080 swagger.yaml + .PHONY: ${SWAGGER_OUT} ${SWAGGER_OUT}: # generate doesn't remove file on error diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index ab92434b1..700881926 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -15,6 +15,7 @@ import ( "github.com/containers/buildah" buildahDefine "github.com/containers/buildah/define" + "github.com/containers/buildah/pkg/parse" "github.com/containers/buildah/util" "github.com/containers/image/v5/types" "github.com/containers/podman/v3/libpod" @@ -445,6 +446,17 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { }, } + if len(query.Platform) > 0 { + variant := "" + buildOptions.OS, buildOptions.Architecture, variant, err = parse.Platform(query.Platform) + if err != nil { + utils.BadRequest(w, "platform", query.Platform, err) + return + } + buildOptions.SystemContext.OSChoice = buildOptions.OS + buildOptions.SystemContext.ArchitectureChoice = buildOptions.Architecture + buildOptions.SystemContext.VariantChoice = variant + } if _, found := r.URL.Query()["timestamp"]; found { ts := time.Unix(query.Timestamp, 0) buildOptions.Timestamp = &ts diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go index 42ece643b..d86fc1e19 100644 --- a/pkg/api/handlers/compat/volumes.go +++ b/pkg/api/handlers/compat/volumes.go @@ -266,7 +266,7 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) { } f := (url.Values)(*filterMap) - filterFuncs, err := filters.GenerateVolumeFilters(f) + filterFuncs, err := filters.GeneratePruneVolumeFilters(f) if err != nil { utils.Error(w, "Something when wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse filters for %s", f.Encode())) return diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go index 2631f19ac..9450a70d9 100644 --- a/pkg/api/handlers/libpod/swagger.go +++ b/pkg/api/handlers/libpod/swagger.go @@ -25,7 +25,7 @@ type swagInspectPodResponse struct { // swagger:response InspectManifest type swagInspectManifestResponse struct { // in:body - Body manifest.List + Body manifest.Schema2List } // Kill Pod diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go index 442b53d1e..68aec30d5 100644 --- a/pkg/api/handlers/libpod/volumes.go +++ b/pkg/api/handlers/libpod/volumes.go @@ -150,7 +150,7 @@ func pruneVolumesHelper(r *http.Request) ([]*reports.PruneReport, error) { } f := (url.Values)(*filterMap) - filterFuncs, err := filters.GenerateVolumeFilters(f) + filterFuncs, err := filters.GeneratePruneVolumeFilters(f) if err != nil { return nil, err } diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index c2bb44c8f..536c4707a 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -1194,11 +1194,22 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - removing // - stopping // description: "Conditions to wait for. If no condition provided the 'exited' condition is assumed." + // - in: query + // name: interval + // type: string + // default: "250ms" + // description: Time Interval to wait before polling for completion. // produces: // - application/json + // - text/plain // responses: // 200: - // $ref: "#/responses/ContainerWaitResponse" + // description: Status code + // schema: + // type: integer + // format: int32 + // examples: + // text/plain: 137 // 404: // $ref: "#/responses/NoSuchContainer" // 500: diff --git a/pkg/api/server/register_manifest.go b/pkg/api/server/register_manifest.go index 230704b1f..010d8a79e 100644 --- a/pkg/api/server/register_manifest.go +++ b/pkg/api/server/register_manifest.go @@ -81,6 +81,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { r.Handle(VersionedPath("/libpod/manifests/{name:.*}/json"), s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet) // swagger:operation POST /libpod/manifests/{name}/add manifests ManifestAddLibpod // --- + // summary: Add image // description: Add an image to a manifest list // produces: // - application/json diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index c47a16551..34d6cee05 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -12,6 +12,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strconv" "strings" @@ -190,6 +191,10 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO platform = "linux" } platform += "/" + options.Architecture + } else { + if len(platform) > 0 { + platform += "/" + runtime.GOARCH + } } if len(platform) > 0 { params.Set("platform", platform) diff --git a/pkg/domain/filters/volumes.go b/pkg/domain/filters/volumes.go index 9b2fc5280..9a08adf82 100644 --- a/pkg/domain/filters/volumes.go +++ b/pkg/domain/filters/volumes.go @@ -75,7 +75,25 @@ func GenerateVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) { return dangling }) default: - return nil, errors.Errorf("%q is in an invalid volume filter", filter) + return nil, errors.Errorf("%q is an invalid volume filter", filter) + } + } + } + return vf, nil +} + +func GeneratePruneVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) { + var vf []libpod.VolumeFilter + for filter, v := range filters { + for _, val := range v { + switch filter { + case "label": + filter := val + vf = append(vf, func(v *libpod.Volume) bool { + return util.MatchLabelFilters([]string{filter}, v.Labels()) + }) + default: + return nil, errors.Errorf("%q is an invalid volume filter", filter) } } } diff --git a/test/apiv2/30-volumes.at b/test/apiv2/30-volumes.at index 18ff31100..623e691e3 100644 --- a/test/apiv2/30-volumes.at +++ b/test/apiv2/30-volumes.at @@ -123,4 +123,20 @@ t POST libpod/volumes/prune 200 #After prune volumes, there should be no volume existing t GET libpod/volumes/json 200 length=0 +# libpod api: do not use list filters for prune +t POST libpod/volumes/prune?filters='{"name":["anyname"]}' 500 \ + .cause="\"name\" is an invalid volume filter" +t POST libpod/volumes/prune?filters='{"driver":["anydriver"]}' 500 \ + .cause="\"driver\" is an invalid volume filter" +t POST libpod/volumes/prune?filters='{"scope":["anyscope"]}' 500 \ + .cause="\"scope\" is an invalid volume filter" + +# compat api: do not use list filters for prune +t POST volumes/prune?filters='{"name":["anyname"]}' 500 \ + .cause="\"name\" is an invalid volume filter" +t POST volumes/prune?filters='{"driver":["anydriver"]}' 500 \ + .cause="\"driver\" is an invalid volume filter" +t POST volumes/prune?filters='{"scope":["anyscope"]}' 500 \ + .cause="\"scope\" is an invalid volume filter" + # vim: filetype=sh diff --git a/test/buildah-bud/buildah-tests.diff b/test/buildah-bud/buildah-tests.diff index ad35e5926..141bd9266 100644 --- a/test/buildah-bud/buildah-tests.diff +++ b/test/buildah-bud/buildah-tests.diff @@ -1,16 +1,16 @@ -From a49a2e48421c6f3bb1a56ae372de1f3d1a45d1f1 Mon Sep 17 00:00:00 2001 +From 47cc8f54d272039bdab389b29c8b2b5bb085e923 Mon Sep 17 00:00:00 2001 From: Ed Santiago <santiago@redhat.com> Date: Tue, 9 Feb 2021 17:28:05 -0700 Subject: [PATCH] tweaks for running buildah tests under podman Signed-off-by: Ed Santiago <santiago@redhat.com> --- - tests/bud.bats | 26 ++++++++++++++++---------- + tests/bud.bats | 22 +++++++++++++--------- tests/helpers.bash | 28 ++++++++++++++++++++++++---- - 2 files changed, 40 insertions(+), 14 deletions(-) + 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/tests/bud.bats b/tests/bud.bats -index cf55d9a4..60cb6f96 100644 +index fe3af27a..d1ccced5 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -4,7 +4,7 @@ load helpers @@ -30,7 +30,7 @@ index cf55d9a4..60cb6f96 100644 run_buildah 125 bud /tmp/tmpdockerfile/ -t blabla check_options_flag_err "-t" -@@ -1416,13 +1417,13 @@ function _test_http() { +@@ -1436,13 +1437,13 @@ function _test_http() { @test "bud with dir for file but no Dockerfile in dir" { target=alpine-image run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/empty-dir ${TESTSDIR}/bud/empty-dir @@ -46,18 +46,7 @@ index cf55d9a4..60cb6f96 100644 } @test "bud with ARG before FROM default value" { -@@ -1834,7 +1835,9 @@ _EOF - run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test-img-2 --build-arg TEST=foo -f Dockerfile4 ${TESTSDIR}/bud/build-arg - run_buildah inspect -f '{{.FromImageID}}' test-img-2 - argsid="$output" -- [[ "$argsid" != "$initialid" ]] -+ if [[ "$argsid" == "$initialid" ]]; then -+ die ".FromImageID of test-img-2 ($argsid) == same as test-img, it should be different" -+ fi - - # Set the build-arg via an ENV in the local environment and verify that the cached layers are not used - export TEST=bar -@@ -1887,6 +1890,7 @@ _EOF +@@ -1913,6 +1914,7 @@ _EOF } @test "bud without any arguments should succeed" { @@ -65,7 +54,7 @@ index cf55d9a4..60cb6f96 100644 cd ${TESTSDIR}/bud/from-scratch run_buildah bud --signature-policy ${TESTSDIR}/policy.json } -@@ -1894,7 +1898,7 @@ _EOF +@@ -1920,7 +1922,7 @@ _EOF @test "bud without any arguments should fail when no Dockerfile exist" { cd $(mktemp -d) run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json @@ -74,7 +63,7 @@ index cf55d9a4..60cb6f96 100644 } @test "bud with specified context should fail if directory contains no Dockerfile" { -@@ -1907,16 +1911,17 @@ _EOF +@@ -1933,16 +1935,17 @@ _EOF DIR=$(mktemp -d) mkdir -p "$DIR"/Dockerfile run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR" @@ -94,7 +83,7 @@ index cf55d9a4..60cb6f96 100644 DIR=$(mktemp -d) echo "FROM alpine" > "$DIR"/Dockerfile run_buildah 0 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"/Dockerfile -@@ -1968,7 +1973,7 @@ _EOF +@@ -1994,7 +1997,7 @@ _EOF @test "bud-squash-hardlinks" { _prefetch busybox @@ -103,7 +92,7 @@ index cf55d9a4..60cb6f96 100644 } @test "bud with additional directory of devices" { -@@ -2134,6 +2139,7 @@ _EOF +@@ -2159,6 +2162,7 @@ _EOF } @test "bud with Containerfile should fail with nonexistent authfile" { @@ -111,7 +100,7 @@ index cf55d9a4..60cb6f96 100644 target=alpine-image run_buildah 125 bud --authfile /tmp/nonexistent --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile } -@@ -2261,6 +2267,7 @@ EOM +@@ -2286,6 +2290,7 @@ EOM } @test "bud with encrypted FROM image" { @@ -119,7 +108,7 @@ index cf55d9a4..60cb6f96 100644 _prefetch busybox mkdir ${TESTDIR}/tmp openssl genrsa -out ${TESTDIR}/tmp/mykey.pem 1024 -@@ -2333,8 +2340,6 @@ EOM +@@ -2358,8 +2363,6 @@ EOM _prefetch alpine run_buildah bud --timestamp=0 --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json -t timestamp -f Dockerfile.1 ${TESTSDIR}/bud/cache-stages cid=$output @@ -128,7 +117,7 @@ index cf55d9a4..60cb6f96 100644 run_buildah inspect --format '{{ .OCIv1.Created }}' timestamp expect_output --substring "1970-01-01" run_buildah inspect --format '{{ .History }}' timestamp -@@ -2594,6 +2599,7 @@ _EOF +@@ -2619,6 +2622,7 @@ _EOF } @test "bud with --arch flag" { @@ -137,18 +126,18 @@ index cf55d9a4..60cb6f96 100644 mytmpdir=${TESTDIR}/my-dir mkdir -p ${mytmpdir} diff --git a/tests/helpers.bash b/tests/helpers.bash -index b28fd2c3..d42a6b82 100644 +index 99c290af..c5572840 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -70,7 +70,7 @@ function _prefetch() { - mkdir -p ${_BUILDAH_IMAGE_CACHEDIR} - fi + mkdir -p ${_BUILDAH_IMAGE_CACHEDIR} + fi -- local _podman_opts="--root ${TESTDIR}/root --storage-driver ${STORAGE_DRIVER}" -+ local _podman_opts="--root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER}" +- local _podman_opts="--root ${TESTDIR}/root --storage-driver ${STORAGE_DRIVER}" ++ local _podman_opts="--root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER}" - for img in "$@"; do - echo "# [checking for: $img]" >&2 + for img in "$@"; do + echo "# [checking for: $img]" >&2 @@ -138,15 +138,35 @@ function run_buildah() { --retry) retry=3; shift;; # retry network flakes esac diff --git a/test/buildah-bud/run-buildah-bud-tests b/test/buildah-bud/run-buildah-bud-tests index 67c8fdfa4..1265e67d5 100755 --- a/test/buildah-bud/run-buildah-bud-tests +++ b/test/buildah-bud/run-buildah-bud-tests @@ -72,7 +72,7 @@ function die() { # From here on out, any unexpected abort will try to offer helpful hints failhint= -trap 'if [[ $? != 0 ]]; then if [[ -n $failhint ]]; then echo;echo "***************************************";echo $failhint;echo;echo "Please see $BUD_TEST_DIR_REL/README.md for advice";fi;fi' 0 +trap 'if [[ $? != 0 ]]; then if [[ -n $failhint ]]; then echo;echo "***************************************";echo "$failhint";echo;echo "Please see $BUD_TEST_DIR_REL/README.md for advice";fi;fi' 0 # Find the version of buildah we've vendored in, so we can run the right tests buildah_version=$(awk "\$1 == \"$BUILDAH_REPO\" { print \$2 }" <go.mod) @@ -110,10 +110,27 @@ if [[ -n $do_checkout ]]; then die "Directory already exists: $buildah_dir" fi + # buildah_version should usually be vX.Y, but sometimes a PR under test + # will need a special unreleased version (go calls then "pseudoversions"). + # In the usual case, we can do a shallow git clone: + shallow_checkout="--branch $buildah_version" + if [[ $buildah_version =~ .*-.*\.[0-9]{14}-.* ]]; then + # ...but with a pseudoversion, we must git-clone the entire repo, + # then do a git checkout within it + shallow_checkout= + fi + failhint="'git clone' failed - this should never happen!" - (set -x;git clone -q --branch $buildah_version https://$BUILDAH_REPO $buildah_dir) + (set -x;git clone -q $shallow_checkout https://$BUILDAH_REPO $buildah_dir) cd $buildah_dir + if [[ -z $shallow_checkout ]]; then + # extract the SHA (rightmost field) from, e.g., v1.2-YYYMMDD-<sha> + sha=${buildah_version##*-} + + failhint="'git checkout $sha' failed - this should never happen!" + (set -x;git checkout -q $sha) + fi # Give it a recognizable tag; this will be useful if we need to update # the set of patches @@ -123,18 +140,22 @@ if [[ -n $do_checkout ]]; then failhint="error building buildah. This should never happen." (set -x;make bin/buildah) - # Apply custom patches. We do this _after_ building, although it shouldn't - # matter because these patches should only apply to test scripts. - failhint=" -Error applying patch file. This can happen when you vendor in a new buildah." - (set -x;git am <$PATCHES) - + # The upcoming patch may fail. Before we try it, create a helper script + # for a developer to push a new set of diffs to podman-land. failhint= sed -e "s,\[BASETAG\],${BASE_TAG},g" \ -e "s,\[BUILDAHREPO\],${BUILDAH_REPO},g" \ < ${BUD_TEST_DIR}/make-new-buildah-diffs \ > make-new-buildah-diffs chmod 755 make-new-buildah-diffs + + # Apply custom patches. We do this _after_ building, although it shouldn't + # matter because these patches should only apply to test scripts. + failhint=" +Error applying patch file. This can happen when you vendor in a new buildah. + +Look for '*.rej' files to resolve the conflict(s) manually." + (set -x;git am --reject <$PATCHES) else # Called with --no-checkout test -d $buildah_dir || die "Called with --no-checkout, but $buildah_dir does not exist" diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 4f337116e..6255690b1 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -566,4 +566,42 @@ RUN echo hello`, ALPINE) Expect(session.OutputToString()).To(ContainSubstring("(user)")) Expect(session.OutputToString()).To(ContainSubstring("(elapsed)")) }) + + It("podman build --arch --os flag", func() { + containerfile := `FROM scratch` + containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") + err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + Expect(err).To(BeNil()) + session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--arch", "foo", "--os", "bar", "--file", containerfilePath, podmanTest.TempDir}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Architecture }}", "test"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.OutputToString()).To(Equal("foo")) + + inspect = podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Os }}", "test"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.OutputToString()).To(Equal("bar")) + + }) + + It("podman build --os windows flag", func() { + containerfile := `FROM scratch` + containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") + err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + Expect(err).To(BeNil()) + session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--os", "windows", "--file", containerfilePath, podmanTest.TempDir}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Architecture }}", "test"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.OutputToString()).To(Equal(runtime.GOARCH)) + + inspect = podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Os }}", "test"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.OutputToString()).To(Equal("windows")) + + }) }) diff --git a/test/e2e/config_amd64.go b/test/e2e/config_amd64.go index 25e50a541..3607bdc30 100644 --- a/test/e2e/config_amd64.go +++ b/test/e2e/config_amd64.go @@ -5,7 +5,7 @@ var ( STORAGE_OPTIONS = "--storage-driver vfs" ROOTLESS_STORAGE_FS = "vfs" ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs" - CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal} + CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal, fedoraToolbox} nginx = "quay.io/libpod/alpine_nginx:latest" BB_GLIBC = "docker.io/library/busybox:glibc" registry = "quay.io/libpod/registry:2.6" diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 29be505b7..098d58033 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -78,7 +78,7 @@ var _ = Describe("Podman images", func() { session = podmanTest.Podman([]string{"images", "-qn"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(BeNumerically("==", 11)) + Expect(len(session.OutputToStringArray())).To(BeNumerically("==", len(CACHE_IMAGES))) }) It("podman images with digests", func() { @@ -194,7 +194,7 @@ WORKDIR /test result := podmanTest.Podman([]string{"images", "-q", "-f", "since=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(len(result.OutputToStringArray())).To(Equal(8)) + Expect(len(result.OutputToStringArray())).To(Equal(9)) }) It("podman image list filter after image", func() { @@ -204,7 +204,7 @@ WORKDIR /test result := podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(result.OutputToStringArray()).Should(HaveLen(8), "list filter output: %q", result.OutputToString()) + Expect(result.OutputToStringArray()).Should(HaveLen(9), "list filter output: %q", result.OutputToString()) }) It("podman images filter dangling", func() { diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 5e6d66d53..03a347a6f 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -221,7 +221,7 @@ var _ = Describe("Podman rmi", func() { session = podmanTest.Podman([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(12)) + Expect(len(session.OutputToStringArray())).To(Equal(len(CACHE_IMAGES) + 1)) podmanTest.BuildImage(dockerfile, "test3", "true") @@ -236,7 +236,7 @@ var _ = Describe("Podman rmi", func() { session = podmanTest.Podman([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToString())).To(Equal(142)) + Expect(len(session.OutputToString())).To(Equal(155)) }) It("podman rmi -a with no images should be exit 0", func() { diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go index d605b59f9..986f856bf 100644 --- a/test/e2e/toolbox_test.go +++ b/test/e2e/toolbox_test.go @@ -215,7 +215,6 @@ var _ = Describe("Toolbox-specific testing", func() { useradd := fmt.Sprintf("useradd --home-dir %s --shell %s --uid %s %s", homeDir, shell, uid, username) passwd := fmt.Sprintf("passwd --delete %s", username) - podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", "--user", "root:root", fedoraToolbox, "sh", "-c", fmt.Sprintf("%s; %s; echo READY; sleep 1000", useradd, passwd)}) session.WaitWithDefaultTimeout() @@ -251,7 +250,6 @@ var _ = Describe("Toolbox-specific testing", func() { groupadd := fmt.Sprintf("groupadd --gid %s %s", gid, groupName) - podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", "--user", "root:root", fedoraToolbox, "sh", "-c", fmt.Sprintf("%s; echo READY; sleep 1000", groupadd)}) session.WaitWithDefaultTimeout() @@ -296,7 +294,6 @@ var _ = Describe("Toolbox-specific testing", func() { usermod := fmt.Sprintf("usermod --append --groups wheel --home %s --shell %s --uid %s --gid %s %s", homeDir, shell, uid, gid, username) - podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", "--user", "root:root", fedoraToolbox, "sh", "-c", fmt.Sprintf("%s; %s; %s; echo READY; sleep 1000", useradd, groupadd, usermod)}) session.WaitWithDefaultTimeout() @@ -341,7 +338,6 @@ var _ = Describe("Toolbox-specific testing", func() { // These should be most of the switches that Toolbox uses to create a "toolbox" container // https://github.com/containers/toolbox/blob/master/src/cmd/create.go - podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--dns", "none", "--hostname", "toolbox", @@ -378,7 +374,6 @@ var _ = Describe("Toolbox-specific testing", func() { currentUser, err := user.Current() Expect(err).To(BeNil()) - podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:%s", currentUser.HomeDir, currentUser.HomeDir), "--userns=keep-id", fedoraToolbox, "sh", "-c", "echo $HOME"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/system/005-info.bats b/test/system/005-info.bats index c0af2e937..ed341dd17 100644 --- a/test/system/005-info.bats +++ b/test/system/005-info.bats @@ -53,6 +53,27 @@ store.imageStore.number | 1 } +# 2021-04-06 discussed in watercooler: RHEL must never use crun, even if +# using cgroups v2. +@test "podman info - RHEL8 must use runc" { + local osrelease=/etc/os-release + test -e $osrelease || skip "Not a RHEL system (no $osrelease)" + + local osname=$(source $osrelease; echo $NAME) + if [[ $osname =~ Red.Hat || $osname =~ CentOS ]]; then + # Version can include minor; strip off first dot an all beyond it + local osver=$(source $osrelease; echo $VERSION_ID) + test ${osver%%.*} -le 8 || skip "$osname $osver > RHEL8" + + # RHEL or CentOS 8. + # FIXME: what does 'CentOS 8' even mean? What is $VERSION_ID in CentOS? + run_podman info --format '{{.Host.OCIRuntime.Name}}' + is "$output" "runc" "$osname only supports OCI Runtime = runc" + else + skip "only applicable on RHEL, this is $osname" + fi +} + @test "podman info --storage-opt='' " { skip_if_remote "--storage-opt flag is not supported for remote" skip_if_rootless "storage opts are required for rootless running" diff --git a/vendor/github.com/containers/buildah/.cirrus.yml b/vendor/github.com/containers/buildah/.cirrus.yml index 9c875a8fd..32c711be8 100644 --- a/vendor/github.com/containers/buildah/.cirrus.yml +++ b/vendor/github.com/containers/buildah/.cirrus.yml @@ -164,7 +164,7 @@ conformance_task: gce_instance: image_name: "${UBUNTU_CACHE_IMAGE_NAME}" - timeout_in: 20m + timeout_in: 25m setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}' conformance_test_script: '${SCRIPT_BASE}/test.sh conformance |& ${_TIMESTAMP}' diff --git a/vendor/github.com/containers/buildah/Makefile b/vendor/github.com/containers/buildah/Makefile index fad4a2107..9ff59df55 100644 --- a/vendor/github.com/containers/buildah/Makefile +++ b/vendor/github.com/containers/buildah/Makefile @@ -149,7 +149,7 @@ install.runc: .PHONY: test-conformance test-conformance: - $(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -timeout 15m ./tests/conformance + $(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover -timeout 20m ./tests/conformance .PHONY: test-integration test-integration: install.tools diff --git a/vendor/github.com/containers/buildah/chroot/run.go b/vendor/github.com/containers/buildah/chroot/run.go index 39ad88b2b..7cb1d710e 100644 --- a/vendor/github.com/containers/buildah/chroot/run.go +++ b/vendor/github.com/containers/buildah/chroot/run.go @@ -20,6 +20,7 @@ import ( "unsafe" "github.com/containers/buildah/bind" + "github.com/containers/buildah/copier" "github.com/containers/buildah/util" "github.com/containers/storage/pkg/ioutils" "github.com/containers/storage/pkg/mount" @@ -1161,7 +1162,18 @@ func setupChrootBindMounts(spec *specs.Spec, bundlePath string) (undoBinds func( } } target := filepath.Join(spec.Root.Path, m.Destination) - if _, err := os.Stat(target); err != nil { + // Check if target is a symlink + stat, err := os.Lstat(target) + // If target is a symlink, follow the link and ensure the destination exists + if err == nil && stat != nil && (stat.Mode()&os.ModeSymlink != 0) { + target, err = copier.Eval(spec.Root.Path, m.Destination, copier.EvalOptions{}) + if err != nil { + return nil, errors.Wrapf(err, "evaluating symlink %q", target) + } + // Stat the destination of the evaluated symlink + _, err = os.Stat(target) + } + if err != nil { // If the target can't be stat()ted, check the error. if !os.IsNotExist(err) { return undoBinds, errors.Wrapf(err, "error examining %q for mounting in mount namespace", target) diff --git a/vendor/github.com/containers/buildah/define/types.go b/vendor/github.com/containers/buildah/define/types.go index 5f3e29e62..6d4809cc0 100644 --- a/vendor/github.com/containers/buildah/define/types.go +++ b/vendor/github.com/containers/buildah/define/types.go @@ -28,7 +28,7 @@ const ( Package = "buildah" // Version for the Package. Bump version in contrib/rpm/buildah.spec // too. - Version = "1.20.0" + Version = "1.20.1-dev" // DefaultRuntime if containers.conf fails. DefaultRuntime = "runc" @@ -166,7 +166,7 @@ func cloneToDirectory(url, dir string) error { cmd = exec.Command("git", "clone", url, dir) } else { logrus.Debugf("cloning repo %q and branch %q to %q", gitBranch[0], gitBranch[1], dir) - cmd = exec.Command("git", "clone", "-b", gitBranch[1], gitBranch[0], dir) + cmd = exec.Command("git", "clone", "--recurse-submodules", "-b", gitBranch[1], gitBranch[0], dir) } return cmd.Run() } diff --git a/vendor/github.com/containers/buildah/go.mod b/vendor/github.com/containers/buildah/go.mod index fa37132f4..075bdfb01 100644 --- a/vendor/github.com/containers/buildah/go.mod +++ b/vendor/github.com/containers/buildah/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/containernetworking/cni v0.8.1 - github.com/containers/common v0.35.3 + github.com/containers/common v0.35.4 github.com/containers/image/v5 v5.10.5 github.com/containers/ocicrypt v1.1.0 github.com/containers/storage v1.28.1 diff --git a/vendor/github.com/containers/buildah/go.sum b/vendor/github.com/containers/buildah/go.sum index c20348bb2..6a48853ac 100644 --- a/vendor/github.com/containers/buildah/go.sum +++ b/vendor/github.com/containers/buildah/go.sum @@ -165,8 +165,8 @@ github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ github.com/containernetworking/cni v0.8.1 h1:7zpDnQ3T3s4ucOuJ/ZCLrYBxzkg0AELFfII3Epo9TmI= github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY= github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM= -github.com/containers/common v0.35.3 h1:6tEBSIHlJzpmt35zA1ZcjBqbtUilAHDWaa7buPvaqWY= -github.com/containers/common v0.35.3/go.mod h1:rMzxgD7nMGw++cEbsp+NZv0UJO4rgXbm7F7IbJPTwIE= +github.com/containers/common v0.35.4 h1:szyWRncsHkBwCVpu1dkEOXUjkwCetlfcLmKJTwo1Sp8= +github.com/containers/common v0.35.4/go.mod h1:rMzxgD7nMGw++cEbsp+NZv0UJO4rgXbm7F7IbJPTwIE= github.com/containers/image/v5 v5.10.5 h1:VK1UbsZMzjdw5Xqr3Im9h4iOqHWU0naFs+I78kavc7I= github.com/containers/image/v5 v5.10.5/go.mod h1:SgIbWEedCNBbn2FI5cH0/jed1Ecy2s8XK5zTxvJTzII= github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE= diff --git a/vendor/github.com/containers/buildah/pkg/blobcache/blobcache.go b/vendor/github.com/containers/buildah/pkg/blobcache/blobcache.go index 3f0177226..f3876cd13 100644 --- a/vendor/github.com/containers/buildah/pkg/blobcache/blobcache.go +++ b/vendor/github.com/containers/buildah/pkg/blobcache/blobcache.go @@ -13,6 +13,7 @@ import ( "github.com/containers/image/v5/docker/reference" "github.com/containers/image/v5/image" "github.com/containers/image/v5/manifest" + "github.com/containers/image/v5/pkg/compression" "github.com/containers/image/v5/transports" "github.com/containers/image/v5/types" "github.com/containers/storage/pkg/archive" @@ -301,25 +302,32 @@ func (s *blobCacheSource) LayerInfosForCopy(ctx context.Context, instanceDigest alternate = filepath.Join(filepath.Dir(alternate), makeFilename(digest.Digest(replaceDigest), false)) fileInfo, err := os.Stat(alternate) if err == nil { - logrus.Debugf("suggesting cached blob with digest %q and compression %v in place of blob with digest %q", string(replaceDigest), s.reference.compress, info.Digest.String()) - info.Digest = digest.Digest(replaceDigest) - info.Size = fileInfo.Size() switch info.MediaType { case v1.MediaTypeImageLayer, v1.MediaTypeImageLayerGzip: switch s.reference.compress { case types.Compress: info.MediaType = v1.MediaTypeImageLayerGzip + info.CompressionAlgorithm = &compression.Gzip case types.Decompress: info.MediaType = v1.MediaTypeImageLayer + info.CompressionAlgorithm = nil } case docker.V2S2MediaTypeUncompressedLayer, manifest.DockerV2Schema2LayerMediaType: switch s.reference.compress { case types.Compress: info.MediaType = manifest.DockerV2Schema2LayerMediaType + info.CompressionAlgorithm = &compression.Gzip case types.Decompress: - info.MediaType = docker.V2S2MediaTypeUncompressedLayer + // nope, not going to suggest anything, it's not allowed by the spec + replacedInfos = append(replacedInfos, info) + continue } } + logrus.Debugf("suggesting cached blob with digest %q, type %q, and compression %v in place of blob with digest %q", string(replaceDigest), info.MediaType, s.reference.compress, info.Digest.String()) + info.CompressionOperation = s.reference.compress + info.Digest = digest.Digest(replaceDigest) + info.Size = fileInfo.Size() + logrus.Debugf("info = %#v", info) } } replacedInfos = append(replacedInfos, info) @@ -422,8 +430,9 @@ func (d *blobCacheDestination) PutBlob(ctx context.Context, stream io.Reader, in var err error var n int var alternateDigest digest.Digest + var closer io.Closer wg := new(sync.WaitGroup) - defer wg.Wait() + needToWait := false compression := archive.Uncompressed if inputInfo.Digest != "" { filename := filepath.Join(d.reference.directory, makeFilename(inputInfo.Digest, isConfig)) @@ -458,7 +467,7 @@ func (d *blobCacheDestination) PutBlob(ctx context.Context, stream io.Reader, in if n >= len(initial) { compression = archive.DetectCompression(initial[:n]) } - if compression != archive.Uncompressed { + if compression == archive.Gzip { // The stream is compressed, so create a file which we'll // use to store a decompressed copy. decompressedTemp, err2 := ioutil.TempFile(d.reference.directory, makeFilename(inputInfo.Digest, isConfig)) @@ -470,10 +479,11 @@ func (d *blobCacheDestination) PutBlob(ctx context.Context, stream io.Reader, in // closing the writing end of the pipe after // PutBlob() returns. decompressReader, decompressWriter := io.Pipe() - defer decompressWriter.Close() + closer = decompressWriter stream = io.TeeReader(stream, decompressWriter) // Let saveStream() close the reading end and handle the temporary file. wg.Add(1) + needToWait = true go saveStream(wg, decompressReader, decompressedTemp, filename, inputInfo.Digest, isConfig, &alternateDigest) } } @@ -481,6 +491,12 @@ func (d *blobCacheDestination) PutBlob(ctx context.Context, stream io.Reader, in } } newBlobInfo, err := d.destination.PutBlob(ctx, stream, inputInfo, cache, isConfig) + if closer != nil { + closer.Close() + } + if needToWait { + wg.Wait() + } if err != nil { return newBlobInfo, errors.Wrapf(err, "error storing blob to image destination for cache %q", transports.ImageName(d.reference)) } diff --git a/vendor/github.com/containers/buildah/pkg/parse/parse.go b/vendor/github.com/containers/buildah/pkg/parse/parse.go index 9497ca4b6..2ae07efe9 100644 --- a/vendor/github.com/containers/buildah/pkg/parse/parse.go +++ b/vendor/github.com/containers/buildah/pkg/parse/parse.go @@ -629,7 +629,7 @@ func SystemContextFromOptions(c *cobra.Command) (*types.SystemContext, error) { } if c.Flag("platform") != nil && c.Flag("platform").Changed { if platform, err := c.Flags().GetString("platform"); err == nil { - os, arch, variant, err := parsePlatform(platform) + os, arch, variant, err := Platform(platform) if err != nil { return nil, err } @@ -672,7 +672,7 @@ func PlatformFromOptions(c *cobra.Command) (os, arch string, err error) { if c.Flag("platform").Changed { if pf, err := c.Flags().GetString("platform"); err == nil { - selectedOS, selectedArch, _, err := parsePlatform(pf) + selectedOS, selectedArch, _, err := Platform(pf) if err != nil { return "", "", errors.Wrap(err, "unable to parse platform") } @@ -691,7 +691,8 @@ func DefaultPlatform() string { return runtime.GOOS + platformSep + runtime.GOARCH } -func parsePlatform(platform string) (os, arch, variant string, err error) { +// Platform separates the platform string into os, arch and variant +func Platform(platform string) (os, arch, variant string, err error) { split := strings.Split(platform, platformSep) if len(split) < 2 { return "", "", "", errors.Errorf("invalid platform syntax for %q (use OS/ARCH)", platform) diff --git a/vendor/github.com/containers/buildah/run_linux.go b/vendor/github.com/containers/buildah/run_linux.go index ffbb36b7b..6356d2602 100644 --- a/vendor/github.com/containers/buildah/run_linux.go +++ b/vendor/github.com/containers/buildah/run_linux.go @@ -359,7 +359,17 @@ func runSetupBuiltinVolumes(mountLabel, mountPoint, containerDir string, builtin } initializeVolume = true } - stat, err := os.Stat(srcPath) + // Check if srcPath is a symlink + stat, err := os.Lstat(srcPath) + // If srcPath is a symlink, follow the link and ensure the destination exists + if err == nil && stat != nil && (stat.Mode()&os.ModeSymlink != 0) { + srcPath, err = copier.Eval(mountPoint, volume, copier.EvalOptions{}) + if err != nil { + return nil, errors.Wrapf(err, "evaluating symlink %q", srcPath) + } + // Stat the destination of the evaluated symlink + stat, err = os.Stat(srcPath) + } if err != nil { if !os.IsNotExist(err) { return nil, err @@ -519,8 +529,9 @@ func (b *Builder) setupMounts(mountPoint string, spec *specs.Spec, bundlePath st return err } + allMounts := util.SortMounts(append(append(append(append(append(volumes, builtins...), secretMounts...), bindFileMounts...), specMounts...), sysfsMount...)) // Add them all, in the preferred order, except where they conflict with something that was previously added. - for _, mount := range append(append(append(append(append(volumes, builtins...), secretMounts...), bindFileMounts...), specMounts...), sysfsMount...) { + for _, mount := range allMounts { if haveMount(mount.Destination) { // Already mounting something there, no need to bother with this one. continue diff --git a/vendor/github.com/containers/buildah/util/util.go b/vendor/github.com/containers/buildah/util/util.go index 419f905e1..b3fae6003 100644 --- a/vendor/github.com/containers/buildah/util/util.go +++ b/vendor/github.com/containers/buildah/util/util.go @@ -6,6 +6,8 @@ import ( "net/url" "os" "path" + "path/filepath" + "sort" "strings" "sync" "syscall" @@ -474,3 +476,26 @@ func MergeEnv(defaults, overrides []string) []string { } return s } + +type byDestination []specs.Mount + +func (m byDestination) Len() int { + return len(m) +} + +func (m byDestination) Less(i, j int) bool { + return m.parts(i) < m.parts(j) +} + +func (m byDestination) Swap(i, j int) { + m[i], m[j] = m[j], m[i] +} + +func (m byDestination) parts(i int) int { + return strings.Count(filepath.Clean(m[i].Destination), string(os.PathSeparator)) +} + +func SortMounts(m []specs.Mount) []specs.Mount { + sort.Sort(byDestination(m)) + return m +} diff --git a/vendor/github.com/onsi/ginkgo/CHANGELOG.md b/vendor/github.com/onsi/ginkgo/CHANGELOG.md index f99f89480..4e0afc291 100644 --- a/vendor/github.com/onsi/ginkgo/CHANGELOG.md +++ b/vendor/github.com/onsi/ginkgo/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.16.1 + +### Fixes +- Supress --stream deprecation warning on windows (#793) + ## 1.16.0 ### Features diff --git a/vendor/github.com/onsi/ginkgo/config/config.go b/vendor/github.com/onsi/ginkgo/config/config.go index 25f8758a6..5f4a4c26e 100644 --- a/vendor/github.com/onsi/ginkgo/config/config.go +++ b/vendor/github.com/onsi/ginkgo/config/config.go @@ -20,7 +20,7 @@ import ( "fmt" ) -const VERSION = "1.16.0" +const VERSION = "1.16.1" type GinkgoConfigType struct { RandomSeed int64 diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go index dd87e1f89..47b586d93 100644 --- a/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go +++ b/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go @@ -6,6 +6,7 @@ import ( "math/rand" "os" "regexp" + "runtime" "strings" "time" @@ -56,7 +57,7 @@ func (r *SpecRunner) RunSpecs(args []string, additionalArgs []string) { deprecationTracker := types.NewDeprecationTracker() - if r.commandFlags.ParallelStream { + if r.commandFlags.ParallelStream && (runtime.GOOS != "windows") { deprecationTracker.TrackDeprecation(types.Deprecation{ Message: "--stream is deprecated and will be removed in Ginkgo 2.0", DocLink: "removed--stream", diff --git a/vendor/github.com/onsi/ginkgo/types/deprecation_support.go b/vendor/github.com/onsi/ginkgo/types/deprecation_support.go index c7bbfbf41..7f7a9aeb8 100644 --- a/vendor/github.com/onsi/ginkgo/types/deprecation_support.go +++ b/vendor/github.com/onsi/ginkgo/types/deprecation_support.go @@ -81,7 +81,7 @@ func (d *DeprecationTracker) DeprecationsReport() string { out += formatter.F("{{light-yellow}}============================================={{/}}\n") out += formatter.F("Ginkgo 2.0 is under active development and will introduce (a small number of) breaking changes.\n") out += formatter.F("To learn more, view the migration guide at {{cyan}}{{underline}}https://github.com/onsi/ginkgo/blob/v2/docs/MIGRATING_TO_V2.md{{/}}\n") - out += formatter.F("To comment, chime in at {{cyan}}{{underline}}https://github.com/onsi/ginkgo/issues/711{{/}}\n") + out += formatter.F("To comment, chime in at {{cyan}}{{underline}}https://github.com/onsi/ginkgo/issues/711{{/}}\n\n") for deprecation, locations := range d.deprecations { out += formatter.Fi(1, "{{yellow}}"+deprecation.Message+"{{/}}\n") diff --git a/vendor/modules.txt b/vendor/modules.txt index 52ed2101e..261feb8aa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -74,7 +74,7 @@ github.com/containernetworking/plugins/pkg/utils/hwaddr github.com/containernetworking/plugins/pkg/utils/sysctl github.com/containernetworking/plugins/plugins/ipam/host-local/backend github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator -# github.com/containers/buildah v1.20.0 +# github.com/containers/buildah v1.20.1-0.20210402144408-36a37402d0c8 github.com/containers/buildah github.com/containers/buildah/bind github.com/containers/buildah/chroot @@ -427,7 +427,7 @@ github.com/nxadm/tail/ratelimiter github.com/nxadm/tail/util github.com/nxadm/tail/watch github.com/nxadm/tail/winfile -# github.com/onsi/ginkgo v1.16.0 +# github.com/onsi/ginkgo v1.16.1 github.com/onsi/ginkgo github.com/onsi/ginkgo/config github.com/onsi/ginkgo/extensions/table |