mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
Merge pull request #17245 from sstosh/e2e-rootless-rm
e2e: Remove the cache with "podman unshare rm" when a rootless user
This commit is contained in:
@ -192,7 +192,7 @@ var _ = SynchronizedAfterSuite(func() {},
|
|||||||
}
|
}
|
||||||
// for localized tests, this removes the image cache dir and for remote tests
|
// for localized tests, this removes the image cache dir and for remote tests
|
||||||
// this is a no-op
|
// this is a no-op
|
||||||
removeCache()
|
podmanTest.removeCache(ImageCacheDir)
|
||||||
|
|
||||||
// LockTmpDir can already be removed
|
// LockTmpDir can already be removed
|
||||||
os.RemoveAll(LockTmpDir)
|
os.RemoveAll(LockTmpDir)
|
||||||
@ -560,9 +560,7 @@ func (p *PodmanTestIntegration) Cleanup() {
|
|||||||
|
|
||||||
p.StopRemoteService()
|
p.StopRemoteService()
|
||||||
// Nuke tempdir
|
// Nuke tempdir
|
||||||
if err := os.RemoveAll(p.TempDir); err != nil {
|
p.removeCache(p.TempDir)
|
||||||
fmt.Printf("%q\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up the registries configuration file ENV variable set in Create
|
// Clean up the registries configuration file ENV variable set in Create
|
||||||
resetRegistriesConfigEnv()
|
resetRegistriesConfigEnv()
|
||||||
@ -849,11 +847,21 @@ func populateCache(podman *PodmanTestIntegration) {
|
|||||||
fmt.Printf("-----------------------------\n")
|
fmt.Printf("-----------------------------\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeCache() {
|
func (p *PodmanTestIntegration) removeCache(path string) {
|
||||||
// Remove cache dirs
|
// Remove cache dirs
|
||||||
if err := os.RemoveAll(ImageCacheDir); err != nil {
|
if isRootless() {
|
||||||
|
// If rootless, os.RemoveAll() is failed due to permission denied
|
||||||
|
cmd := exec.Command(p.PodmanBinary, "unshare", "rm", "-rf", path)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := os.RemoveAll(path); err != nil {
|
||||||
fmt.Printf("%q\n", err)
|
fmt.Printf("%q\n", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodmanNoCache calls the podman command with no configured imagecache
|
// PodmanNoCache calls the podman command with no configured imagecache
|
||||||
|
Reference in New Issue
Block a user