mirror of
https://github.com/containers/podman.git
synced 2025-08-26 20:20:16 +08:00
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 <arajan@redhat.com>
This commit is contained in:
@ -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())
|
||||
|
4
test/e2e/build/cache/Dockerfilecacheread
vendored
Normal file
4
test/e2e/build/cache/Dockerfilecacheread
vendored
Normal file
@ -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
|
4
test/e2e/build/cache/Dockerfilecachewrite
vendored
Normal file
4
test/e2e/build/cache/Dockerfilecachewrite
vendored
Normal file
@ -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
|
@ -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))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user