[ARVADOS] updated: 4e676bd941adc7c4751a3ef03aed8f145d432c0c
git at public.curoverse.com
git at public.curoverse.com
Sun Feb 14 21:37:19 EST 2016
Summary of changes:
services/crunch-run/crunchrun.go | 64 +++++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 4 deletions(-)
via 4e676bd941adc7c4751a3ef03aed8f145d432c0c (commit)
from 10382e4e34d7ce9dd572fed50f7747124b2d857a (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 4e676bd941adc7c4751a3ef03aed8f145d432c0c
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Sun Feb 14 21:37:14 2016 -0500
8015: Improve handling for arv-mount start, arv-mount exit.
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 9c52f18..665f107 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -18,6 +18,7 @@ import (
"strings"
"sync"
"syscall"
+ "time"
)
// IArvadosClient is the minimal Arvados API methods used by crunch-run.
@@ -69,6 +70,8 @@ type ContainerRecord struct {
// NewLogWriter is a factory function to create a new log writer.
type NewLogWriter func(name string) io.WriteCloser
+type RunArvMount func([]string) (*exec.Cmd, error)
+
// ThinDockerClient is the minimal Docker client interface used by crunch-run.
type ThinDockerClient interface {
StopContainer(id string, timeout int) error
@@ -98,6 +101,7 @@ type ContainerRunner struct {
Stderr *ThrottledLogger
LogCollection *CollectionWriter
LogsPDH *string
+ RunArvMount
ArvMount *exec.Cmd
ArvMountPoint string
HostOutputDir string
@@ -106,6 +110,7 @@ type ContainerRunner struct {
CancelLock sync.Mutex
Cancelled bool
SigChan chan os.Signal
+ ArvMountExit chan error
finalState string
}
@@ -180,6 +185,50 @@ func (runner *ContainerRunner) LoadImage() (err error) {
return nil
}
+func (runner *ContainerRunner) ArvMountCmd(arvMountCmd []string) (c *exec.Cmd, err error) {
+ c = exec.Command("arv-mount", arvMountCmd...)
+ nt := NewThrottledLogger(runner.NewLogWriter("arv-mount"))
+ c.Stdout = nt
+ c.Stderr = nt
+
+ err = c.Start()
+ if err != nil {
+ return nil, err
+ }
+
+ statReadme := make(chan bool)
+ runner.ArvMountExit = make(chan error)
+
+ keepStatting := true
+ go func() {
+ for keepStatting {
+ time.Sleep(100 * time.Millisecond)
+ _, err = os.Stat(fmt.Sprintf("%s/by_id/README", runner.ArvMountPoint))
+ if err == nil {
+ keepStatting = false
+ statReadme <- true
+ }
+ }
+ close(statReadme)
+ }()
+
+ go func() {
+ runner.ArvMountExit <- c.Wait()
+ close(runner.ArvMountExit)
+ }()
+
+ select {
+ case <-statReadme:
+ break
+ case err := <-runner.ArvMountExit:
+ runner.ArvMount = nil
+ keepStatting = false
+ return nil, err
+ }
+
+ return c, nil
+}
+
func (runner *ContainerRunner) SetupMounts() (err error) {
runner.ArvMountPoint, err = ioutil.TempDir("", "keep")
if err != nil {
@@ -250,10 +299,8 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
}
arvMountCmd = append(arvMountCmd, runner.ArvMountPoint)
- runner.ArvMount = exec.Command("arv-mount", arvMountCmd...)
- err = runner.ArvMount.Start()
+ runner.ArvMount, err = runner.RunArvMount(arvMountCmd)
if err != nil {
- runner.ArvMount = nil
return fmt.Errorf("While trying to start arv-mount: %v", err)
}
@@ -352,7 +399,15 @@ func (runner *ContainerRunner) CaptureOutput() error {
if runner.ArvMount != nil {
defer func() {
umount := exec.Command("fusermount", "-z", "-u", runner.ArvMountPoint)
- umount.Run()
+ umnterr := umount.Run()
+ if umnterr != nil {
+ runner.CrunchLog.Print("While running fusermount: %v", umnterr)
+ }
+
+ mnterr := <-runner.ArvMountExit
+ if mnterr != nil {
+ runner.CrunchLog.Print("Arv-mount exit error: %v", mnterr)
+ }
}()
}
@@ -584,6 +639,7 @@ func NewContainerRunner(api IArvadosClient,
cr := &ContainerRunner{ArvClient: api, Kc: kc, Docker: docker}
cr.NewLogWriter = cr.NewArvLogWriter
+ cr.RunArvMount = cr.ArvMountCmd
cr.LogCollection = &CollectionWriter{kc, nil, sync.Mutex{}}
cr.ContainerRecord.UUID = containerUUID
cr.CrunchLog = NewThrottledLogger(cr.NewLogWriter("crunch-run"))
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list