-
Notifications
You must be signed in to change notification settings - Fork 251
/
usage.go
324 lines (304 loc) · 23.6 KB
/
usage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
package main
import "fmt"
type ExitCode int
// These constants represent all possible exit codes from the generic-worker process.
const (
TASKS_COMPLETE ExitCode = 0
CANT_LOAD_CONFIG ExitCode = 64
CANT_INSTALL_GENERIC_WORKER ExitCode = 65
REBOOT_REQUIRED ExitCode = 67
IDLE_TIMEOUT ExitCode = 68
INTERNAL_ERROR ExitCode = 69
NONCURRENT_DEPLOYMENT_ID ExitCode = 70
WORKER_STOPPED ExitCode = 71
WORKER_SHUTDOWN ExitCode = 72
INVALID_CONFIG ExitCode = 73
CANT_CREATE_ED25519_KEYPAIR ExitCode = 75
CANT_COPY_TO_TEMP_FILE ExitCode = 76
CANT_CONNECT_PROTOCOL_PIPE ExitCode = 78
CANT_CREATE_FILE ExitCode = 79
CANT_CREATE_DIRECTORY ExitCode = 80
CANT_UNARCHIVE ExitCode = 81
)
func usage(versionName string) string {
return versionName + `
generic-worker is a taskcluster worker that can run on any platform that supports go (golang).
See http://taskcluster.github.io/generic-worker/ for more details. Essentially, the worker is
the taskcluster component that executes tasks. It requests tasks from the taskcluster queue,
and reports back results to the queue.
Usage:
generic-worker run [--config CONFIG-FILE]
[--with-worker-runner]
[--worker-runner-protocol-pipe PIPE]` + installServiceSummary() + `
generic-worker show-payload-schema
generic-worker new-ed25519-keypair --file ED25519-PRIVATE-KEY-FILE` + customTargetsSummary() + `
generic-worker copy-to-temp-file --copy-file COPY-FILE
generic-worker create-file --create-file CREATE-FILE
generic-worker create-dir --create-dir CREATE-DIR
generic-worker unarchive --archive-src ARCHIVE-SRC --archive-dst ARCHIVE-DST --archive-fmt ARCHIVE-FMT
generic-worker --help
generic-worker --version
Targets:
run Runs the generic-worker. Pass --with-worker-runner if
running under that service, otherwise generic-worker will
not communicate with worker-runner.
show-payload-schema Each taskcluster task defines a payload to be
interpreted by the worker that executes it. This
payload is validated against a json schema baked
into the release. This option outputs the json
schema used in this version of the generic
worker.` + installService() + `
new-ed25519-keypair This will generate a fresh, new ed25519
compliant private/public key pair. The public
key will be written to stdout and the private
key will be written to the specified file.` + customTargets() + `
copy-to-temp-file This will copy the specified file to a temporary
location and will return the temporary file path
to stdout. Intended for internal use.
create-file This will create a file at the specified path.
Intended for internal use.
create-dir This will create a directory (including missing
parent directories) at the specified path.
Intended for internal use.
unarchive This will unarchive the specified archive file
to the specified destination directory.
Intended for internal use.
Options:
--config CONFIG-FILE Json configuration file to use. See
configuration section below to see what this
file should contain. When calling the install
target, this is the config file that the
installation should use, rather than the config
to use during install.
[default: generic-worker.config]
--worker-runner-protocol-pipe PIPE Use this option when running generic-worker under
worker-runner, passing the same value as given for
'worker.protocolPipe' in the runner configuration.
This specifies a named pipe that is used for
communication between the two processes.` + platformCommandLineParameters() + `
--file PRIVATE-KEY-FILE The path to the file to write the private key
to. The parent directory must already exist.
If the file exists it will be overwritten,
otherwise it will be created.` + sidSID() + `
--copy-file COPY-FILE The path to the file to copy.
--create-file CREATE-FILE The path to the file to create.
--create-dir CREATE-DIR The path to the directory to create.
--archive-src ARCHIVE-SRC The path to the archive file to unarchive.
--archive-dst ARCHIVE-DST The path to the directory to unarchive to.
--archive-fmt ARCHIVE-FMT The format of the archive file to unarchive.
--help Display this help text.
--version The release version of the generic-worker.
Configuring the generic worker:
The configuration file for the generic worker is specified with -c|--config CONFIG-FILE
as described above. Its format is a json dictionary of name/value pairs.
** REQUIRED ** properties
=========================
accessToken Taskcluster access token used by generic worker
to talk to taskcluster queue.
clientId Taskcluster client ID used by generic worker to
talk to taskcluster queue.
ed25519SigningKeyLocation The ed25519 signing key for signing artifacts with.
rootURL The root URL of the taskcluster deployment to which
clientId and accessToken grant access. For example,
'https://community-tc.services.mozilla.com/'.
workerId A name to uniquely identify your worker.
workerType This should match a worker_type managed by the
provisioner you have specified.
** OPTIONAL ** properties
=========================
availabilityZone The EC2 availability zone of the worker.
cachesDir The directory where task caches should be stored on
the worker. The directory will be created if it does
not exist. This may be a relative path to the
current directory, or an absolute path.
[default: "caches"]
certificate Taskcluster certificate, when using temporary
credentials only.
checkForNewDeploymentEverySecs The number of seconds between consecutive calls
to the provisioner, to check if there has been a
new deployment of the current worker type. If a
new deployment is discovered, worker will shut
down. See deploymentId property. [default: 1800]
cleanUpTaskDirs Whether to delete the home directories of the task
users after the task completes. Normally you would
want to do this to avoid filling up disk space,
but for one-off troubleshooting, it can be useful
to (temporarily) leave home directories in place.
Accepted values: true or false. [default: true]
createObjectArtifacts If true, use artifact type 'object' for artifacts
containing data. If false, use artifact type 's3'.
The 'object' type will become the default when the
's3' type is deprecated.
deploymentId If running with --configure-for-aws, then between
tasks, at a chosen maximum frequency (see
checkForNewDeploymentEverySecs property), the
worker will query the provisioner to get the
updated worker type definition. If the deploymentId
in the config of the worker type definition is
different to the worker's current deploymentId, the
worker will shut itself down. See
https://bugzil.la/1298010
disableReboots If true, no system reboot will be initiated by
generic-worker program, but it will still return
with exit code 67 if the system needs rebooting.
This allows custom logic to be executed before
rebooting, by patching run-generic-worker.bat
script to check for exit code 67, perform steps
(such as formatting a hard drive) and then
rebooting in the run-generic-worker.bat script.
[default: false]
downloadsDir The directory to cache downloaded files for
populating preloaded caches and readonly mounts. The
directory will be created if it does not exist. This
may be a relative path to the current directory, or
an absolute path. [default: "downloads"]
enableInteractive Enables interactive mode. This allows an
interactive shell session to run on the worker.
[default: false]
idleTimeoutSecs How many seconds to wait without getting a new
task to perform, before the worker process exits.
An integer, >= 0. A value of 0 means "never reach
the idle state" - i.e. continue running
indefinitely. See also shutdownMachineOnIdle.
[default: 0]
instanceID The EC2 instance ID of the worker. Used by chain of trust.
instanceType The EC2 instance Type of the worker. Used by chain of trust.
interactivePort Set the port number for an interactive shell. This
is used to allow interactive access to the worker
while it is running.
[default: 53654]
livelogExecutable Filepath of LiveLog executable to use; see
https://github.com/taskcluster/livelog
[default: "livelog"]
livelogPortBase Set the base port number for livelog. Livelog requires two
ports: livelogPortBase & livelogPortBase + 1 are used.
[default: 60098]
livelogExposePort When not using websocktunnel, livelog would be exposed using this port.
If it is set to 0, logs would be exposed using a random port.
[default: 0]
loopbackAudioDeviceNumber The audio loopback device number. The resulting devices inside /dev/snd
will take the form controlC<DEVICE_NUMBER>, pcmC<DEVICE_NUMBER>D0c,
pcmC<DEVICE_NUMBER>D0p, pcmC<DEVICE_NUMBER>D1c, pcmC<DEVICE_NUMBER>D1p
where <DEVICE_NUMBER> is an integer between 0 and 31.
[default: 16]
loopbackVideoDeviceNumber The video loopback device number. Its value will take the form
/dev/video<DEVICE_NUMBER> where <DEVICE_NUMBER> is an integer
between 0 and 255. This setting may be used to change it.
[default: 0]
maxTaskRunTime The maximum value allowed for maxRunTime on generic-worker payloads.
[default: 86400]
numberOfTasksToRun If zero, run tasks indefinitely. Otherwise, after
this many tasks, exit. [default: 0]
privateIP The private IP of the worker, used by chain of trust.
provisionerId The taskcluster provisioner which is taking care
of provisioning environments with generic-worker
running on them. [default: "test-provisioner"]
publicIP The IP address for VNC access. Also used by chain of
trust when present.
region The EC2 region of the worker. Used by chain of trust.
requiredDiskSpaceMegabytes The garbage collector will ensure at least this
number of megabytes of disk space are available
when each task starts. If it cannot free enough
disk space, the worker will shut itself down.
[default: 10240]
runAfterUserCreation A string, that if non-empty, will be treated as a
command to be executed as the newly generated task
user, after the user has been created, the machine
has rebooted and the user has logged in, but before
a task is run as that user. This is a way to
provide generic user initialisation logic that
should apply to all generated users (and thus all
tasks) and be run as the task user itself. This
option does *not* support running a command as
Administrator. Furthermore, even if
runTasksAsCurrentUser is true, the script will still
be executed as the task user, rather than the
current user (that runs the generic-worker process).` + runTasksAsCurrentUserUsage() + `
sentryProject The project name used in https://sentry.io for
reporting worker crashes. Permission to publish
crash reports is granted via the scope
auth:sentry:<sentryProject>. If the taskcluster
client (see clientId property above) does not
posses this scope, no crash reports will be sent.
Similarly, if this property is not specified or
is the empty string, no reports will be sent.
[default: "generic-worker"]
shutdownMachineOnIdle If true, when the worker is deemed to have been
idle for enough time (see idleTimeoutSecs) the
worker will issue an OS shutdown command. If false,
the worker process will simply terminate, but the
machine will not be shut down. [default: false]
shutdownMachineOnInternalError If true, if the worker encounters an unrecoverable
error (such as not being able to write to a
required file) it will shutdown the host
computer. Note this is generally only desired
for machines running in production, such as on AWS
EC2 spot instances. Use with caution!
[default: false]
taskclusterProxyExecutable Filepath of taskcluster-proxy executable to use; see
https://github.com/taskcluster/taskcluster/tree/main/tools/taskcluster-proxy
[default: "taskcluster-proxy"]
taskclusterProxyPort Port number for taskcluster-proxy HTTP requests.
[default: 80]
tasksDir The location where task directories should be
created on the worker.
[default (varies by platform): ` + fmt.Sprintf("%q", defaultTasksDir()) + `]
workerGroup Typically this would be an aws region - an
identifier to uniquely identify which pool of
workers this worker logically belongs to.
[default: "test-worker-group"]
workerLocation If a non-empty string, task commands will have environment variable
TASKCLUSTER_WORKER_LOCATION set to the value provided.
Otherwise TASKCLUSTER_WORKER_LOCATION environment
variable will not be implicitly set in task commands.
[default: ""]
workerTypeMetaData This arbitrary json blob will be included at the
top of each task log. Providing information here,
such as a URL to the code/config used to set up the
worker type will mean that people running tasks on
the worker type will have more information about how
it was set up (for example what has been installed on
the machine).
wstAudience The audience value for which to request websocktunnel
credentials, identifying a set of WST servers this
worker could connect to. Optional if not using websocktunnel
to expose live logs.
wstServerURL The URL of the websocktunnel server with which to expose
live logs. Optional if not using websocktunnel to expose
live logs.
If an optional config setting is not provided in the json configuration file, the
default will be taken (defaults documented above).
If no value can be determined for a required config setting, the generic-worker will
exit with a failure message.
Exit Codes:
0 Tasks completed successfully; no more tasks to run (see config setting
numberOfTasksToRun).
64 Not able to load generic-worker config. This could be a problem reading the
generic-worker config file on the filesystem, a problem talking to AWS/GCP
metadata service, or a problem retrieving config/files from the taskcluster
secrets service.` + exitCode65() + `
67 A task user has been created, and the generic-worker needs to reboot in order
to log on as the new task user. Note, the reboot happens automatically unless
config setting disableReboots is set to true - in either code this exit code will
be issued.
68 The generic-worker hit its idle timeout limit (see config settings idleTimeoutSecs
and shutdownMachineOnIdle).
69 Worker panic - either a worker bug, or the environment is not suitable for running
a task, e.g. a file cannot be written to the file system, or something else did
not work that was required in order to execute a task. See config setting
shutdownMachineOnInternalError.
70 A new deploymentId has been issued in the AWS worker type configuration, meaning
this worker environment is no longer up-to-date. Typcially workers should
terminate.
71 The worker was terminated via an interrupt signal (e.g. Ctrl-C pressed).
72 The worker is running on spot infrastructure in AWS EC2 and has been served a
spot termination notice, and therefore has shut down.
73 The config provided to the worker is invalid.` + exitCode74() + `
75 Not able to create an ed25519 key pair.
76 Not able to copy --copy-file to a temporary file.` + exitCode77() + `
78 Not able to connect to --worker-runner-protocol-pipe.
79 Not able to create file at --create-file path.
80 Not able to create directory at --create-dir path.
81 Not able to unarchive --archive-src to --archive-dst.` + exitCode82() + `
`
}