X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2b8f39b5067103d60f7bc43d26cb2f59126b2a42..516685e09227ab64c2d4f7fd04d4b60a75fc5d0f:/services/crunch-run/crunchrun.go diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go index 27136b4522..1deb740316 100644 --- a/services/crunch-run/crunchrun.go +++ b/services/crunch-run/crunchrun.go @@ -61,6 +61,7 @@ type IKeepClient interface { PutB(buf []byte) (string, int, error) ReadAt(locator string, p []byte, off int) (int, error) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) + LocalLocator(locator string) (string, error) ClearBlockCache() } @@ -122,7 +123,7 @@ type ContainerRunner struct { SigChan chan os.Signal ArvMountExit chan error SecretMounts map[string]arvados.Mount - MkArvClient func(token string) (IArvadosClient, error) + MkArvClient func(token string) (IArvadosClient, IKeepClient, error) finalState string parentTemp string @@ -237,8 +238,17 @@ func (runner *ContainerRunner) LoadImage() (err error) { runner.CrunchLog.Printf("Fetching Docker image from collection '%s'", runner.Container.ContainerImage) + tok, err := runner.ContainerToken() + if err != nil { + return fmt.Errorf("While getting container token (LoadImage): %v", err) + } + arvClient, kc, err := runner.MkArvClient(tok) + if err != nil { + return fmt.Errorf("While creating arv client (LoadImage): %v", err) + } + var collection arvados.Collection - err = runner.ArvClient.Get("collections", runner.Container.ContainerImage, nil, &collection) + err = arvClient.Get("collections", runner.Container.ContainerImage, nil, &collection) if err != nil { return fmt.Errorf("While getting container image collection: %v", err) } @@ -259,7 +269,7 @@ func (runner *ContainerRunner) LoadImage() (err error) { runner.CrunchLog.Print("Loading Docker image from keep") var readCloser io.ReadCloser - readCloser, err = runner.Kc.ManifestFileReader(manifest, img) + readCloser, err = kc.ManifestFileReader(manifest, img) if err != nil { return fmt.Errorf("While creating ManifestFileReader for container image: %v", err) } @@ -281,7 +291,7 @@ func (runner *ContainerRunner) LoadImage() (err error) { runner.ContainerConfig.Image = imageID - runner.Kc.ClearBlockCache() + kc.ClearBlockCache() return nil } @@ -1293,6 +1303,17 @@ func (runner *ContainerRunner) CaptureOutput() error { if err != nil { return err } + if n := len(regexp.MustCompile(` [0-9a-f]+\+\S*\+R`).FindAllStringIndex(txt, -1)); n > 0 { + runner.CrunchLog.Printf("Copying %d data blocks from remote input collections...", n) + fs, err := (&arvados.Collection{ManifestText: txt}).FileSystem(runner.client, runner.Kc) + if err != nil { + return err + } + txt, err = fs.MarshalManifest(".") + if err != nil { + return err + } + } var resp arvados.Collection err = runner.ArvClient.Create("collections", arvadosclient.Dict{ "ensure_unique_name": true, @@ -1679,7 +1700,7 @@ func (runner *ContainerRunner) fetchContainerRecord() error { return fmt.Errorf("error getting container token: %v", err) } - containerClient, err := runner.MkArvClient(containerToken) + containerClient, _, err := runner.MkArvClient(containerToken) if err != nil { return fmt.Errorf("error creating container API client: %v", err) } @@ -1719,13 +1740,17 @@ func NewContainerRunner(client *arvados.Client, api IArvadosClient, kc IKeepClie } return ps, nil } - cr.MkArvClient = func(token string) (IArvadosClient, error) { + cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) { cl, err := arvadosclient.MakeArvadosClient() if err != nil { - return nil, err + return nil, nil, err } cl.ApiToken = token - return cl, nil + kc, err := keepclient.MakeKeepClient(cl) + if err != nil { + return nil, nil, err + } + return cl, kc, nil } var err error cr.LogCollection, err = (&arvados.Collection{}).FileSystem(cr.client, cr.Kc)