From 5ca35d6de7c95669dd6a4de2dbf701c33b7f3b28 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Thu, 2 Feb 2023 13:21:21 +0530 Subject: [PATCH 1/2] vendor: bump buildah to v1.29.1-0.20230201192322-e56eb25575c7 Signed-off-by: Aditya R --- go.mod | 4 ++-- go.sum | 8 ++++---- vendor/github.com/containers/buildah/define/types.go | 2 +- vendor/github.com/containers/buildah/pkg/parse/parse.go | 7 ++++++- vendor/modules.txt | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index c3d910e664..dc913d0fc4 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/container-orchestrated-devices/container-device-interface v0.5.3 github.com/containernetworking/cni v1.1.2 github.com/containernetworking/plugins v1.2.0 - github.com/containers/buildah v1.29.0 + github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7 github.com/containers/common v0.51.0 github.com/containers/conmon v2.0.20+incompatible github.com/containers/image/v5 v5.24.0 @@ -79,7 +79,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/containerd/cgroups v1.0.4 // indirect - github.com/containerd/containerd v1.6.15 // indirect + github.com/containerd/containerd v1.6.16 // indirect github.com/containerd/stargz-snapshotter/estargz v0.14.1 // indirect github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect github.com/coreos/go-oidc/v3 v3.5.0 // indirect diff --git a/go.sum b/go.sum index d602702f0b..b3000bf6aa 100644 --- a/go.sum +++ b/go.sum @@ -202,8 +202,8 @@ github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoT github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c= github.com/containerd/containerd v1.5.9/go.mod h1:fvQqCfadDGga5HZyn3j4+dx56qj2I9YwBrlSdalvJYQ= -github.com/containerd/containerd v1.6.15 h1:4wWexxzLNHNE46aIETc6ge4TofO550v+BlLoANrbses= -github.com/containerd/containerd v1.6.15/go.mod h1:U2NnBPIhzJDm59xF7xB2MMHnKtggpZ+phKg8o2TKj2c= +github.com/containerd/containerd v1.6.16 h1:0H5xH6ABsN7XTrxIAKxFpBkFCBtrZ/OSORhCpUnHjrc= +github.com/containerd/containerd v1.6.16/go.mod h1:1RdCUu95+gc2v9t3IL+zIlpClSmew7/0YS8O5eQZrOw= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= @@ -259,8 +259,8 @@ github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHV github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8= github.com/containernetworking/plugins v1.2.0 h1:SWgg3dQG1yzUo4d9iD8cwSVh1VqI+bP7mkPDoSfP9VU= github.com/containernetworking/plugins v1.2.0/go.mod h1:/VjX4uHecW5vVimFa1wkG4s+r/s9qIfPdqlLF4TW8c4= -github.com/containers/buildah v1.29.0 h1:rA3S2SXJffrJjvY2kyxOsAaIseDY6Ib77FsD7n88Mj4= -github.com/containers/buildah v1.29.0/go.mod h1:mah+CGmpOjkBJJ5rhOP0M2ETnODhiuhtnXusfh0hc6Q= +github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7 h1:GmQhTfsGuYgGfuYWEF4Ed+rEvlSWRmxisLBL2J8rCb4= +github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7/go.mod h1:sFvOi+WMtMtrkxx1Dn8EhF5/ddXNyC1f5LAj4ZGzjAs= github.com/containers/common v0.51.0 h1:Ax4YHNTG8cEPHZJcMYRoP7sfBgOISceeyOvmZzmSucg= github.com/containers/common v0.51.0/go.mod h1:3W2WIdalgQfrsX/T5tjX+6CxgT3ThJVN2G9sNuFjuCM= github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= diff --git a/vendor/github.com/containers/buildah/define/types.go b/vendor/github.com/containers/buildah/define/types.go index 1325674266..3148259598 100644 --- a/vendor/github.com/containers/buildah/define/types.go +++ b/vendor/github.com/containers/buildah/define/types.go @@ -30,7 +30,7 @@ const ( Package = "buildah" // Version for the Package. Bump version in contrib/rpm/buildah.spec // too. - Version = "1.29.0" + Version = "1.30.0-dev" // DefaultRuntime if containers.conf fails. DefaultRuntime = "runc" diff --git a/vendor/github.com/containers/buildah/pkg/parse/parse.go b/vendor/github.com/containers/buildah/pkg/parse/parse.go index 3d604589cb..8d02f59ddf 100644 --- a/vendor/github.com/containers/buildah/pkg/parse/parse.go +++ b/vendor/github.com/containers/buildah/pkg/parse/parse.go @@ -16,7 +16,6 @@ import ( "github.com/containerd/containerd/platforms" "github.com/containers/buildah/define" - securejoin "github.com/cyphar/filepath-securejoin" internalParse "github.com/containers/buildah/internal/parse" "github.com/containers/buildah/pkg/sshagent" "github.com/containers/common/pkg/config" @@ -26,6 +25,7 @@ import ( "github.com/containers/storage/pkg/idtools" "github.com/containers/storage/pkg/unshare" storageTypes "github.com/containers/storage/types" + securejoin "github.com/cyphar/filepath-securejoin" units "github.com/docker/go-units" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/openshift/imagebuilder" @@ -67,6 +67,11 @@ func RepoNamesToNamedReferences(destList []string) ([]reference.Named, error) { return result, nil } +// CleanCacheMount gets the cache parent created by `--mount=type=cache` and removes it. +func CleanCacheMount() error { + return internalParse.CleanCacheMount() +} + // CommonBuildOptions parses the build options from the bud cli func CommonBuildOptions(c *cobra.Command) (*define.CommonBuildOptions, error) { return CommonBuildOptionsFromFlagSet(c.Flags(), c.Flag) diff --git a/vendor/modules.txt b/vendor/modules.txt index 946e7c15f7..04f49ea32f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -72,7 +72,7 @@ github.com/container-orchestrated-devices/container-device-interface/specs-go # github.com/containerd/cgroups v1.0.4 ## explicit; go 1.17 github.com/containerd/cgroups/stats/v1 -# github.com/containerd/containerd v1.6.15 +# github.com/containerd/containerd v1.6.16 ## explicit; go 1.17 github.com/containerd/containerd/errdefs github.com/containerd/containerd/log @@ -98,7 +98,7 @@ github.com/containernetworking/cni/pkg/version # github.com/containernetworking/plugins v1.2.0 ## explicit; go 1.17 github.com/containernetworking/plugins/pkg/ns -# github.com/containers/buildah v1.29.0 +# github.com/containers/buildah v1.29.1-0.20230201192322-e56eb25575c7 ## explicit; go 1.17 github.com/containers/buildah github.com/containers/buildah/bind From 9e7f1bea428c4f523155c133b29e374aba242079 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Thu, 2 Feb 2023 14:26:36 +0530 Subject: [PATCH 2/2] system-reset: use CleanCacheMount to clear build cache Just like buildkit buildah must allow cleaning the buildcache and cache generated on host by --mount=type=cache just like buildkit's prune command. See: https://github.com/moby/buildkit#cache Signed-off-by: Aditya R --- cmd/podman/system/reset.go | 6 ++++++ test/e2e/build/cache/Dockerfilecacheread | 4 ++++ test/e2e/build/cache/Dockerfilecachewrite | 4 ++++ test/e2e/build_test.go | 16 ++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 test/e2e/build/cache/Dockerfilecacheread create mode 100644 test/e2e/build/cache/Dockerfilecachewrite diff --git a/cmd/podman/system/reset.go b/cmd/podman/system/reset.go index 02c4a7b467..a52ab9faf5 100644 --- a/cmd/podman/system/reset.go +++ b/cmd/podman/system/reset.go @@ -9,6 +9,7 @@ import ( "os" "strings" + "github.com/containers/buildah/pkg/parse" "github.com/containers/common/pkg/completion" "github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/cmd/podman/validate" @@ -88,6 +89,11 @@ func reset(cmd *cobra.Command, args []string) { if err != nil { logrus.Error(err) } + // Clean build cache if any + err = parse.CleanCacheMount() + if err != nil { + logrus.Error(err) + } // Shutdown all running engines, `reset` will hijack repository registry.ContainerEngine().Shutdown(registry.Context()) registry.ImageEngine().Shutdown(registry.Context()) diff --git a/test/e2e/build/cache/Dockerfilecacheread b/test/e2e/build/cache/Dockerfilecacheread new file mode 100644 index 0000000000..be123158c9 --- /dev/null +++ b/test/e2e/build/cache/Dockerfilecacheread @@ -0,0 +1,4 @@ +FROM alpine +RUN mkdir /test +# use option z if selinux is enabled +RUN --mount=type=cache,target=/test,z cat /test/world diff --git a/test/e2e/build/cache/Dockerfilecachewrite b/test/e2e/build/cache/Dockerfilecachewrite new file mode 100644 index 0000000000..67a65939ea --- /dev/null +++ b/test/e2e/build/cache/Dockerfilecachewrite @@ -0,0 +1,4 @@ +FROM alpine +RUN mkdir /test +# use option z if selinux is enabled +RUN --mount=type=cache,target=/test,z echo hello > /test/world diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 22e5d419d0..5445e5302d 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -874,4 +874,20 @@ RUN ls /dev/test1`, ALPINE) build.WaitWithDefaultTimeout() Expect(build).To(Exit(0)) }) + + It("podman system reset must clean host shared cache", func() { + SkipIfRemote("podman-remote does not have system reset -f") + podmanTest.AddImageToRWStore(ALPINE) + session := podmanTest.Podman([]string{"build", "--pull-never", "--file", "build/cache/Dockerfilecachewrite", "build/cache/"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + session = podmanTest.Podman([]string{"system", "reset", "-f"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + session = podmanTest.Podman([]string{"build", "--pull-never", "--file", "build/cache/Dockerfilecacheread", "build/cache/"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(1)) + }) })