From c05ce270f86d67c4007d3ba5d6b1559046cbb3b7 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Fri, 3 Oct 2014 16:55:39 -0400 Subject: [PATCH 1/2] Fixes bad validMountMode check Needed to check if the mode was invalid and return error, not valid and return error. This didn't get picked up because the existing integration-cli tests were all either expecting errors when a valid mode was passed in (e.g. "ro" passed in, we expected an error because it was testing write). So modified a test which was testing for "rw" to actually pass in "rw" instead of assuming the "rw" Docker-DCO-1.1-Signed-off-by: Brian Goff (github: cpuguy83) Upstream-commit: 007b4f63409c6c642fb075640a8ec7d58825edc8 Component: engine --- components/engine/daemon/volumes.go | 2 +- components/engine/integration-cli/docker_cli_run_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/daemon/volumes.go b/components/engine/daemon/volumes.go index 3d6864b7d5..867bbb44ef 100644 --- a/components/engine/daemon/volumes.go +++ b/components/engine/daemon/volumes.go @@ -235,7 +235,7 @@ func parseVolumesFromSpec(daemon *Daemon, spec string) (map[string]*Mount, error if len(specParts) == 2 { mode := specParts[1] - if validMountMode(mode) { + if !validMountMode(mode) { return nil, fmt.Errorf("Invalid mode for volumes-from: %s", mode) } diff --git a/components/engine/integration-cli/docker_cli_run_test.go b/components/engine/integration-cli/docker_cli_run_test.go index 01a3f57638..e218430ced 100644 --- a/components/engine/integration-cli/docker_cli_run_test.go +++ b/components/engine/integration-cli/docker_cli_run_test.go @@ -389,7 +389,7 @@ func TestRunVolumesFromInReadWriteMode(t *testing.T) { t.Fatal(err) } - cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent", "busybox", "touch", "/test/file") + cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:rw", "busybox", "touch", "/test/file") if _, err := runCommand(cmd); err != nil { t.Fatal(err) } From 143d6d01457442072be050b8d7535772883f3286 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Fri, 3 Oct 2014 15:33:11 -0700 Subject: [PATCH 2/2] Add test for invalid mount mode for volumes in. Closes #8389. Docker-DCO-1.1-Signed-off-by: Jessica Frazelle (github: jfrazelle) Upstream-commit: b10b458b6ef8327268676744a7c3230e33c9baf6 Component: engine --- .../engine/integration-cli/docker_cli_run_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_run_test.go b/components/engine/integration-cli/docker_cli_run_test.go index e218430ced..401c6438c0 100644 --- a/components/engine/integration-cli/docker_cli_run_test.go +++ b/components/engine/integration-cli/docker_cli_run_test.go @@ -390,8 +390,18 @@ func TestRunVolumesFromInReadWriteMode(t *testing.T) { } cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:rw", "busybox", "touch", "/test/file") - if _, err := runCommand(cmd); err != nil { - t.Fatal(err) + if out, _, err := runCommandWithOutput(cmd); err != nil { + t.Fatalf("running --volumes-from parent:rw failed with output: %q\nerror: %v", out, err) + } + + cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:bar", "busybox", "touch", "/test/file") + if out, _, err := runCommandWithOutput(cmd); err == nil || !strings.Contains(out, "Invalid mode for volumes-from: bar") { + t.Fatalf("running --volumes-from foo:bar should have failed with invalid mount mode: %q", out) + } + + cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent", "busybox", "touch", "/test/file") + if out, _, err := runCommandWithOutput(cmd); err != nil { + t.Fatalf("running --volumes-from parent failed with output: %q\nerror: %v", out, err) } deleteAllContainers()