[ARVADOS] updated: 735502484467241d088fd3c2ebbccc0d6a628dc1

Git user git at public.curoverse.com
Tue May 10 11:26:33 EDT 2016


Summary of changes:
 services/crunch-run/crunchrun.go      | 34 +++++++-----------------------
 services/crunch-run/crunchrun_test.go | 39 +++++------------------------------
 2 files changed, 13 insertions(+), 60 deletions(-)

       via  735502484467241d088fd3c2ebbccc0d6a628dc1 (commit)
      from  c217491f9fdc78bd1c665618137c053a852599ac (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 735502484467241d088fd3c2ebbccc0d6a628dc1
Author: radhika <radhika at curoverse.com>
Date:   Tue May 10 11:25:45 2016 -0400

    8464: stdout handling

diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index acaa5a2..cebebb1 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -15,6 +15,7 @@ import (
 	"os"
 	"os/exec"
 	"os/signal"
+	"path"
 	"strings"
 	"sync"
 	"syscall"
@@ -313,17 +314,6 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
 			} else {
 				runner.Binds = append(runner.Binds, bind)
 			}
-		} else if mnt.Kind == "file" {
-			runner.HostOutputDir = runner.ContainerRecord.OutputPath
-			st, staterr := os.Stat(runner.HostOutputDir)
-			if staterr != nil {
-				return fmt.Errorf("While getting stat on output_path %v: %v", runner.HostOutputDir, staterr)
-			}
-			if st.IsDir() != true {
-				return fmt.Errorf("Given output_path '%v' is not a directory", runner.HostOutputDir)
-			}
-		} else {
-			return fmt.Errorf("Unknown mount kind '%s'", mnt.Kind)
 		}
 	}
 
@@ -409,32 +399,24 @@ func (runner *ContainerRunner) AttachStreams() (err error) {
 
 	runner.loggingDone = make(chan bool)
 
-	var stdoutMnt Mount
-	for bind, mnt := range runner.ContainerRecord.Mounts {
-		if bind == "stdout" {
-			stdoutMnt = mnt
-			break
-		}
-	}
-	if stdoutMnt.Path != "" {
+	if stdoutMnt, ok := runner.ContainerRecord.Mounts["stdout"]; ok {
 		stdoutPath := stdoutMnt.Path[len(runner.ContainerRecord.OutputPath):]
 		index := strings.LastIndex(stdoutPath, "/")
 		if index > 0 {
-			stdoutSubdirs := stdoutPath[:index]
-			if stdoutSubdirs != "" {
+			subdirs := stdoutPath[:index]
+			if subdirs != "" {
 				st, err := os.Stat(runner.HostOutputDir)
 				if err != nil {
 					return fmt.Errorf("While Stat on temp dir: %v", err)
 				}
-				path := runner.HostOutputDir + stdoutSubdirs
-				err = os.MkdirAll(path, st.Mode()|os.ModeSetgid|0777)
+				stdoutPath := path.Join(runner.HostOutputDir, subdirs)
+				err = os.MkdirAll(stdoutPath, st.Mode()|os.ModeSetgid|0777)
 				if err != nil {
-					return fmt.Errorf("While MkdirAll %q: %v", path, err)
+					return fmt.Errorf("While MkdirAll %q: %v", stdoutPath, err)
 				}
-				st, err = os.Stat(path)
 			}
 		}
-		stdoutFile, err := os.Create(runner.HostOutputDir + "/" + stdoutPath)
+		stdoutFile, err := os.Create(path.Join(runner.HostOutputDir, stdoutPath))
 		if err != nil {
 			return fmt.Errorf("While creating stdout file: %v", err)
 		}
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index a58fae0..1f2aa20 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -734,34 +734,27 @@ func (s *TestSuite) TestSetupMounts(c *C) {
 }
 
 func (s *TestSuite) TestStdout(c *C) {
-	tmpdir, _ := ioutil.TempDir("", "test-stdout")
-	defer func() {
-		os.RemoveAll(tmpdir)
-	}()
-
 	helperRecord := `{`
 	helperRecord += `"command": ["/bin/sh", "-c", "echo $FROBIZ"],`
 	helperRecord += `"container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",`
 	helperRecord += `"cwd": "/bin",`
 	helperRecord += `"environment": {"FROBIZ": "bilbo"},`
-	helperRecord += `"mounts": {"stdout": {"kind": "file", "path": "` + tmpdir + `/a/b/c.out"} },`
-	helperRecord += `"output_path": "` + tmpdir + `",`
+	helperRecord += `"mounts": {"/tmp": {"kind": "tmp"}, "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"} },`
+	helperRecord += `"output_path": "/tmp",`
 	helperRecord += `"priority": 1,`
 	helperRecord += `"runtime_constraints": {}`
 	helperRecord += `}`
 
-	api, cr := FullRunHelper(c, helperRecord, func(t *TestDockerClient) {
+	api, _ := FullRunHelper(c, helperRecord, func(t *TestDockerClient) {
 		t.logWriter.Write(dockerLog(1, t.env[0][7:]+"\n"))
 		t.logWriter.Close()
 		t.finish <- dockerclient.WaitResult{ExitCode: 0}
 	})
+
 	c.Check(api.Calls, Equals, 6)
 	c.Check(api.Content[5]["container"].(arvadosclient.Dict)["exit_code"], Equals, 0)
 	c.Check(api.Content[5]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
-	stdout := cr.HostOutputDir + "/a/b/c.out"
-	data, err := ioutil.ReadFile(stdout)
-	c.Check(err, IsNil)
-	c.Check("bilbo\n", Equals, string(data))
+	c.Check(api.Content[2]["collection"].(arvadosclient.Dict)["manifest_text"], Equals, "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n")
 }
 
 // Used by the TestStdoutWithWrongPath*()
@@ -812,25 +805,3 @@ func (s *TestSuite) TestStdoutWithWrongKindCollection(c *C) {
 	c.Check(err, NotNil)
 	c.Check(strings.Contains(err.Error(), "Unsupported mount kind 'collection' for stdout"), Equals, true)
 }
-
-func (s *TestSuite) TestStdoutNoSuchDir(c *C) {
-	tmpdir, _ := ioutil.TempDir("", "test-stdout")
-	defer func() {
-		os.RemoveAll(tmpdir)
-	}()
-
-	helperRecord := `{`
-	helperRecord += `"command": ["/bin/sh", "-c", "echo $FROBIZ"],`
-	helperRecord += `"container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",`
-	helperRecord += `"cwd": "/bin",`
-	helperRecord += `"environment": {"FROBIZ": "bilbo"},`
-	helperRecord += `"mounts": {"stdout": {"kind": "file", "path": "` + tmpdir + `/nosuchsubdir/a/b/c.out"} },`
-	helperRecord += `"output_path": "` + tmpdir + `/nosuchsubdir",`
-	helperRecord += `"priority": 1,`
-	helperRecord += `"runtime_constraints": {}`
-	helperRecord += `}`
-
-	_, _, err := StdoutErrorRunHelper(c, helperRecord, func(t *TestDockerClient) {})
-	c.Check(err, NotNil)
-	c.Check(strings.Contains(err.Error(), "/nosuchsubdir: no such file or directory"), Equals, true)
-}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list