Merge branch '21766-disk-cache-size'
[arvados.git] / doc / api / methods / container_requests.html.textile.liquid
1 ---
2 layout: default
3 navsection: api
4 navmenu: API Methods
5 title: "container_requests"
6
7 ...
8 {% comment %}
9 Copyright (C) The Arvados Authors. All rights reserved.
10
11 SPDX-License-Identifier: CC-BY-SA-3.0
12 {% endcomment %}
13
14 API endpoint base: @https://{{ site.arvados_api_host }}/arvados/v1/container_requests@
15
16 Object type: @xvhdp@
17
18 Example UUID: @zzzzz-xvhdp-0123456789abcde@
19
20 h2. Resource
21
22 A container request is a request for the Arvados cluster to perform some computational work.  See "computing with Crunch":{{site.baseurl}}/api/execution.html for details.
23
24 Each ContainerRequest offers the following attributes, in addition to the "Common resource fields":{{site.baseurl}}/api/resources.html:
25
26 All attributes are optional, unless otherwise marked as required.
27
28 table(table table-bordered table-condensed).
29 |_. Attribute|_. Type|_. Description|_. Notes|
30 |name|string|The name of the container_request.||
31 |description|string|The description of the container_request.||
32 |properties|hash|User-defined metadata that does not affect how the container is run.  May be used in queries using "subproperty filters":{{site.baseurl}}/api/methods.html#subpropertyfilters||
33 |state|string|The allowed states are "Uncommitted", "Committed", and "Final".|Once a request is Committed, the only attributes that can be modified are priority, container_uuid, and container_count_max. A request in the "Final" state cannot have any of its functional parts modified (i.e., only name, description, and properties fields can be modified).|
34 |requesting_container_uuid|string|The uuid of the parent container that created this container_request, if any. Represents a process tree.|The priority of this container_request is inherited from the parent container, if the parent container is cancelled, this container_request will be cancelled as well.|
35 |container_uuid|string|The uuid of the container that satisfies this container_request. The system may return a preexisting Container that matches the container request criteria. See "Container reuse":#container_reuse for more details.|Container reuse is the default behavior, but may be disabled with @use_existing: false@ to always create a new container.|
36 |container_count_max|integer|Maximum number of containers to start, i.e., the maximum number of "attempts" to be made.||
37 |mounts|hash|Objects to attach to the container's filesystem and stdin/stdout.|See "Mount types":#mount_types for more details.|
38 |secret_mounts|hash|Objects to attach to the container's filesystem.  Only "json" or "text" mount types allowed.|Not returned in API responses. Reset to empty when state is "Complete" or "Cancelled".|
39 |runtime_constraints|hash|Restrict the container's access to compute resources and the outside world.|Required when in "Committed" state. e.g.,<pre><code>{
40   "ram":12000000000,
41   "vcpus":2,
42   "API":true
43 }</code></pre>See "Runtime constraints":#runtime_constraints for more details.|
44 |scheduling_parameters|hash|Parameters to be passed to the container scheduler when running this container.|e.g.,<pre><code>{
45 "partitions":["fastcpu","vfastcpu"]
46 }</code></pre>See "Scheduling parameters":#scheduling_parameters for more details.|
47 |container_image|string|Portable data hash of a collection containing the docker image to run the container.|Required.|
48 |environment|hash|Environment variables and values that should be set in the container environment (@docker run --env@). This augments and (when conflicts exist) overrides environment variables given in the image's Dockerfile.||
49 |cwd|string|Initial working directory, given as an absolute path (in the container) or a path relative to the WORKDIR given in the image's Dockerfile.|Required.|
50 |command|array of strings|Command to execute in the container.|Required. e.g., @["echo","hello"]@|
51 |output_path|string|Path to a directory or file inside the container that should be preserved as container's output when it finishes. This path must be one of the mount targets. For best performance, point output_path to a writable collection mount.  See "Pre-populate output using Mount points":#pre-populate-output for details regarding optional output pre-population using mount points and "Symlinks in output":#symlinks-in-output for additional details.|Required.|
52 |output_glob|array of strings|Glob patterns determining which files (of those present in the output directory when the container finishes) will be included in the output collection. If multiple patterns are given, files that match any pattern are included. If null or empty, all files will be included.|e.g., @["**/*.vcf", "**/*.vcf.gz"]@
53 See "Glob patterns":#glob_patterns for more details.|
54 |output_name|string|Desired name for the output collection. If null or empty, a name will be assigned automatically.||
55 |output_ttl|integer|Desired lifetime for the output collection, in seconds. If zero, the output collection will not be deleted automatically.||
56 |priority|integer|Range 0-1000.  Indicate scheduling order preference.|Clients are expected to submit container requests with zero priority in order to preview the container that will be used to satisfy it. Priority can be null if and only if state!="Committed".  See "below for more details":#priority .|
57 |expires_at|datetime|After this time, priority is considered to be zero.|Not yet implemented.|
58 |use_existing|boolean|If possible, use an existing (non-failed) container to satisfy the request instead of creating a new one.|Default is true|
59 |log_uuid|string|Log collection containing log messages provided by the scheduler and crunch processes.|Null if the container has not yet started running.
60 To retrieve logs in real time while the container is running, use the log API (see below).|
61 |output_uuid|string|Output collection created when the container finished successfully.|Null if the container has failed or not yet completed.|
62 |filters|string|Additional constraints for satisfying the container_request, given in the same form as the filters parameter accepted by the container_requests.list API.|
63 |runtime_token|string|A v2 token to be passed into the container itself, used to access Keep-backed mounts, etc.  |Not returned in API responses.  Reset to null when state is "Complete" or "Cancelled".|
64 |runtime_user_uuid|string|The user permission that will be granted to this container.||
65 |runtime_auth_scopes|array of string|The scopes associated with the auth token used to run this container.||
66 |output_storage_classes|array of strings|The storage classes that will be used for the log and output collections of this container request|default is ["default"]|
67 |output_properties|hash|User metadata properties to set on the output collection.  The output collection will also have default properties "type" ("intermediate" or "output") and "container_request" (the uuid of container request that produced the collection).|
68 |cumulative_cost|number|Estimated cost of the cloud VMs used to satisfy the request, including retried attempts and completed subrequests, but not including reused containers.|0 if container was reused or VM price information was not available.|
69
70 h2(#lifecycle). Container request lifecycle
71
72 A container request may be created in the Committed state, or created in the Uncommitted state and then moved into the Committed state.
73
74 Once a request is in the Committed state, Arvados locates a suitable existing container or schedules a new one. When the assigned container finishes, the request state changes to Final.
75
76 A client may cancel a committed request early (before the assigned container finishes) by setting the request priority to zero.
77
78 !{max-width:60em;}{{site.baseurl}}/api/methods/container_request_lifecycle.svg!
79 {% comment %}
80 # svg generated using `graphviz -Tsvg -O`
81 digraph {
82     graph [nojustify=true] [labeljust=l]
83
84     invisiblestart [label = ""] [color=white] [group=lifecycle];
85     node [color=black] [fillcolor=white] [style=filled] [shape=box] [nojustify=true];
86     uncommitted [label = "container request:\l   state=Uncommitted\l"] [fillcolor=lightgrey] [group=lifecycle];
87     {
88         rank=same;
89         committed [label = "container request:\l   state=Committed\l   priority>0\l"] [group=lifecycle];
90         reused [label = "container request:\l   state=Final\lcontainer:\l   state=Complete\l(reused existing container)\l"] [fillcolor=lightblue] [group=endstate];
91     }
92     invisiblestart -> uncommitted [label = "   user creates container request\l"] [color=navy] [fontcolor=navy];
93     uncommitted -> committed [label = "   user updates to\l      state=Committed, priority>0\l"] [color=navy] [fontcolor=navy];
94     queued [label = "container request:\l   state=Committed\l   priority>0\lcontainer:\l   state=Queued\l"] [group=lifecycle];
95     committed -> queued [label = "   Arvados creates a new container\l"];
96     {
97         rank=same;
98         locked [label = "container request:\l   state=Committed\l   priority>0\lcontainer:\l   state=Locked\l"] [group=lifecycle];
99         latecancelled [label = "container request:\l   state=Final\lcontainer:\l   state=Cancelled\l"] [fillcolor=lightblue] [group=endstate];
100     }
101     queued -> locked [label = "   Arvados is ready to dispatch the container\l"];
102     {
103         rank=same;
104         running [label = "container request:\l   state=Committed\l   priority>0\lcontainer:\l   state=Running\l"] [group=lifecycle];
105         containerfailed [label = "container request:\l   state=Final\lcontainer:\l   state=Complete\l   exit_codeā‰ 0\l"] [fillcolor=lightblue] [group=endstate];
106     }
107     locked -> running [label = "   Arvados starts the container process\l"];
108     containerfinished [label = "container request:\l   state=Final\lcontainer:\l   state=Complete\l   exit_code=0\l"] [fillcolor=lightblue] [group=lifecycle];
109
110     committed -> reused [label = "Arvados selects an existing container"] [constraint=false] [labeldistance=0.5];
111     queued -> latecancelled [label = "user updates to priority=0"] [color=navy] [fontcolor=navy];
112     locked -> latecancelled [label = "user updates to priority=0"] [color=navy] [fontcolor=navy] [constraint=false];
113     running -> latecancelled [label = "user updates to priority=0"] [color=navy] [fontcolor=navy] [constraint=false];
114     running -> containerfailed [label = "container process fails"];
115     running -> containerfinished [label = "   container process succeeds\l"];
116
117     # layout hacks
118     reused -> latecancelled [style=invis];
119     latecancelled -> containerfailed [style=invis];
120 }
121 {% endcomment %}
122
123 h2(#priority). Priority
124
125 The @priority@ field has a range of 0-1000.
126
127 Priority 0 means no container should run on behalf of this request, and containers already running will be terminated (setting container priority to 0 is the cancel operation.)
128
129 Priority 1 is the lowest priority.
130
131 Priority 1000 is the highest priority.
132
133 The actual order that containers execute is determined by the underlying scheduling software (e.g. Slurm) and may be based on a combination of container priority, submission time, available resources, and other factors.
134
135 In the current implementation, the magnitude of difference in priority between two containers affects the weight of priority vs age in determining scheduling order.  If two containers have only a small difference in priority (for example, 500 and 501) and the lower priority container has a longer queue time, the lower priority container may be scheduled before the higher priority container.  Use a greater magnitude difference (for example, 500 and 600) to give higher weight to priority over queue time.
136
137 h2(#mount_types). {% include 'mount_types' %}
138
139 h2(#runtime_constraints). {% include 'container_runtime_constraints' %}
140
141 h2(#scheduling_parameters). {% include 'container_scheduling_parameters' %}
142
143 h2(#glob_patterns). {% include 'container_glob_patterns' %}
144
145 h2(#container_reuse). Container reuse
146
147 When a container request is "Committed", the system will try to find and reuse an existing Container with the same command, cwd, environment, output_path, container_image, mounts, secret_mounts, runtime_constraints, runtime_user_uuid, and runtime_auth_scopes being requested.
148
149 * The serialized fields environment, mounts, and runtime_constraints are normalized when searching.
150 * The system will also search for containers with minor variations in the keep_cache_disk and keep_cache_ram runtime_constraints that should not affect the result. This searches for other common values for those constraints, so a container that used a non-default value for these constraints may not be reused by later container requests that use a different value.
151
152 In order of preference, the system will use:
153
154 * The first matching container to have finished successfully (i.e., reached state "Complete" with an exit_code of 0) whose log and output collections are still available.
155 * The oldest matching "Running" container with the highest progress, i.e., the container that is most likely to finish first.
156 * The oldest matching "Locked" container with the highest priority, i.e., the container that is most likely to start first.
157 * The oldest matching "Queued" container with the highest priority, i.e,, the container that is most likely to start first.
158 * A new container.
159
160 h2(#cancel_container). Canceling a container request
161
162 A container request may be canceled by setting its priority to 0, using an update call.
163
164 When a container request is canceled, it will still reflect the state of the Container it is associated with via the container_uuid attribute. If that Container is being reused by any other container_requests that are still active, i.e., not yet canceled, that Container may continue to run or be scheduled to run by the system in future. However, if no other container_requests are using that Container, then the Container will get canceled as well.
165
166 h2. Methods
167
168 See "Common resource methods":{{site.baseurl}}/api/methods.html for more information about @create@, @delete@, @get@, @list@, and @update@.
169
170 Required arguments are displayed in %{background:#ccffcc}green%.
171
172 Supports federated @create@, @delete@, @get@, @list@, and @update@.
173
174 h2(#create). create
175
176 Create a new container request.
177
178 Arguments:
179
180 table(table table-bordered table-condensed).
181 |_. Argument |_. Type |_. Description |_. Location |_. Example |
182 {background:#ccffcc}.|container_request|object|Container request resource.|request body||
183 |cluster_id|string|The federated cluster to submit the container request.|query||
184
185 The request body must include the required attributes command, container_image, cwd, and output_path. It can also inlcude other attributes such as environment, mounts, and runtime_constraints.
186
187 h3. delete
188
189 Delete an existing container request.
190
191 Arguments:
192
193 table(table table-bordered table-condensed).
194 |_. Argument |_. Type |_. Description |_. Location |_. Example |
195 {background:#ccffcc}.|uuid|string|The UUID of the container request in question.|path||
196
197 h3. get
198
199 Get a container request's metadata by UUID.
200
201 Arguments:
202
203 table(table table-bordered table-condensed).
204 |_. Argument |_. Type |_. Description |_. Location |_. Example |
205 {background:#ccffcc}.|uuid|string|The UUID of the container request in question.|path||
206
207 h3. list
208
209 List container requests.
210
211 See "common resource list method.":{{site.baseurl}}/api/methods.html#index
212
213 The @filters@ argument can also filter on attributes of the container referenced by @container_uuid@. For example, @[["container.state", "=", "Running"]]@ will match any container request whose container is running now.
214
215 h3. update
216
217 Update attributes of an existing container request.
218
219 Arguments:
220
221 table(table table-bordered table-condensed).
222 |_. Argument |_. Type |_. Description |_. Location |_. Example |
223 {background:#ccffcc}.|uuid|string|The UUID of the container request in question.|path||
224 |container_request|object||query||
225
226 {% include 'notebox_begin' %}
227 Setting the priority of a committed container_request to 0 may cancel a running container assigned for it.
228 See "Canceling a container request":{{site.baseurl}}/api/methods/container_requests.html#cancel_container for further details.
229 {% include 'notebox_end' %}
230
231 h3(#container_status). container_status
232
233 Get container status.
234
235 table(table table-bordered table-condensed).
236 |_. Argument |_. Type |_. Description |_. Location |
237 {background:#ccffcc}.|uuid|string|The UUID of the container request in question.|path|
238
239 Example request: @GET /arvados/v1/container_requests/zzzzz-xvdhp-0123456789abcde/container_status@
240
241 Response attributes:
242
243 table(table table-bordered table-condensed).
244 |_. Attribute|_. Type|_. Description|_. Examples|
245 |uuid|string|The UUID of the container assigned to this request.||
246 |state|string|The state of the container assigned to this request (see "container resource attributes":containers.html).||
247 |scheduling_status|string|A brief explanation of the container's status in the dispatch queue, or an empty string if scheduling is not applicable, e.g., the container is running or finished.|@waiting for cloud resources: queue position 3@
248 @creating new instance@
249 @preparing runtime environment@|
250
251 h3(#log). log
252
253 Get container log data using WebDAV methods.
254
255 This API retrieves data from the container request's log collection. It can be used at any time in the container request lifecycle.
256 * Before a container has been assigned (the request is @Uncommitted@) it returns an empty directory.
257 * While the container is @Queued@ or @Locked@, it returns an empty directory.
258 * While the container is @Running@, @.../log/{container_uuid}/@ returns real-time logging data.
259 * While the container is @Complete@ or @Cancelled@, @.../log/{container_uuid}/@ returns the final log collection.
260
261 If a request results in multiple containers being run (see @container_count_max@ above), the logs from prior attempts remain available at @.../log/{old_container_uuid}/@.
262
263 Currently, this API has a limitation that a directory listing at the top level @/arvados/v1/container_requests/{uuid}/log/@ does not reveal the per-container subdirectories. Instead, clients should look up the container request record and use the @container_uuid@ attribute to request files and directory listings under the per-container directory, as in the examples below.
264
265 This API supports the @Range@ request header, so it can be used to poll for and retrieve logs incrementally while the container is running.
266
267 Arguments:
268
269 table(table table-bordered table-condensed).
270 |_. Argument |_. Type |_. Description |_. Location |_. Example |
271 {background:#ccffcc}.|method|string|Read-only WebDAV method|HTTP method|@GET@, @OPTIONS@, @PROPFIND@|
272 {background:#ccffcc}.|uuid|string|The UUID of the container request.|path|zzzzz-xvdhp-0123456789abcde|
273 {background:#ccffcc}.|path|string|Path to a file in the log collection.|path|@/zzzzz-dz642-0123456789abcde/stderr.txt@|
274
275 Examples:
276 * @GET /arvados/v1/container_requests/zzzzz-xvdhp-0123456789abcde/log/zzzzz-dz642-0123456789abcde/stderr.txt@
277 * @PROPFIND /arvados/v1/container_requests/zzzzz-xvdhp-0123456789abcde/log/zzzzz-dz642-0123456789abcde/@