-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
volume: add support for non-volatile upperdir
,workdir
for overlay volumes
#12712
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,60 @@ var _ = Describe("Podman run with volumes", func() { | |
|
||
}) | ||
|
||
It("podman support overlay on named volume with custom upperdir and workdir", func() { | ||
SkipIfRemote("Overlay volumes only work locally") | ||
if os.Getenv("container") != "" { | ||
Skip("Overlay mounts not supported when running in a container") | ||
} | ||
if rootless.IsRootless() { | ||
if _, err := exec.LookPath("fuse-overlayfs"); err != nil { | ||
Skip("Fuse-Overlayfs required for rootless overlay mount test") | ||
} | ||
} | ||
|
||
// create persistent upperdir on host | ||
upperDir := filepath.Join(tempdir, "upper") | ||
err := os.Mkdir(upperDir, 0755) | ||
Expect(err).To(BeNil(), "mkdir "+upperDir) | ||
|
||
// create persistent workdir on host | ||
workDir := filepath.Join(tempdir, "work") | ||
err = os.Mkdir(workDir, 0755) | ||
Expect(err).To(BeNil(), "mkdir "+workDir) | ||
|
||
overlayOpts := fmt.Sprintf("upperdir=%s,workdir=%s", upperDir, workDir) | ||
|
||
session := podmanTest.Podman([]string{"volume", "create", "myvolume"}) | ||
session.WaitWithDefaultTimeout() | ||
volName := session.OutputToString() | ||
Expect(session).Should(Exit(0)) | ||
|
||
// create file on actual volume | ||
session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data", ALPINE, "sh", "-c", "echo hello >> " + "/data/test"}) | ||
session.WaitWithDefaultTimeout() | ||
Expect(session).Should(Exit(0)) | ||
|
||
// create file on overlay volume | ||
session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data:O," + overlayOpts, ALPINE, "sh", "-c", "echo hello >> " + "/data/overlay"}) | ||
session.WaitWithDefaultTimeout() | ||
Expect(session).Should(Exit(0)) | ||
|
||
session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data:O," + overlayOpts, ALPINE, "sh", "-c", "ls /data"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test two volume mounts, one without overlayOpts and one without, and make sure the one without is not perment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes added another mount with just |
||
session.WaitWithDefaultTimeout() | ||
// must contain `overlay` file since it should be persistent on specified upper and workdir | ||
Expect(session.OutputToString()).To(ContainSubstring("overlay")) | ||
// this should be there since `test` was written on actual volume not on any overlay | ||
Expect(session.OutputToString()).To(ContainSubstring("test")) | ||
|
||
session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data:O", ALPINE, "sh", "-c", "ls /data"}) | ||
session.WaitWithDefaultTimeout() | ||
// must not contain `overlay` file which was on custom upper and workdir since we have not specified any upper or workdir | ||
Expect(session.OutputToString()).To(Not(ContainSubstring("overlay"))) | ||
// this should be there since `test` was written on actual volume not on any overlay | ||
Expect(session.OutputToString()).To(ContainSubstring("test")) | ||
|
||
}) | ||
|
||
It("podman run with noexec can't exec", func() { | ||
session := podmanTest.Podman([]string{"run", "--rm", "-v", "/bin:/hostbin:noexec", ALPINE, "/hostbin/ls", "/"}) | ||
session.WaitWithDefaultTimeout() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you check for duplicates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We ignore in underlying library if upperdir is empty. But I agree user should get early error so added here.