From fbacdaec3dbba425155ab6348c7e6b80ff4e710b Mon Sep 17 00:00:00 2001 From: radhika Date: Sat, 21 Jan 2017 19:05:55 -0500 Subject: [PATCH] 9397: only mount points of kind "collection" are allowed under the output_dir. --- services/crunch-run/crunchrun.go | 6 ++++++ services/crunch-run/crunchrun_test.go | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go index 0eb593939a..dfe2dfa99a 100644 --- a/services/crunch-run/crunchrun.go +++ b/services/crunch-run/crunchrun.go @@ -290,6 +290,12 @@ func (runner *ContainerRunner) SetupMounts() (err error) { needCertMount = false } + if strings.HasPrefix(bind, runner.Container.OutputPath+"/") && bind != runner.Container.OutputPath+"/" { + if mnt.Kind != "collection" { + return fmt.Errorf("Only mount points of kind 'collection' are supported underneath the output_path: %v", bind) + } + } + switch { case mnt.Kind == "collection": var src string diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go index af531f8ca5..1cbaa6ca3b 100644 --- a/services/crunch-run/crunchrun_test.go +++ b/services/crunch-run/crunchrun_test.go @@ -919,7 +919,7 @@ func (s *TestSuite) TestSetupMounts(c *C) { checkEmpty() } - // read-only mount points are allowed underneath output_dir mount point + // Read-only mount points are allowed underneath output_dir mount point { i = 0 cr.Container.Mounts = make(map[string]arvados.Mount) @@ -939,7 +939,7 @@ func (s *TestSuite) TestSetupMounts(c *C) { checkEmpty() } - // writable mount points are not allowed underneath output_dir mount point + // Writable mount points are not allowed underneath output_dir mount point { i = 0 cr.Container.Mounts = make(map[string]arvados.Mount) @@ -955,6 +955,23 @@ func (s *TestSuite) TestSetupMounts(c *C) { cr.CleanupDirs() checkEmpty() } + + // Only mount points of kind 'collection' are allowed underneath output_dir mount point + { + i = 0 + cr.Container.Mounts = make(map[string]arvados.Mount) + cr.Container.Mounts = map[string]arvados.Mount{ + "/tmp": {Kind: "tmp"}, + "/tmp/foo": {Kind: "json"}, + } + cr.OutputPath = "/tmp" + + err := cr.SetupMounts() + c.Check(err, NotNil) + c.Check(err, ErrorMatches, `Only mount points of kind 'collection' are supported underneath the output_path.*`) + cr.CleanupDirs() + checkEmpty() + } } func (s *TestSuite) TestStdout(c *C) { -- 2.30.2