return "", fmt.Errorf("cannot choose from multiple tar files in image collection: %v", tarfiles)
}
imageID := tarfiles[0][:len(tarfiles[0])-4]
+ imageTarballPath := runner.ArvMountPoint + "/by_id/" + runner.Container.ContainerImage + "/" + imageID + ".tar"
runner.CrunchLog.Printf("Using Docker image id %q", imageID)
runner.CrunchLog.Print("Loading Docker image from keep")
- err = runner.executor.LoadImage(imageID, runner.Container, runner.ArvMountPoint,
- runner.containerClient, runner.ContainerKeepClient)
+ err = runner.executor.LoadImage(imageID, imageTarballPath, runner.Container, runner.ArvMountPoint,
+ runner.containerClient)
if err != nil {
return "", err
}
exit chan int
}
-func (e *stubExecutor) ImageLoaded(imageID string) bool { return e.imageLoaded }
-func (e *stubExecutor) LoadImage(filename string) error { e.loaded = filename; return e.loadErr }
+func (e *stubExecutor) LoadImage(imageId string, tarball string, container arvados.Container, keepMount string,
+ containerClient *arvados.Client) error {
+ e.loaded = tarball
+ return e.loadErr
+}
func (e *stubExecutor) Create(spec containerSpec) error { e.created = spec; return e.createErr }
func (e *stubExecutor) Start() error { e.exit = make(chan int, 1); go e.runFunc(); return e.startErr }
func (e *stubExecutor) CgroupID() string { return "cgroupid" }
func (e *stubExecutor) Wait(context.Context) (int, error) {
return <-e.exit, e.waitErr
}
-func (e *stubExecutor) SetArvadoClient(containerClient *arvados.Client, keepClient IKeepClient, container arvados.Container, keepMount string) {
-}
const fakeInputCollectionPDH = "ffffffffaaaaaaaa88888888eeeeeeee+1234"
}, err
}
-func (e *dockerExecutor) LoadImage(imageID string, container arvados.Container, arvMountPoint string,
- containerClient *arvados.Client, keepClient IKeepClient) error {
+func (e *dockerExecutor) LoadImage(imageID string, imageTarballPath string, container arvados.Container, arvMountPoint string,
+ containerClient *arvados.Client) error {
_, _, err := e.dockerclient.ImageInspectWithRaw(context.TODO(), imageID)
if err == nil {
// already loaded
return nil
}
- filename := arvMountPoint + "/by_id/" + container.ContainerImage + "/" + imageID + ".tar"
-
- f, err := os.Open(filename)
+ f, err := os.Open(imageTarballPath)
if err != nil {
return err
}
type containerExecutor interface {
// ImageLoad loads the image from the given tarball such that
// it can be used to create/start a container.
- LoadImage(imageID string, container arvados.Container, keepMount string,
- containerClient *arvados.Client, keepClient IKeepClient) error
+ LoadImage(imageID string, imageTarballPath string, container arvados.Container, keepMount string,
+ containerClient *arvados.Client) error
// Wait for the container process to finish, and return its
// exit code. If applicable, also remove the stopped container
"strings"
"time"
+ "git.arvados.org/arvados.git/sdk/go/arvados"
"golang.org/x/net/context"
. "gopkg.in/check.v1"
)
Stdout: nopWriteCloser{&s.stdout},
Stderr: nopWriteCloser{&s.stderr},
}
- err := s.executor.LoadImage(busyboxDockerImage(c))
+ err := s.executor.LoadImage("", busyboxDockerImage(c), arvados.Container{}, "", nil)
c.Assert(err, IsNil)
}
}
func (e *singularityExecutor) checkImageCache(dockerImageID string, container arvados.Container, arvMountPoint string,
- containerClient *arvados.Client, keepClient IKeepClient) (collectionUuid string, err error) {
+ containerClient *arvados.Client) (collectionUuid string, err error) {
// Cache the image to keep
cacheGroup, err := e.getOrCreateProject(container.RuntimeUserUUID, ".cache", containerClient)
},
Limit: 1})
if err != nil {
- return "", fmt.Errorf("error querying for collection '%v': %v", err)
+ return "", fmt.Errorf("error querying for collection '%v': %v", collectionName, err)
}
var imageCollection arvados.Collection
if len(cl.Items) == 1 {
// LoadImage will satisfy ContainerExecuter interface transforming
// containerImage into a sif file for later use.
-func (e *singularityExecutor) LoadImage(dockerImageID string, container arvados.Container, arvMountPoint string,
- containerClient *arvados.Client, keepClient IKeepClient) error {
+func (e *singularityExecutor) LoadImage(dockerImageID string, imageTarballPath string, container arvados.Container, arvMountPoint string,
+ containerClient *arvados.Client) error {
- sifCollectionUUID, err := e.checkImageCache(dockerImageID, container, arvMountPoint, containerClient, keepClient)
- if err != nil {
- return err
+ var sifCollectionUUID string
+ var imageFilename string
+ if containerClient != nil {
+ sifCollectionUUID, err := e.checkImageCache(dockerImageID, container, arvMountPoint, containerClient)
+ if err != nil {
+ return err
+ }
+ imageFilename = fmt.Sprintf("%s/by_uuid/%s/image.sif", arvMountPoint, sifCollectionUUID)
+ } else {
+ imageFilename = e.tmpdir + "/image.sif"
}
- imageTarballPath := arvMountPoint + "/by_id/" + container.ContainerImage + "/" + dockerImageID + ".tar"
-
- imageFilename := fmt.Sprintf("%s/by_uuid/%s/image.sif", arvMountPoint, sifCollectionUUID)
-
- if _, err = os.Stat(imageFilename); os.IsNotExist(err) {
+ if _, err := os.Stat(imageFilename); os.IsNotExist(err) {
exec.Command("find", arvMountPoint+"/by_id/").Run()
e.logf("building singularity image")
}
}
+ if containerClient == nil {
+ e.imageFilename = imageFilename
+ return nil
+ }
+
// update TTL to now + two weeks
exp := time.Now().Add(24 * 7 * 2 * time.Hour)