Merge branch '21258-flaky-adc-test'
[arvados.git] / sdk / go / arvados / container.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import "time"
8
9 // Container is an arvados#container resource.
10 type Container struct {
11         UUID                      string                 `json:"uuid"`
12         Etag                      string                 `json:"etag"`
13         CreatedAt                 time.Time              `json:"created_at"`
14         ModifiedByClientUUID      string                 `json:"modified_by_client_uuid"`
15         ModifiedByUserUUID        string                 `json:"modified_by_user_uuid"`
16         ModifiedAt                time.Time              `json:"modified_at"`
17         Command                   []string               `json:"command"`
18         ContainerImage            string                 `json:"container_image"`
19         Cwd                       string                 `json:"cwd"`
20         Environment               map[string]string      `json:"environment"`
21         LockedByUUID              string                 `json:"locked_by_uuid"`
22         LockCount                 int                    `json:"lock_count"`
23         Mounts                    map[string]Mount       `json:"mounts"`
24         Output                    string                 `json:"output"`
25         OutputPath                string                 `json:"output_path"`
26         Priority                  int64                  `json:"priority"`
27         RuntimeConstraints        RuntimeConstraints     `json:"runtime_constraints"`
28         State                     ContainerState         `json:"state"`
29         SchedulingParameters      SchedulingParameters   `json:"scheduling_parameters"`
30         ExitCode                  int                    `json:"exit_code"`
31         RuntimeStatus             map[string]interface{} `json:"runtime_status"`
32         StartedAt                 *time.Time             `json:"started_at"`  // nil if not yet started
33         FinishedAt                *time.Time             `json:"finished_at"` // nil if not yet finished
34         GatewayAddress            string                 `json:"gateway_address"`
35         InteractiveSessionStarted bool                   `json:"interactive_session_started"`
36         OutputStorageClasses      []string               `json:"output_storage_classes"`
37         RuntimeUserUUID           string                 `json:"runtime_user_uuid"`
38         RuntimeAuthScopes         []string               `json:"runtime_auth_scopes"`
39         RuntimeToken              string                 `json:"runtime_token"`
40         AuthUUID                  string                 `json:"auth_uuid"`
41         Log                       string                 `json:"log"`
42         Cost                      float64                `json:"cost"`
43         SubrequestsCost           float64                `json:"subrequests_cost"`
44 }
45
46 // ContainerRequest is an arvados#container_request resource.
47 type ContainerRequest struct {
48         UUID                    string                 `json:"uuid"`
49         OwnerUUID               string                 `json:"owner_uuid"`
50         CreatedAt               time.Time              `json:"created_at"`
51         ModifiedByClientUUID    string                 `json:"modified_by_client_uuid"`
52         ModifiedByUserUUID      string                 `json:"modified_by_user_uuid"`
53         ModifiedAt              time.Time              `json:"modified_at"`
54         Href                    string                 `json:"href"`
55         Etag                    string                 `json:"etag"`
56         Name                    string                 `json:"name"`
57         Description             string                 `json:"description"`
58         Properties              map[string]interface{} `json:"properties"`
59         State                   ContainerRequestState  `json:"state"`
60         RequestingContainerUUID string                 `json:"requesting_container_uuid"`
61         ContainerUUID           string                 `json:"container_uuid"`
62         ContainerCountMax       int                    `json:"container_count_max"`
63         Mounts                  map[string]Mount       `json:"mounts"`
64         RuntimeConstraints      RuntimeConstraints     `json:"runtime_constraints"`
65         SchedulingParameters    SchedulingParameters   `json:"scheduling_parameters"`
66         ContainerImage          string                 `json:"container_image"`
67         Environment             map[string]string      `json:"environment"`
68         Cwd                     string                 `json:"cwd"`
69         Command                 []string               `json:"command"`
70         OutputPath              string                 `json:"output_path"`
71         OutputName              string                 `json:"output_name"`
72         OutputTTL               int                    `json:"output_ttl"`
73         Priority                int                    `json:"priority"`
74         UseExisting             bool                   `json:"use_existing"`
75         LogUUID                 string                 `json:"log_uuid"`
76         OutputUUID              string                 `json:"output_uuid"`
77         RuntimeToken            string                 `json:"runtime_token"`
78         ExpiresAt               time.Time              `json:"expires_at"`
79         Filters                 []Filter               `json:"filters"`
80         ContainerCount          int                    `json:"container_count"`
81         OutputStorageClasses    []string               `json:"output_storage_classes"`
82         OutputProperties        map[string]interface{} `json:"output_properties"`
83         CumulativeCost          float64                `json:"cumulative_cost"`
84 }
85
86 // Mount is special behavior to attach to a filesystem path or device.
87 type Mount struct {
88         Kind              string      `json:"kind"`
89         Writable          bool        `json:"writable"`
90         PortableDataHash  string      `json:"portable_data_hash"`
91         UUID              string      `json:"uuid"`
92         DeviceType        string      `json:"device_type"`
93         Path              string      `json:"path"`
94         Content           interface{} `json:"content"`
95         ExcludeFromOutput bool        `json:"exclude_from_output"`
96         Capacity          int64       `json:"capacity"`
97         Commit            string      `json:"commit"`          // only if kind=="git_tree"
98         RepositoryName    string      `json:"repository_name"` // only if kind=="git_tree"
99         GitURL            string      `json:"git_url"`         // only if kind=="git_tree"
100 }
101
102 type CUDARuntimeConstraints struct {
103         DriverVersion      string `json:"driver_version"`
104         HardwareCapability string `json:"hardware_capability"`
105         DeviceCount        int    `json:"device_count"`
106 }
107
108 // RuntimeConstraints specify a container's compute resources (RAM,
109 // CPU) and network connectivity.
110 type RuntimeConstraints struct {
111         API           bool                   `json:"API"`
112         RAM           int64                  `json:"ram"`
113         VCPUs         int                    `json:"vcpus"`
114         KeepCacheRAM  int64                  `json:"keep_cache_ram"`
115         KeepCacheDisk int64                  `json:"keep_cache_disk"`
116         CUDA          CUDARuntimeConstraints `json:"cuda"`
117 }
118
119 // SchedulingParameters specify a container's scheduling parameters
120 // such as Partitions
121 type SchedulingParameters struct {
122         Partitions  []string `json:"partitions"`
123         Preemptible bool     `json:"preemptible"`
124         MaxRunTime  int      `json:"max_run_time"`
125         Supervisor  bool     `json:"supervisor"`
126 }
127
128 // ContainerList is an arvados#containerList resource.
129 type ContainerList struct {
130         Items          []Container `json:"items"`
131         ItemsAvailable int         `json:"items_available"`
132         Offset         int         `json:"offset"`
133         Limit          int         `json:"limit"`
134 }
135
136 // ContainerRequestList is an arvados#containerRequestList resource.
137 type ContainerRequestList struct {
138         Items          []ContainerRequest `json:"items"`
139         ItemsAvailable int                `json:"items_available"`
140         Offset         int                `json:"offset"`
141         Limit          int                `json:"limit"`
142 }
143
144 // ContainerState is a string corresponding to a valid Container state.
145 type ContainerState string
146
147 const (
148         ContainerStateQueued    = ContainerState("Queued")
149         ContainerStateLocked    = ContainerState("Locked")
150         ContainerStateRunning   = ContainerState("Running")
151         ContainerStateComplete  = ContainerState("Complete")
152         ContainerStateCancelled = ContainerState("Cancelled")
153 )
154
155 // ContainerRequestState is a string corresponding to a valid Container Request state.
156 type ContainerRequestState string
157
158 const (
159         ContainerRequestStateUncomitted = ContainerRequestState("Uncommitted")
160         ContainerRequestStateCommitted  = ContainerRequestState("Committed")
161         ContainerRequestStateFinal      = ContainerRequestState("Final")
162 )