15370: Re-enable docker tests.
[arvados.git] / lib / crunchrun / executor.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4 package crunchrun
5
6 import (
7         "io"
8
9         "git.arvados.org/arvados.git/sdk/go/arvados"
10         "golang.org/x/net/context"
11 )
12
13 type bindmount struct {
14         HostPath string
15         ReadOnly bool
16 }
17
18 type containerSpec struct {
19         Image           string
20         VCPUs           int
21         RAM             int64
22         WorkingDir      string
23         Env             map[string]string
24         BindMounts      map[string]bindmount
25         Command         []string
26         EnableNetwork   bool
27         CUDADeviceCount int
28         NetworkMode     string // docker network mode, normally "default"
29         CgroupParent    string
30         Stdin           io.Reader
31         Stdout          io.Writer
32         Stderr          io.Writer
33 }
34
35 // containerExecutor is an interface to a container runtime
36 // (docker/singularity).
37 type containerExecutor interface {
38         // ImageLoad loads the image from the given tarball such that
39         // it can be used to create/start a container.
40         LoadImage(imageID string, imageTarballPath string, container arvados.Container, keepMount string,
41                 containerClient *arvados.Client) error
42
43         // Wait for the container process to finish, and return its
44         // exit code. If applicable, also remove the stopped container
45         // before returning.
46         Wait(context.Context) (int, error)
47
48         // Create a container, but don't start it yet.
49         Create(containerSpec) error
50
51         // Start the container
52         Start() error
53
54         // CID the container will belong to
55         CgroupID() string
56
57         // Stop the container immediately
58         Stop() error
59
60         // Release resources (temp dirs, stopped containers)
61         Close()
62
63         // Name and version of runtime engine ("docker 20.10.16", "singularity-ce version 3.9.9")
64         Runtime() string
65
66         GatewayTarget
67 }