File: slurmrestd.8

package info (click to toggle)
slurm-wlm-contrib 24.11.5-4
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 50,600 kB
  • sloc: ansic: 529,598; exp: 64,795; python: 17,051; sh: 9,411; javascript: 6,528; makefile: 4,030; perl: 3,762; pascal: 131
file content (638 lines) | stat: -rw-r--r-- 16,783 bytes parent folder | download | duplicates (3)
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
.TH slurmrestd "8" "Slurm REST Daemon" "May 2025" "Slurm REST Daemon"

.SH "NAME"
slurmrestd \- Interface to Slurm via REST API.
.SH "SYNOPSIS"
\fBslurmrestd\fR [\fIOPTIONS\fR...] <\fI[host]:port\fR|\fIunix:/path/to/socket\fR>...
.SH "DESCRIPTION"
\fBslurmrestd\fR is REST API interface for Slurm. It can be used in two modes:

.PP
\fBInetd Mode\fR: slurmrestd will read and write to STDIO. If STDIN is a socket
file descriptor, then slurmrestd will detect this and use relevant
functionality. If a controlling TTY is detected, interactive mode will
automatically activate to provide additional logging information. This mode is
designed to work with piped input, inetd, xinetd or systemd socket activation.

.PP
\fBListen Mode\fR: slurmrestd will open a listening socket on each requested
\fIhost\fR:\fIport\fR pair or UNIX socket.

.SH "OPTIONS"

.TP
\fB[host]:port\fR
Hostname and port to listen against. \fIhost\fR may be an IPv4/IPv6 IP or a
resolvable hostname. Hostnames are only looked up at startup and do not change
for the life of the process. \fIhost\fR is optional; if not provided, slurmrestd
will listen on all network interfaces.
.IP

.TP
\fBunix:/path/to/socket\fR
Listen on local UNIX socket. Must have permission to create socket in
filesystem.
.IP

.TP
\fB\-a <plugin>\fR[,plugin]...
Comma\-delimited list of authentication plugins to load.
By default all available authentication plugins will be loaded.
.RS
.TP
\fBlist\fR
Display a list of the possible plugins to load.
.IP

.TP
\fBrest_auth/local\fR
Allows authentication via UNIX sockets when \fBauth/munge\fR is active.
.br
\fBNOTE\fR: slurmrestd and client processes must run under the same UID or the
client requests will be rejected.
.IP

.TP
\fBrest_auth/jwt\fR
Allows authentication via TCP and UNIX sockets when \fBAuthAltTypes=auth/jwt\fR
is active. User must specify the following HTTP cookies with each request:
.RS
.TP
\fBX-SLURM-USER-NAME\fR:<user name>
.IP
.TP
\fBX-SLURM-USER-TOKEN\fR:<JSON Web Token>
.RE
.IP
\fBNOTE\fR: Tokens are usually generated via calling "\fBscontrol token\fR".
.RE
.IP

.TP
\fB\-d <plugin>\fR[,plugin]...
Comma\-delimited list of data_parser plugins, which will determine the
output format. May include optional flags denoted by '+' symbol. By default all
available data_parser plugins will be loaded without any optional flags.
See also \fB-s\fR for OpenAPI plugins controlling the available content.
.BR
Defaults: all builtin supported data_parser plugins.
.RS
.TP
\fBlist[+flags]\fR
Display a list of the possible plugins to load.
.IP

.TP
\fBlatest\fR
Automatically replaced with latest plugin version. See relevant plugin for
description and potential flags.
.IP

.TP
\fB[data_parser/]v0.0.40[+fast]\fR
Load data_parser/]v0.0.40 plugin to for formatting of data. Only compatible
with \fBopenapi/slurmctld\fR and \fBopenapi/slurmdbd\fR content plugins.
.RS
.TP
\fB+fast\fR
Disable builtin warnings and other logic to strictly validate
incoming requests. Should only ever be used in a production environment with
very well tested clients and potentially malformatted requests will be accepted
as given and no warnings will be generated about ignored or incorrect fields or
values.
.IP
.RE
.IP

.TP
\fB[data_parser/]v0.0.41[+fast][+prefer_refs]\fR
Load data_parser/]v0.0.41 plugin to for formatting of data. Only compatible
with \fBopenapi/slurmctld\fR and \fBopenapi/slurmdbd\fR content plugins.
.RS
.TP
\fB+fast\fR
Disable builtin warnings and other logic to strictly validate
incoming requests. Should only ever be used in a production environment with
very well tested clients and potentially malformatted requests will be accepted
as given and no warnings will be generated about ignored or incorrect fields or
values.
.IP
.TP
\fB+prefer_refs\fR
Prefer inline expansion of referenced schemas (via \fI$ref\fR) in generated
OpenAPI specifications if the schema is only referenced once.
.IP
.RE
.IP

.TP
\fB[data_parser/]v0.0.42[+fast][+minimize_refs][+inline_enums]\fR
Load data_parser/]v0.0.42 plugin to for formatting of data. Only compatible
with \fBopenapi/slurmctld\fR and \fBopenapi/slurmdbd\fR content plugins.
.RS
.TP
\fB+fast\fR
Disable builtin warnings and other logic to strictly validate
incoming requests. Should only ever be used in a production environment with
very well tested clients and potentially malformatted requests will be accepted
as given and no warnings will be generated about ignored or incorrect fields or
values.
.IP
.TP
\fB+minimize_refs\fR
Avoid inline expansion of referenced schemas (via \fI$ref\fR) in generated
OpenAPI specifications if the schema is only referenced once.
.IP
.TP
\fB+inline_enums\fR
Avoid inline expansion of referenced schemas (via \fI$ref\fR) in generated
OpenAPI specifications for enum arrays.
.IP
.RE
.IP

.RE
.IP

.TP
\fB\-f <file>\fR
Read Slurm configuration from the specified file. See \fBNOTES\fR below.
.IP

.TP
\fB\-\-generate\-openapi\-spec\fR
Dump JSON formatted OpenAPI specification to stdout and exit immediately.
Loads miminal plugins required. Loading of \fBslurm.conf\fR(5) can be disabled
by passing additional arguments \fB\-f /dev/null\fR or setting
\fBSLURM_CONF\fR=/dev/null in the environment.
.IP

.TP
\fB\-g <group id>\fR
Change group id (and drop supplemental groups) before processing client
request. This should be a unique group with no write access or special
permissions. Do not set this to the group belonging to to SlurmUser or
root or the daemon won't start with the default settings.
.IP

.TP
\fB\-h\fR, \fB\-\-help\fR
Help; print a brief summary of command options.
.IP

.TP
\fB\-\-max\-connections <count>\fR
Set the maximum number of connections to process at any one time. This is
independent of the number of connections that can connect to slurmrestd at any
one time. The kernel allows any number of connections to be pending for
processing at any one time when SYN cookies are active.
.RS
.TP
\fBCaution\fR:
Each connection could cause one RPC to the controller daemons, leading to
potential overloading of the controller. Each connection can also hold memory
for the duration of the life of the connection. Having too many connections
processing at once could use considerably more memory. Process limits
(\fBulimit\fR(3)) may require adjustment when this value is increased.
.TP
Default: 124
.RE
.IP

.TP
\fB\-s <plugin>\fR[,plugin]...
Comma\-delimited list of OpenAPI plugins to load, which will determine the
available content. By default all available OpenAPI plugins will be loaded.
See also \fB-d\fR for the data_parser plugins controlling the output format.
.RS
.TP
\fBlist\fR
Display a list of the possible plugins to load.
.IP

.TP
\fB[openapi/]slurmctld\fR
Provides 'slurm/' endpoints for the loaded data_parser plugins.
.IP

.TP
\fB[openapi/]slurmdbd\fR
Provides 'slurmdb/' endpoints for the loaded data_parser plugins. This plugin
will fail if \fBaccounting_storage/slurmdbd\fR is not used in the cluster.
.IP
.RE
.IP

.TP
\fB\-t <THREAD COUNT>\fR
Specify number of threads to use to process client connections.
Ignored in inetd mode. Default: 20
.IP

.TP
\fB\-u <user id>\fR
Change user id before processing client request. This should be a unique group
with no write access or special permissions. Do not set this user to SlurmUser
or root or the daemon won't start with the default settings.
.IP

.TP
\fB\-v\fR
Verbose operation. Multiple \fBv\fR's can be specified, with each '\fBv\fR'
beyond the first increasing verbosity, up to 6 times (i.e. \-vvvvvv).
Higher verbosity levels will have significant performance impact.
.IP

.TP
\fB\-V\fR
Print version information and exit.
.IP

.SH "ENVIRONMENT VARIABLES"
The following environment variables can be used to override settings
compiled into slurmrestd.

.TP
\fBABORT_ON_FATAL\fR
When a fatal error is detected, use abort() instead of exit() to terminate the
process. This allows backtraces to be captured without recompiling Slurm.
.IP

.TP
\fBSLURM_CONF\fR
The location of the Slurm configuration file.
.IP

.TP
\fBSLURM_DEBUG_FLAGS\fR
Specify debug flags for slurmrestd to use. See DebugFlags in the
\fBslurm.conf\fR(5) man page for a full list of flags. The environment
variable takes precedence over the setting in the slurm.conf.
.IP

.TP
\fBSLURMRESTD_JSON\fR
Control JSON serialization:
.IP
.RS
.TP
\fBcompact\fR
Output JSON as compact as possible.
.IP

.TP
\fBpretty\fR
Output JSON in pretty format to make it more readable.
.IP
.RE

.TP
\fBSLURM_JWT\fR
This variable must be set to use JWT token authentication.
.IP

.TP
\fBSLURMRESTD_AUTH_TYPES\fR
Set allowed authentication types. See \fB\-a\fR
.IP

.TP
\fBSLURMRESTD_DEBUG\fR
Set debug level explicitly. Valid values are 0\-9, or the same string values as
the debug options such as SlurmctldDebug in slurm.conf(5).
Ignored if \fB\-v\fR passed as argument during invocation.
.IP

.TP
\fBSLURMRESTD_DATA_PARSER_PLUGINS\fR
Comma\-delimited list of data_parser plugins to load. See \fB\-d\fR
.IP

.TP
\fBSLURMRESTD_LISTEN\fR
Comma\-delimited list of host:port pairs or unix sockets to listen on.
.IP

.TP
\fBSLURMRESTD_MAX_CONNECTIONS\fR
Set the maximum number of connections to process at any one time. See
\fB\-\-max\-connections\fR
.IP

.TP
\fBSLURMRESTD_OPENAPI_PLUGINS\fR
Comma\-delimited list of OpenAPI plugins to load. See \fB\-s\fR
.IP

.TP
\fBSLURMRESTD_RESPONSE_STATUS_CODES\fR
Comma\-delimited list of OpenAPI method responses to generate in OpenAPI
specification.
.BR
Default: 200,default
.IP

.TP
\fBSLURMRESTD_SECURITY\fR
Control slurmrestd security functionality using the following comma\-delimited
values:
.IP
.RS
.TP
\fBbecome_user\fR
Allows \fBslurmrestd\fR to be run as root in order to become the requesting
user for all requests. When combined with \fBrest_auth/local\fB, when a user
connects via a named UNIX socket, \fBslurmrestd\fR will setuid()/setgid() into
that user/group and then complete all requests as the given user. This mode is
only intended for inet mode as the user change is permanent for the life of the
process. This mode is incompatible with \fBrest_auth/jwt\fR and it is suggested
to start \fBslurmrestd\fR with "-a \fBrest_auth/local\fR" arguments.
.IP

.TP
\fBdisable_unshare_files\fR
Disables unsharing file descriptors with parent process.
.IP

.TP
\fBdisable_unshare_sysv\fR
Disables unsharing the SYSV namespace.
.IP

.TP
\fBdisable_user_check\fR
Disables check that slurmrestd is not running as root or SlurmUser, or with the
root or SlurmUser's primary group.
.RE
.IP

.TP
\fBSLURMRESTD_YAML\fR
Control YAML serialization:
.IP
.RS
.TP
\fBcompact\fR
Output YAML as compact as possible.
.IP

.TP
\fBpretty\fR
Output YAML in pretty format to make it more readable.
.RE
.IP

.SH "SIGNALS"

.TP 6
\fBSIGINT\fR
\fBslurmrestd\fR will shutdown cleanly.
.IP

.TP
\fBSIGPIPE\fR
This signal is explicitly ignored.
.IP

.SH "NOTES"
\fBSPANK\fR and \fBclifilter\fR plugins are not supported in \fBslurmrestd\fR
due to their lack of thread safety. Active \fBSPANK\fR plugins and
\fBJobSubmitPlugins\fR in \fBslurmctld\fR are independent of slurmrestd and can
be used to enforce site policy on job submissions.

.SH "EXAMPLES"

.LP
Generate OpenAPI schema without configuration
.IP
.nf
$ slurmrestd -f /dev/null  --generate-openapi-spec -s slurmdbd,slurmctld -d v0.0.42 > openapi.json
.fi

.LP
Start \fBslurmrestd\fR with a UNIX socket in listen mode:
.IP
.nf
$ export SLURMRESTD=/var/spool/slurm/restd/rest
$ slurmrestd -s slurmctld,slurmdbd -d v0.0.42 unix:$SLURMRESTD
.fi

.LP
Verify connectivity with slurmctld with a ping, with \fBslurmrestd\fR
running in listen mode:
.IP
.nf
$ export $(scontrol token)
$ curl --unix-socket "${SLURMRESTD}" -H "X-SLURM-USER-TOKEN:${SLURM_JWT}" 'http://ignored_with_unix_sockets/slurm/v0.0.42/ping' | jq '.pings'
[
  {
    "hostname": "omicronpersei8",
    "pinged": "UP",
    "latency": 314,
    "mode": "primary"
  }
]
.fi

.LP
Verify connectivity with slurmdbd with a diag request, with \fBslurmrestd\fR
running in listen mode:
.IP
.nf
$ export $(scontrol token)
$ curl --unix-socket "${SLURMRESTD}" -H "X-SLURM-USER-TOKEN:${SLURM_JWT}" 'http://ignored_with_unix_sockets/slurmdb/v0.0.42/diag' | jq '.pings'
1722009793
.fi

.LP
Query the status of a node with \fBslurmrestd\fR running in INETD mode:
.IP
.nf
$ echo -e "GET http://ignored/slurm/v0.0.42/node/host1 HTTP/1.1\\r\\n" | slurmrestd
HTTP/1.1 200 OK
Content-Length: 3174
Content-Type: application/json

{
  "nodes": [
    {
      "architecture": "x86_64",
      "burstbuffer_network_address": "",
      "boards": 1,
      "boot_time": {
        "set": true,
        "infinite": false,
	"number": 1720820315
      },
      "cluster_name": "",
      "cores": 16,
      "specialized_cores": 0,
      "cpu_binding": 0,
      "cpu_load": 446,
      "free_mem": {
        "set": true,
        "infinite": false,
	"number": 39871
      },
      "cpus": 32,
      "effective_cpus": 32,
      "specialized_cpus": "",
      "energy": {
        "average_watts": 0,
        "base_consumed_energy": 0,
        "consumed_energy": 0,
	"current_watts": {
          "set": false,
          "infinite": false,
          "number": 0
        },
	"previous_consumed_energy": 0,
	"last_collected": 0
      },
      "external_sensors": {},
      "extra": "",
      "power": {},
      "features": [],
      "active_features": [],
      "gpu_spec": "",
      "gres": "gpu:fake1:1(S:0),gpu:fake2:1(S:0)",
      "gres_drained": "N\/A",
      "gres_used": "gpu:fake1:0(IDX:N\/A),gpu:fake2:0(IDX:N\/A)",
      "instance_id": "",
      "instance_type": "",
      "last_busy": {
	"set": true,
	"infinite": false,
	"number": 1722009794
      },
      "mcs_label": "",
      "specialized_memory": 0,
      "name": "host1",
      "next_state_after_reboot": [
	"INVALID"
      ],
      "address": "localhost",
      "hostname": "omicronpersei8",
      "state": [
        "IDLE"
      ],
      "operating_system": "Linux 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun  7 15:10:09 UTC 2024",
      "owner": "",
      "partitions": [
        "debug"
      ],
      "port": 5015,
      "real_memory": 127927,
      "res_cores_per_gpu": 0,
      "comment": "",
      "reason": "",
      "reason_changed_at": {
	"set": true,
	"infinite": false,
	"number": 0
      },
      "reason_set_by_user": "",
      "resume_after": {
        "set": true,
        "infinite": false,
        "number": 0
      },
      "reservation": "",
      "alloc_memory": 0,
      "alloc_cpus": 0,
      "alloc_idle_cpus": 32,
      "tres_used": "",
      "tres_weighted": 0.0,
      "slurmd_start_time": {
	"set": true,
	"infinite": false,
	"number": 1722009794
      },
      "sockets": 1,
      "threads": 2,
      "temporary_disk": 0,
      "weight": 1,
      "tres": "cpu=32,mem=127927M,billing=32,gres\/gpu=2",
      "version": "24.11.0-0rc1"
    }
  ],
  "last_update": {
    "set": true,
    "infinite": false,
    "number": 1722010273
  },
  "meta": {
<<< TRIMMED >>>
  },
  "errors": [],
  "warnings": []
}
.fi

.LP
Submit a job to \fBslurmrestd\fR with it running in listen mode:
.IP
.nf
$ jq . example_job.json
{
  "job": {
    "script": "#!/bin/bash\\nsleep 30",
    "name": "ExampleJob",
    "account": "sub1",
    "environment": [
      "PATH=/usr/bin/:/bin/"
    ],
    "current_working_directory": "/tmp/",
    "tasks": 12,
    "memory_per_cpu": 100,
    "time_limit": 240
  }
}

$ curl -H "Content-Type: application/json" --data-binary @example_job.json --unix-socket "${SLURMRESTD}" 'http://ignored/slurm/v0.0.42/job/submit'
{
  "job_id": 9,
  "step_id": "batch",
  "job_submit_user_msg": "",
  "meta": {
<<< TRIMMED >>>
  },
  "errors": [],
  "warnings": []
}

$ curl -H "Content-Type: application/json" --data-binary @example_job.json --unix-socket "${SLURMRESTD}" 'http://ignored/slurm/v0.0.42/job/submit'
{
  "job_id": 7,
  "step_id": "batch",
  "job_submit_user_msg": "",
  "meta": {
  },
  "errors": [],
  "warnings": [
    {
      "description": "Expected OpenAPI type=array (Slurm type=list) but got OpenAPI type=object (Slurm type=dictionary): {\"PATH\":\"\\\/bin\"}",
      "source": "#\/job\/environment\/"
    }
  ]
}
.fi

.SH "COPYING"
Copyright (C) 2019\-2022 SchedMD LLC.
.LP
This file is part of Slurm, a resource management program.
For details, see <https://slurm.schedmd.com/>.
.LP
Slurm is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
.LP
Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.

.SH "SEE ALSO"
\fBslurm.conf\fR(5), \fBslurmctld\fR(8), \fBslurmdbd\fR(8)