summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-06-18 17:01:53 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-06-19 09:57:33 -0400
commit30f24bb76051f403c662ef4a317b50dd1b3b045a (patch)
tree42a278c1abc31f3e8a37393af90ed0d74ea9c972
parent8e5b294ac3429b8c59dd014a1583d0d77ea2380a (diff)
downloadpodman-30f24bb76051f403c662ef4a317b50dd1b3b045a.tar.gz
podman-30f24bb76051f403c662ef4a317b50dd1b3b045a.tar.bz2
podman-30f24bb76051f403c662ef4a317b50dd1b3b045a.zip
Add tests for cached and delegated mounts
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r--pkg/spec/storage.go23
-rw-r--r--test/e2e/run_volume_test.go18
2 files changed, 26 insertions, 15 deletions
diff --git a/pkg/spec/storage.go b/pkg/spec/storage.go
index c960ace33..ed767f5ba 100644
--- a/pkg/spec/storage.go
+++ b/pkg/spec/storage.go
@@ -582,22 +582,7 @@ func ValidateVolumeCtrDir(ctrDir string) error {
func ValidateVolumeOpts(options []string) ([]string, error) {
var foundRootPropagation, foundRWRO, foundLabelChange, bindType int
finalOpts := make([]string, 0, len(options))
- discardOpts := []string{"cached", "delegated"}
for _, opt := range options {
- // The discarded ops are OS X specific volume options introduced
- // in a recent Docker version.
- // They have no meaning on Linux, so here we silently drop them.
- // This matches Docker's behavior (the options are intended to
- // be always safe to use, even not on OS X).
- bad := false
- for _, discard := range discardOpts {
- if opt == discard {
- bad = true
- }
- }
- if bad {
- continue
- }
switch opt {
case "rw", "ro":
foundRWRO++
@@ -619,6 +604,14 @@ func ValidateVolumeOpts(options []string) ([]string, error) {
if bindType > 1 {
return nil, errors.Errorf("invalid options %q, can only specify 1 '[r]bind' option", strings.Join(options, ", "))
}
+ case "cached", "delegated":
+ // The discarded ops are OS X specific volume options
+ // introduced in a recent Docker version.
+ // They have no meaning on Linux, so here we silently
+ // drop them. This matches Docker's behavior (the options
+ // are intended to be always safe to use, even not on OS
+ // X).
+ continue
default:
return nil, errors.Errorf("invalid mount option %q", opt)
}
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index d89c80909..9e160e73c 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -63,6 +63,24 @@ var _ = Describe("Podman run with volumes", func() {
Expect(found).Should(BeTrue())
Expect(matches[0]).To(ContainSubstring("rw"))
Expect(matches[0]).To(ContainSubstring("shared"))
+
+ // Cached is ignored
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:cached", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ found, matches = session.GrepString("/run/test")
+ Expect(found).Should(BeTrue())
+ Expect(matches[0]).To(ContainSubstring("rw"))
+ Expect(matches[0]).To(Not(ContainSubstring("cached")))
+
+ // Delegated is ignored
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:delegated", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ found, matches = session.GrepString("/run/test")
+ Expect(found).Should(BeTrue())
+ Expect(matches[0]).To(ContainSubstring("rw"))
+ Expect(matches[0]).To(Not(ContainSubstring("delegated")))
})
It("podman run with --mount flag", func() {