"git.arvados.org/arvados.git/sdk/go/arvadosclient"
"git.arvados.org/arvados.git/sdk/go/keepclient"
"git.arvados.org/arvados.git/sdk/go/manifest"
+ "golang.org/x/sys/unix"
)
type command struct{}
}
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()
+ if name := unix.SignalName(sig); name != "" {
+ extra = fmt.Sprintf(" (signal %d, %s)", sig, name)
+ } else {
+ extra = fmt.Sprintf(" (signal %d)", sig)
+ }
+ }
+ 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)
})
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) {
}
s.executor.runFunc = func() {
time.Sleep(time.Second)
- s.executor.exit <- 0
+ s.executor.exit <- 137
}
record := `{
"command": ["sleep", "1"],
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).*Container exited with status code 137 \(signal 9, SIGKILL\).*`)
}
func (s *TestSuite) TestStdoutWithExcludeFromOutputMountPointUnderOutputDir(c *C) {
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
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 _, isdocker := s.executor.(*dockerExecutor); isdocker {
+ // 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)