[ARVADOS] updated: 1.1.0-194-gfbcedc4

Git user git at public.curoverse.com
Wed Nov 29 11:58:41 EST 2017


Summary of changes:
 services/crunch-run/crunchrun.go      | 20 +++++++-------------
 services/crunch-run/crunchrun_test.go | 21 ++++++++++++++++-----
 2 files changed, 23 insertions(+), 18 deletions(-)

       via  fbcedc4041edae0c1ff5367915bb75d60d47a99f (commit)
      from  a7bbcabfeb74bd61ca92078a0a49caeab01e08bc (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 fbcedc4041edae0c1ff5367915bb75d60d47a99f
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Wed Nov 29 11:56:46 2017 -0500

    12614: Restore order set state "Running" before starting the container.
    
    Use "Matches" in tests.
    
    Broken node hook tests that output is captured.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 3c6d7d2..180da0c 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -229,13 +229,13 @@ func (runner *ContainerRunner) stopSignals() {
 }
 
 var errorBlacklist = []string{"Cannot connect to the Docker daemon"}
-var brokenNodeHook *string
+var brokenNodeHook *string = flag.String("broken-node-hook", "", "Script to run if node is detected to be broken (for example, Docker daemon is not running)")
 
 func (runner *ContainerRunner) checkBrokenNode(goterr error) bool {
 	for _, d := range errorBlacklist {
 		if strings.Index(goterr.Error(), d) != -1 {
 			runner.CrunchLog.Printf("Error suggests node is unable to run containers: %v", goterr)
-			if brokenNodeHook == nil || *brokenNodeHook == "" {
+			if *brokenNodeHook == "" {
 				runner.CrunchLog.Printf("No broken node hook provided, cannot mark node as broken.")
 			} else {
 				runner.CrunchLog.Printf("Running broken node hook %q", *brokenNodeHook)
@@ -1550,22 +1550,17 @@ func (runner *ContainerRunner) Run() (err error) {
 		return
 	}
 
-	runner.StartCrunchstat()
-
-	err = runner.StartContainer()
+	err = runner.UpdateContainerRunning()
 	if err != nil {
-		if !runner.checkBrokenNode(err) {
-			// Failed to start container but not a "broken node"
-			// condition, assume user error.
-			runner.finalState = "Cancelled"
-		}
 		return
 	}
-
 	runner.finalState = "Cancelled"
 
-	err = runner.UpdateContainerRunning()
+	runner.StartCrunchstat()
+
+	err = runner.StartContainer()
 	if err != nil {
+		runner.checkBrokenNode(err)
 		return
 	}
 
@@ -1629,7 +1624,6 @@ func main() {
 		`Set networking mode for container.  Corresponds to Docker network mode (--net).
     	`)
 	memprofile := flag.String("memprofile", "", "write memory profile to `file` after running container")
-	brokenNodeHook = flag.String("broken-node-hook", "", "Script to run if node is detected to be broken (for example, Docker daemon is not running)")
 	flag.Parse()
 
 	containerId := flag.Arg(0)
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index bcf9704..4702838 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -1769,7 +1769,17 @@ func (s *TestSuite) TestEvalSymlinkDir(c *C) {
 }
 
 func (s *TestSuite) TestFullBrokenDocker1(c *C) {
-	ech := "/bin/echo"
+	tf, err := ioutil.TempFile("", "brokenNodeHook-")
+	c.Assert(err, IsNil)
+	defer os.Remove(tf.Name())
+
+	tf.Write([]byte(`#!/bin/sh
+exec echo killme
+`))
+	tf.Close()
+	os.Chmod(tf.Name(), 0700)
+
+	ech := tf.Name()
 	brokenNodeHook = &ech
 
 	api, _, _ := FullRunHelper(c, `{
@@ -1787,8 +1797,9 @@ func (s *TestSuite) TestFullBrokenDocker1(c *C) {
 	})
 
 	c.Check(api.CalledWith("container.state", "Queued"), NotNil)
-	c.Check(strings.Index(api.Logs["crunch-run"].String(), "unable to run containers"), Not(Equals), -1)
-	c.Check(strings.Index(api.Logs["crunch-run"].String(), "Running broken node hook \"/bin/echo\""), Not(Equals), -1)
+	c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*unable to run containers.*")
+	c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*Running broken node hook.*")
+	c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*killme.*")
 
 }
 
@@ -1811,6 +1822,6 @@ func (s *TestSuite) TestFullBrokenDocker2(c *C) {
 	})
 
 	c.Check(api.CalledWith("container.state", "Queued"), NotNil)
-	c.Check(strings.Index(api.Logs["crunch-run"].String(), "unable to run containers"), Not(Equals), -1)
-	c.Check(strings.Index(api.Logs["crunch-run"].String(), "No broken node hook"), Not(Equals), -1)
+	c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*unable to run containers.*")
+	c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*No broken node hook.*")
 }

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list