Project

General

Profile

Containers API » History » Version 8

Tom Clegg, 06/04/2015 05:58 PM

1 2 Tom Clegg
h1. Jobs API (DRAFT)
2 1 Tom Clegg
3 6 Tom Clegg
Clients control JobRequests. The system controls Jobs, and assigns them to JobRequests. When the system has assigned a Job to a JobRequest, anyone with permission to read the JobRequest also has permission to read the Job.
4
5
A JobRequest describes job _constraints_ which can have different interpretations over time. For example, a JobRequest with @{"git_revision":"abc123..master"}@ might be satisfiable by any of several different source trees, and this set of satisfying source trees changes whenever the repository's "master" branch is updated.
6
7
A Job is an unambiguously specified process. Git revisions, data collections, docker images, etc. are specified using content addresses. A Job serves as a statement of exactly _what computation will be attempted_ and, later, a record of _what computation was done_.
8
9
h2. JobRequest/Job life cycle
10
11
Illustrating job re-use and preview facility:
12
# Client CA creates a JobRequest JRA with priority=0.
13
# Server creates job JX and assigns JX to JRA, but does not try to run JX yet because max(priority)=0.
14
# Client CA presents JX to the user. "We haven't computed this result yet, so we'll have to run a new job. Is this OK?"
15
# Client CB creates a JobRequest JRB with priority=1.
16
# Server assigns JX to JRB and puts JX in the execution queue with priority=1.
17
# Client CA updates JRA with priority=2.
18
# Server updates JX with priority=2.
19
# Job JX starts.
20
# Client CA updates JRA with priority=0. (This is the "cancel" operation.)
21
# Server updates JX with priority=1. (JRB still wants this job to complete.)
22
# Job JX finishes.
23
# Clients CA and CB have permission to read JX (ever since JX was assigned to their respective JobRequests) as well as its progress indicators, output, and log.
24
25 1 Tom Clegg
h2. "JobRequest" schema
26 5 Tom Clegg
27 1 Tom Clegg
|Attribute|Type|Description|Discussion|Examples|
28 6 Tom Clegg
|uuid, owner_uuid, modified_by_client_uuid,  modified_by_user_uuid|string|Usual Arvados model attributes|||
29 1 Tom Clegg
|
30 6 Tom Clegg
|created_at, modified_at|datetime|Usual Arvados model attributes|||
31 1 Tom Clegg
|
32 6 Tom Clegg
|name|string|Unparsed|||
33 1 Tom Clegg
|
34 6 Tom Clegg
|description|text|Unparsed|||
35
|
36
|job_uuid|uuid|The job that satisfies this job request.|
37
Can be null if a suitable job has not yet been found or queued.
38
Assigned by the system: cannot be modified directly by clients.
39
If null, it can be changed by the system at any time.
40
If not null, it can be reset to null by a client _if priority is zero_.||
41
|
42 8 Tom Clegg
|mounts|hash|Objects to attach to the container's filesystem and stdin/stdout.
43
Keys starting with a forward slash indicate objects mounted in the container's filesystem.
44
Other keys are given special meanings here.|
45
We use "stdin" instead of "/dev/stdin" because literally replacing /dev/stdin with a file would have a confusing effect on many unix programs. The stdin feature only affects the standard input of the first process started in the container; after that, the usual rules apply.|
46
<pre>{
47
 "/input/foo":{
48
  "kind":"collection",
49
  "portable_data_hash":"d41d8cd98f00b204e9800998ecf8427e+0"
50
 },
51
 "stdin":{
52
  "kind":"file",
53
  "uuid":"zzzzz-4zz18-yyyyyyyyyyyyyyy",
54
  "path":"/foo.txt"
55
 },
56
 "stdout":{
57
  "kind":"output:object"
58
 }
59 1 Tom Clegg
}</pre>|
60
|
61
|runtime_permissions|hash|Restrict the job's access to the outside world (apart from its explicitly stated inputs and output).
62
Each key is the name of a capability, like "internet" or "API" or "clock". The corresponding value is @true@ (the capability must be available in the job's runtime environment) or @false@ (must not). If a key is omitted, availability of the corresponding capability is acceptable but not necessary.|This is a generalized version of "enforce purity restrictions": it is not a claim that the job will be pure. However, knowing which restrictions were in place can be helpful when reasoning about whether a given job was pure.
63
In the most basic implementation, no capabilities are defined, and the only acceptable value of this attribute is the empty hash.
64
(TC)This name isn't great, and conflicts with the "readable/writable" kind of permissions. Perhaps something along the lines of capabilities or interfaces?|
65
<pre>{}</pre>|
66
|
67
|docker_image|string|Docker image repository and tag, docker image hash, collection UUID, or collection PDH.|||
68
|
69 8 Tom Clegg
|environment|hash|environment variables and values that should be set in the container environment (docker run --env). This augments and (when conflicts exists) overrides environment variables given in the image's Dockerfile.|||
70 1 Tom Clegg
|
71 8 Tom Clegg
|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. The default is @"."@.||<pre>"/tmp"</pre>|
72 1 Tom Clegg
|
73 8 Tom Clegg
|command|array of strings|Command to execute in the container. Default is the CMD given in the image's Dockerfile.|
74 1 Tom Clegg
(TC)Possible to specify a pipe, like "echo foo &#124; tr f b"? Any shell variables supported? Or do you just use @["sh","-c","echo $PATH &#124; wc"]@ if you want a shell?||
75
|
76
|priority|number|Higher number means spend more resources (e.g., go ahead of other queued jobs, bring up more nodes).
77
Zero means a job should not be run. Clients are expected to submit JobRequests with zero priority in order to prevew the job that will be used to satisfy it.|(TC)Do we need something more subtle than a single number?
78
(TC)What if a high priority job is waiting for a low priority job to finish?|@0@, @1000.5@, @-1@|
79
80
81
h2. "Job" schema
82
83
|Attribute|Type|Description|Discussion|Examples|
84
|state, started_at, finished_at, log||Same as current job|||
85
|
86 8 Tom Clegg
|input, stdin, stdout, environment, initial_collection, cwd, command, runtime_debugging, git_checkout_dir, temp_dir, output_dir, keep_dir||Copied from the relevant JobRequest(s) and made available to the job process.|||
87 1 Tom Clegg
|
88
|output|hash|Arbitrary hash provided by the job process.|
89
(PA)Changing the basic output type from a collection to a JSON object is important for native CWL support.
90
(TC)Need examples of how "output is one collection", "output is multiple collections", "output is collections plus other stuff(?)", and "output is other stuff without collections" are to be encoded.||
91
|
92
|pure|boolean|The job's output is thought to be dependent solely on its inputs (i.e., it is expected to produce identical output if repeated)|
93
(TC)Is this merely an assertion by the submitter? Is the job itself expected to set or reset it? Does the system behave differently while running the job (e.g., different firewall rules, some APIs disabled)? [Under what conditions] is the system allowed to change it from true to false? Is null allowed, presumably signifying "not known"?|@null@ (?)
94
@true@
95
@false@|
96
|
97
|git_commit_sha1|string|Full 40-character commit hash used to run the job.|(TC)Should we store the tree hash as well? Or _instead_ of the commit hash, if we prevent the job from seeing the git metadata, which would be good for reproducibility (consider a job that starts by doing "git checkout master" in its working directory).
98
(TC)Do we need to store git_repository here too? Presumably, the relevant git tree should be in the internal git repository as a prerequisite of Job creation. And if two repositories have the same commit/tree, it shouldn't matter which we pull it from when running the job.||
99
|docker_image_pdh|string|Portable data hash of a collection containing the docker image used to run the job.|(TC) *If* docker image hashes can be verified efficiently, we can use the native docker image hash here instead of a collection PDH.||
100
|
101
|progress|number|A number between 0.0 and 1.0 describing the fraction of work done.|
102
(TC)How does this relate to child tasks? E.g., is a job supposed to update this itself as its child tasks complete?||
103
|
104
|priority|number|Highest priority of all associated JobRequests|||
105
106 8 Tom Clegg
h2. Mount types
107
108
The "mounts" hash is the primary mechanism for adding data to the container at runtime (beyond what is already in the container image).
109
110
Each value of the "mounts" hash is itself a hash, whose "kind" key determines the handler used to attach data to the container.
111
112
|Mount type|@kind@|Expected keys|Description|Examples|Discussion|
113
|
114
|Read-only collection|@collection@|
115
@"portable_data_hash"@ _or_ @"uuid"@ can be provided.|
116
At job startup, the target path will have the same directory structure as the given collection. Files in target path _may_ be read-only. Even if the files/directories are writable, modifications will _not_ be saved when the job ends.|
117
<pre>
118
{
119
 "kind":"collection",
120
 "uuid":"..."
121
}
122
</pre>|
123
|
124
|Read-only file|@file@|
125
Either @"portable_data_hash"@ or @"uuid"@ must be provided.
126
"path" must be provided, and must indicate a file in the given collection.|
127
Behavior is identical to "Read-only collection" except that the target is a single file.|
128
<pre>
129
{
130
 "kind":"file",
131
 "uuid":"..."
132
}
133
</pre>|
134
|
135
|Output collection (initially empty)|@output:collection@|
136
None|
137
At job startup, the target path will be empty. When the job ends, the content will be saved as the output of the job.|
138
<pre>
139
{
140
 "kind":"output:collection"
141
}
142
</pre>|
143
(TC)Needs a "pre-populate with collection X" feature.|
144
|
145
|Output collection (initially empty)|@output:file@|
146
@"name"@|
147
This is usable only for the @"stdout"@ mount. The standard output of the container process will be written to a file in a new collection, and the resulting file (recorded as "{collection}/{path}") will be taken as the output of the job.|
148
<pre>
149
{
150
 "kind":"output:file"
151
}
152
</pre>|
153
|
154
|Output object|@output:object@ (?)|
155
None|
156
This is usable only for the @"stdout"@ mount. The standard output of the container process will be parsed as JSON, and the resulting object will be taken as the output of the job.|
157
<pre>
158
{
159
 "kind":"output:object"
160
}
161
</pre>|
162
|
163
|Git tree|@git_tree@|
164
One of {@"git-url"@, @"repository_name"@, @"uuid"@} must be provided.
165
One of {@"tree"@, @"commit"@, @"revisions"@} must be provided.|
166
At job startup, the target path will have the source tree indicated by the given revision. The @.git@ metadata directory _will not_ be available: typically the system will use @git-archive@ rather than @git-checkout@ to prepare the target directory.
167
If a value is given for @"revisions"@, it will be resolved to a set of commits (as desribed in the "ranges" section of git-revisions(1)) and the job request will be satisfiable by any commit in that set.
168
If a value is given for @"commit"@, it will be resolved to a single commit, and the tree resulting from that commit will be used.
169
If a value is given for @"tree"@, the given tree will be used.
170
Note that multiple commit hashes can resolve to the same tree hash: e.g., identical patch with different committer/author/timestamp.|
171
<pre>
172
{
173
 "kind":"git_tree",
174
 "uuid":"zzzzz-s0uqq-xxxxxxxxxxxxxxx",
175
 "commit":"master"
176
}
177
178
{
179
 "kind":"git_tree",
180
 "uuid":"zzzzz-s0uqq-xxxxxxxxxxxxxxx",
181
 "commit_range":"bugfix^..master"
182
}
183
184
{
185
 "kind":"git_tree",
186
 "uuid":"zzzzz-s0uqq-xxxxxxxxxxxxxxx",
187
 "tree":"bugfix^..master"
188
}
189
</pre>|
190
(TC)Is the "tree" option here useful, or just unnecessary extra work? It seems to be the right way to test equivalence of two jobs, in any case.|
191
|
192
|
193
|Temporary directory|@tmp@|
194
None|
195
At job startup, the target path will be empty. When the job finishes, the content will be discarded. This will be backed by a memory-based filesystem where possible.|
196
<pre>
197
{
198
 "kind":"tmp",
199
}
200
</pre>|
201
(TC)Should add a "max size" feature, to help memfs-backed implementations.|
202
|
203
204
205 5 Tom Clegg
h2. Permissions
206
207
Users own JobRequests but the system owns Jobs.  Users get permission to read Jobs by virtue of linked JobRequests.
208
209 8 Tom Clegg
h2. API methods
210 5 Tom Clegg
211 8 Tom Clegg
Changes from the usual REST APIs:
212 4 Peter Amstutz
213 8 Tom Clegg
h3. arvados.v1.job_requests.create and .update
214 4 Peter Amstutz
215 8 Tom Clegg
These methods can fail when objects referenced in the "mounts" hash do not exist, or the acting user has insufficient permission on them.
216 5 Tom Clegg
217 8 Tom Clegg
h3. arvados.v1.job_requests.update
218 5 Tom Clegg
219 8 Tom Clegg
The @job_uuid@ attribute is special:
220
* It cannot be changed from null to non-null by a regular client.
221
* It cannot be changed from non-null to null by system processes.
222
* It _can_ be reset from non-null to null by the system _during a client-initiated update transaction that modifies attributes other than @state@ and @priority@._
223 2 Tom Clegg
224 8 Tom Clegg
Apart from @job_uuid@, updates are restricted by the current @state@ of the job request.
225
* When @state="Preview"@, all attributes can be updated.
226
* When @state="Request"@, only @priority@ and @state@ can be updated.
227
* When @state="Done"@, no attributes can be updated.
228 2 Tom Clegg
229 8 Tom Clegg
@state@ cannot be null. The following state transitions are the only ones permitted.
230
* Preview &rarr; Request
231
* Preview &rarr; Done
232
* Request &rarr; Done
233 2 Tom Clegg
234 8 Tom Clegg
h3. arvados.v1.jobs.create and .update
235 2 Tom Clegg
236 8 Tom Clegg
These methods are not callable except by system processes.
237
238
h3. arvados.v1.jobs.progress
239
240
This method permits specific types of updates while a job is running: update progress, record success/failure.
241
242
Q: [How] can a client submitting job B indicate it shouldn't run unless/until job A succeeds?
243
244
h2. Debugging
245
246
Q: Need any infrastructure debug-logging controls in this API?
247
248
Q: Need any job debug-logging controls in this API? Or just use environment vars?
249 1 Tom Clegg
250
h2. Scheduling and running jobs
251
252
Q: If two users submit identical pure jobs and ask to reuse existing jobs, whose token does the job get to use?
253
* Should pure jobs be run as a pseudo-user that is given read access to the relevant objects for the duration of the job? (This would make it safer to share jobs -- see #5823)
254
255
Q: If two users submit identical pure jobs with different priority, which priority is used?
256
* Choices include "whichever is greater" and "sum".
257
258
Q: If two users submit identical pure jobs and one cancels -- or one user submits two identical jobs and cancels one -- does the work stop, or continue? What do the job records look like after this?