[ARVADOS] created: 2.1.0-1832-g18c96ade0
Git user
git at public.arvados.org
Tue Jan 18 04:47:35 UTC 2022
at 18c96ade0da52032429e2d62405cab9433c6b61f (commit)
commit 18c96ade0da52032429e2d62405cab9433c6b61f
Author: Tom Clegg <tom at curii.com>
Date: Mon Jan 17 23:44:52 2022 -0500
18513: Decipher status code in crunch-run.txt log.
container exited with status code 137 (signal 9, killed)
Previously, docker mode just said "exited with code: 137" and
singularity mode didn't mention it at all.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index fb2200a56..08b8d4b5f 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -1056,6 +1056,23 @@ func (runner *ContainerRunner) WaitFinish() error {
}
runner.ExitCode = &exitcode
+ extra := ""
+ if exitcode&0x80 != 0 {
+ // Convert raw exit status (0x80 + signal number) to a
+ // string to log after the code, like " (signal 101)"
+ // or " (signal 9, killed)"
+ sig := syscall.WaitStatus(exitcode).Signal()
+ extra = sig.String()
+ if !strings.HasPrefix(extra, "signal ") {
+ // Even if the signal has a name, e.g.,
+ // "killed", we also want to say the signal
+ // number.
+ extra = fmt.Sprintf("signal %d, %s", sig, extra)
+ }
+ extra = " (" + extra + ")"
+ }
+ runner.CrunchLog.Printf("container exited with status code %d%s", exitcode, extra)
+
var returnErr error
if err = runner.executorStdin.Close(); err != nil {
err = fmt.Errorf("error closing container stdin: %s", err)
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index 97f91103a..caa251afd 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -1567,6 +1567,7 @@ func (s *TestSuite) TestFullRunWithAPI(c *C) {
})
c.Check(s.api.CalledWith("container.exit_code", 3), NotNil)
c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
+ c.Check(s.api.Logs["crunch-run"].String(), Matches, `(?ms).*status code 3\n.*`)
}
func (s *TestSuite) TestFullRunSetOutput(c *C) {
@@ -1599,7 +1600,7 @@ func (s *TestSuite) TestArvMountRuntimeStatusWarning(c *C) {
}
s.executor.runFunc = func() {
time.Sleep(time.Second)
- s.executor.exit <- 0
+ s.executor.exit <- 137
}
record := `{
"command": ["sleep", "1"],
@@ -1616,10 +1617,11 @@ func (s *TestSuite) TestArvMountRuntimeStatusWarning(c *C) {
c.Assert(err, IsNil)
err = s.runner.Run()
c.Assert(err, IsNil)
- c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
+ c.Check(s.api.CalledWith("container.exit_code", 137), NotNil)
c.Check(s.api.CalledWith("container.runtime_status.warning", "arv-mount: Keep write error"), NotNil)
c.Check(s.api.CalledWith("container.runtime_status.warningDetail", "Test: Keep write error: I am a teapot"), NotNil)
c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
+ c.Check(s.api.Logs["crunch-run"].String(), Matches, `(?ms).*status code 137 \(signal 9, killed\).*`)
}
func (s *TestSuite) TestStdoutWithExcludeFromOutputMountPointUnderOutputDir(c *C) {
diff --git a/lib/crunchrun/docker.go b/lib/crunchrun/docker.go
index 06e5b5b1e..e62f2a39b 100644
--- a/lib/crunchrun/docker.go
+++ b/lib/crunchrun/docker.go
@@ -215,7 +215,6 @@ func (e *dockerExecutor) Wait(ctx context.Context) (int, error) {
for {
select {
case waitBody := <-waitOk:
- e.logf("Container exited with code: %v", waitBody.StatusCode)
// wait for stdout/stderr to complete
<-e.doneIO
return int(waitBody.StatusCode), nil
diff --git a/lib/crunchrun/executor_test.go b/lib/crunchrun/executor_test.go
index 08c7140ad..2f9b2517c 100644
--- a/lib/crunchrun/executor_test.go
+++ b/lib/crunchrun/executor_test.go
@@ -86,6 +86,22 @@ func (s *executorSuite) TestExecTrivialContainer(c *C) {
c.Check(s.stderr.String(), Equals, "")
}
+func (s *executorSuite) TestExitStatus(c *C) {
+ s.spec.Command = []string{"false"}
+ s.checkRun(c, 1)
+}
+
+func (s *executorSuite) TestSignalExitStatus(c *C) {
+ if strings.HasPrefix(c.TestName(), "dockerSuite.") {
+ // It's not quite this easy to make busybox kill
+ // itself in docker where it's pid 1.
+ c.Skip("kill -9 $$ doesn't work on busybox with pid=1 in docker")
+ return
+ }
+ s.spec.Command = []string{"sh", "-c", "kill -9 $$"}
+ s.checkRun(c, 0x80+9)
+}
+
func (s *executorSuite) TestExecStop(c *C) {
s.spec.Command = []string{"sh", "-c", "sleep 10; echo ok"}
err := s.executor.Create(s.spec)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list