]> git.arvados.org - arvados.git/blob - lib/crunchrun/executor.go
Merge branch '23009-multiselect-bug' into main. Closes #23009
[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         "context"
8         "io"
9
10         "git.arvados.org/arvados.git/sdk/go/arvados"
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         GPUStack       string
28         GPUDeviceCount int
29         NetworkMode    string // docker network mode, normally "default"
30         CgroupParent   string
31         Stdin          io.Reader
32         Stdout         io.Writer
33         Stderr         io.Writer
34 }
35
36 // containerExecutor is an interface to a container runtime
37 // (docker/singularity).
38 type containerExecutor interface {
39         // ImageLoad loads the image from the given tarball such that
40         // it can be used to create/start a container.
41         LoadImage(imageID string, imageTarballPath string, container arvados.Container, keepMount string,
42                 containerClient *arvados.Client) error
43
44         // Wait for the container process to finish, and return its
45         // exit code. If applicable, also remove the stopped container
46         // before returning.
47         Wait(context.Context) (int, error)
48
49         // Create a container, but don't start it yet.
50         Create(containerSpec) error
51
52         // Start the container
53         Start() error
54
55         // Process ID of a process in the container.  Return 0 if
56         // container is finished or no process has started yet.
57         Pid() int
58
59         // Stop the container immediately
60         Stop() error
61
62         // Release resources (temp dirs, stopped containers)
63         Close()
64
65         // Name and version of runtime engine ("docker 20.10.16", "singularity-ce version 3.9.9")
66         Runtime() string
67
68         GatewayTarget
69 }