15823: Add "cloud dispatcher" API doc page.
[arvados.git] / doc / api / dispatch.html.textile.liquid
1 ---
2 layout: default
3 navsection: api
4 navmenu: API Methods
5 title: "cloud dispatcher"
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 The cloud dispatcher provides several management/diagnostic APIs, intended to be used by a system administrator.
15
16 These APIs are not normally exposed to external clients. To use them, connect directly to the dispatcher's internal URL (see Services.DispatchCloud.InternalURLs in the cluster config file). All requests must include the cluster's management token (@ManagementToken@ in the cluster config file).
17
18 Example:
19
20 <notextile><pre><code>curl -H "Authorization: Bearer $management_token" http://localhost:9006/arvados/v1/dispatch/containers</code></pre></notextile>
21
22 These APIs are not available via @arv@ CLI tool.
23
24 h3. List containers
25
26 @GET /arvados/v1/dispatch/containers@
27
28 Return a list of containers that are either ready to dispatch, or being started/monitored by the dispatcher.
29
30 The response provides @uuid@, @priority@, and @state@ fields for each container. Other fields of the container records are not loaded by the dispatcher, and will have empty/zero values here (e.g., @{...,"created_at":"0001-01-01T00:00:00Z","command":[],...}@).
31
32 Example response:
33
34 <notextile><pre>{
35   "items": [
36     {
37       "container": {
38         "uuid": "zzzzz-dz642-xz68ptr62m49au7",
39         ...
40         "priority": 562948375092493200,
41         ...
42         "state": "Locked",
43         ...
44       },
45       "instance_type": {
46         "Name": "Standard_E2s_v3",
47         "ProviderType": "Standard_E2s_v3",
48         "VCPUs": 2,
49         "RAM": 17179869184,
50         "Scratch": 32000000000,
51         "IncludedScratch": 32000000000,
52         "AddedScratch": 0,
53         "Price": 0.146,
54         "Preemptible": false
55       }
56     },
57     ...
58   ]
59 }</pre></notextile>
60
61 h3. Terminate a container
62
63 @POST /arvados/v1/dispatch/containers/kill?container_uuid={uuid}&reason={string}@
64
65 Make a single attempt to terminate the indicated container on the relevant cloud VM. (The caller can implement a delay-and-retry loop if needed.)
66
67 A container terminated this way will end with state @Cancelled@ if its docker container had already started, or @Queued@ if it was terminated while setting up the runtime environment.
68
69 The provided @reason@ string will appear in the dispatcher's log, but not in the user-visible container log.
70
71 If the provided @container_uuid@ is not scheduled/running on a worker node, the response status will be 404.
72
73 h3. List instances
74
75 @GET /arvados/v1/dispatch/instances@
76
77 Return a list of cloud instances.
78
79 Example response:
80
81 <notextile><pre>{
82   "items": [
83     {
84       "instance": "/subscriptions/abcdefab-abcd-abcd-abcd-abcdefabcdef/resourceGroups/zzzzz/providers/Microsoft.Compute/virtualMachines/compute-abcdef0123456789abcdef0123456789-abcdefghijklmno",
85       "address": "10.23.45.67",
86       "price": 0.073,
87       "arvados_instance_type": "Standard_DS1_v2",
88       "provider_instance_type": "Standard_DS1_v2",
89       "last_container_uuid": "zzzzz-dz642-vp7scm21telkadq",
90       "last_busy": "2020-01-13T15:20:21.775019617Z",
91       "worker_state": "running",
92       "idle_behavior": "run"
93     },
94     ...
95 }</pre></notextile>
96
97 The @instance@ value is the instance's identifier, assigned by the cloud provider. It can be used with the instance APIs below.
98
99 The @worker_state@ value indicates the instance's capability to run containers.
100 * @unknown@: instance was not created by this dispatcher, and a boot probe has not yet succeeded (this state typically appears briefly after the dispatcher restarts).
101 * @booting@: cloud provider says the instance exists, but a boot probe has not yet succeeded.
102 * @idle@: instance is idle and ready to run a container.
103 * @running@: instance is running a container.
104 * @shutdown@: cloud provider has been instructed to terminate the instance.
105
106 The @idle_behavior@ value determines what the dispatcher will do with the instance when it is idle; see hold/drain/run APIs below.
107
108 h3. Hold an instance
109
110 @POST /arvados/v1/dispatch/instances/hold?instance_id={instance}@
111
112 Set the indicated instance's idle behavior to @hold@. The instance will not be shut down automatically. If a container is currently running, it will be allowed to continue, but no new containers will be scheduled.
113
114 h3. Drain an instance
115
116 @POST /arvados/v1/dispatch/instances/drain?instance_id={instance}@
117
118 Set the indicated instance's idle behavior to @drain@. If a container is currently running, it will be allowed to continue, but when the instance becomes idle, it will be shut down.
119
120 h3. Resume an instance
121
122 @POST /arvados/v1/dispatch/instances/run?instance_id={instance}@
123
124 Set the indicated instance's idle behavior to @run@ (the normal behavior). When it becomes idle, it will be eligible to run new containers. It will be shut down automatically when the configured idle threshold is reached.
125
126 h3. Shut down an instance
127
128 @POST /arvados/v1/dispatch/instances/kill?instance_id={instance}&reason={string}@
129
130 Terminate the indicated instance.
131
132 If a container is running on the instance, it will be killed too; no effort is made to wait for it to end gracefully.
133
134 The provided @reason@ string will appear in the dispatcher's log.