forked from GoogleCloudPlatform/slurm-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
643 lines (587 loc) · 19.6 KB
/
variables.tf
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
639
640
641
642
643
/**
* Copyright (C) SchedMD LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
###########
# GENERAL #
###########
variable "project_id" {
type = string
description = "Project ID to create resources in."
}
variable "slurm_cluster_name" {
type = string
description = "Cluster name, used for resource naming and slurm accounting."
validation {
condition = can(regex("^[a-z](?:[a-z0-9]{0,9})$", var.slurm_cluster_name))
error_message = "Variable 'slurm_cluster_name' must be a match of regex '^[a-z](?:[a-z0-9]{0,9})$'."
}
}
variable "region" {
type = string
description = "The default region to place resources in."
}
##########
# BUCKET #
##########
variable "create_bucket" {
description = <<-EOD
Create GCS bucket instead of using an existing one.
EOD
type = bool
default = true
}
variable "bucket_name" {
description = <<-EOD
Name of GCS bucket.
Ignored when 'create_bucket' is true.
EOD
type = string
default = null
}
variable "bucket_dir" {
description = "Bucket directory for cluster files to be put into. If not specified, then one will be chosen based on slurm_cluster_name."
type = string
default = null
}
#####################
# CONTROLLER: CLOUD #
#####################
variable "controller_instance_config" {
description = <<EOD
Creates a controller instance with given configuration.
EOD
type = object({
additional_disks = optional(list(object({
disk_name = optional(string)
device_name = optional(string)
disk_size_gb = optional(number)
disk_type = optional(string)
disk_labels = optional(map(string), {})
auto_delete = optional(bool, true)
boot = optional(bool, false)
})), [])
bandwidth_tier = optional(string, "platform_default")
can_ip_forward = optional(bool, false)
disable_smt = optional(bool, false)
disk_auto_delete = optional(bool, true)
disk_labels = optional(map(string), {})
disk_size_gb = optional(number)
disk_type = optional(string, "n1-standard-1")
enable_confidential_vm = optional(bool, false)
enable_public_ip = optional(bool, false)
enable_oslogin = optional(bool, true)
enable_shielded_vm = optional(bool, false)
gpu = optional(object({
count = number
type = string
}))
instance_template = optional(string)
labels = optional(map(string), {})
machine_type = optional(string)
metadata = optional(map(string), {})
min_cpu_platform = optional(string)
network_ip = optional(string)
network_tier = optional(string, "STANDARD")
on_host_maintenance = optional(string)
preemptible = optional(bool, false)
region = optional(string)
service_account = optional(object({
email = optional(string)
scopes = optional(list(string), ["https://www.googleapis.com/auth/cloud-platform"])
}))
shielded_instance_config = optional(object({
enable_integrity_monitoring = optional(bool, true)
enable_secure_boot = optional(bool, true)
enable_vtpm = optional(bool, true)
}))
source_image_family = optional(string)
source_image_project = optional(string)
source_image = optional(string)
spot = optional(bool, false)
static_ip = optional(string)
subnetwork_project = optional(string)
subnetwork = optional(string)
tags = optional(list(string), [])
termination_action = optional(string)
zone = optional(string)
})
default = {}
}
######################
# CONTROLLER: HYBRID #
######################
variable "enable_hybrid" {
description = <<EOD
Enables use of hybrid controller mode. When true, controller_hybrid_config will
be used instead of controller_instance_config and will disable login instances.
EOD
type = bool
default = false
}
variable "controller_hybrid_config" {
description = <<EOD
Creates a hybrid controller with given configuration.
See 'main.tf' for valid keys.
EOD
type = object({
google_app_cred_path = optional(string)
slurm_control_host = optional(string)
slurm_control_host_port = optional(string)
slurm_control_addr = optional(string)
slurm_bin_dir = optional(string)
slurm_log_dir = optional(string)
output_dir = optional(string)
install_dir = optional(string)
munge_mount = optional(object({
server_ip = optional(string)
remote_mount = optional(string, "/etc/munge")
fs_type = optional(string, "nfs")
mount_options = optional(string)
}), {})
})
default = {}
}
#########
# LOGIN #
#########
variable "enable_login" {
description = <<EOD
Enables the creation of login nodes and instance templates.
EOD
type = bool
default = true
}
variable "login_nodes" {
description = "List of slurm login instance definitions."
type = list(object({
additional_disks = optional(list(object({
disk_name = optional(string)
device_name = optional(string)
disk_size_gb = optional(number)
disk_type = optional(string)
disk_labels = optional(map(string), {})
auto_delete = optional(bool, true)
boot = optional(bool, false)
})), [])
bandwidth_tier = optional(string, "platform_default")
can_ip_forward = optional(bool, false)
disable_smt = optional(bool, false)
disk_auto_delete = optional(bool, true)
disk_labels = optional(map(string), {})
disk_size_gb = optional(number)
disk_type = optional(string, "n1-standard-1")
enable_confidential_vm = optional(bool, false)
enable_public_ip = optional(bool, false)
enable_oslogin = optional(bool, true)
enable_shielded_vm = optional(bool, false)
gpu = optional(object({
count = number
type = string
}))
group_name = string
instance_template = optional(string)
labels = optional(map(string), {})
machine_type = optional(string)
metadata = optional(map(string), {})
min_cpu_platform = optional(string)
network_tier = optional(string, "STANDARD")
num_instances = optional(number, 1)
on_host_maintenance = optional(string)
preemptible = optional(bool, false)
region = optional(string)
service_account = optional(object({
email = optional(string)
scopes = optional(list(string), ["https://www.googleapis.com/auth/cloud-platform"])
}))
shielded_instance_config = optional(object({
enable_integrity_monitoring = optional(bool, true)
enable_secure_boot = optional(bool, true)
enable_vtpm = optional(bool, true)
}))
source_image_family = optional(string)
source_image_project = optional(string)
source_image = optional(string)
static_ips = optional(list(string), [])
subnetwork_project = optional(string)
subnetwork = optional(string)
spot = optional(bool, false)
tags = optional(list(string), [])
zone = optional(string)
termination_action = optional(string)
}))
default = []
}
############
# NODESETS #
############
variable "nodeset" {
description = "Define nodesets, as a list."
type = list(object({
node_count_static = optional(number, 0)
node_count_dynamic_max = optional(number, 1)
node_conf = optional(map(string), {})
nodeset_name = string
additional_disks = optional(list(object({
disk_name = optional(string)
device_name = optional(string)
disk_size_gb = optional(number)
disk_type = optional(string)
disk_labels = optional(map(string), {})
auto_delete = optional(bool, true)
boot = optional(bool, false)
})), [])
bandwidth_tier = optional(string, "platform_default")
can_ip_forward = optional(bool, false)
disable_smt = optional(bool, false)
disk_auto_delete = optional(bool, true)
disk_labels = optional(map(string), {})
disk_size_gb = optional(number)
disk_type = optional(string)
enable_confidential_vm = optional(bool, false)
enable_placement = optional(bool, false)
enable_public_ip = optional(bool, false)
enable_oslogin = optional(bool, true)
enable_shielded_vm = optional(bool, false)
gpu = optional(object({
count = number
type = string
}))
instance_template = optional(string)
labels = optional(map(string), {})
machine_type = optional(string)
metadata = optional(map(string), {})
min_cpu_platform = optional(string)
network_tier = optional(string, "STANDARD")
on_host_maintenance = optional(string)
preemptible = optional(bool, false)
region = optional(string)
reservation_name = optional(string)
service_account = optional(object({
email = optional(string)
scopes = optional(list(string), ["https://www.googleapis.com/auth/cloud-platform"])
}))
shielded_instance_config = optional(object({
enable_integrity_monitoring = optional(bool, true)
enable_secure_boot = optional(bool, true)
enable_vtpm = optional(bool, true)
}))
source_image_family = optional(string)
source_image_project = optional(string)
source_image = optional(string)
subnetwork_project = optional(string)
subnetwork = optional(string)
spot = optional(bool, false)
tags = optional(list(string), [])
termination_action = optional(string)
zones = optional(list(string), [])
zone_target_shape = optional(string, "ANY_SINGLE_ZONE")
}))
default = []
validation {
condition = length(distinct([for x in var.nodeset : x.nodeset_name])) == length(var.nodeset)
error_message = "All nodesets must have a unique name."
}
}
variable "nodeset_dyn" {
description = "Defines nodesets (dynamic), as a list."
type = list(object({
nodeset_name = string
nodeset_feature = string
}))
default = []
validation {
condition = length(distinct([for x in var.nodeset_dyn : x.nodeset_name])) == length(var.nodeset_dyn)
error_message = "All nodesets must have a unique name."
}
}
variable "nodeset_tpu" {
description = "Define TPU nodesets, as a list."
type = list(object({
node_count_static = optional(number, 0)
node_count_dynamic_max = optional(number, 1)
nodeset_name = string
enable_public_ip = optional(bool, false)
node_type = optional(string)
accelerator_config = optional(object({
topology = string
version = string
}), {
topology = ""
version = ""
})
tf_version = string
preemptible = optional(bool, false)
preserve_tpu = optional(bool, true)
zone = string
data_disks = optional(list(string), [])
docker_image = optional(string, "")
subnetwork = optional(string, "")
service_account = optional(object({
email = optional(string)
scopes = optional(list(string), ["https://www.googleapis.com/auth/cloud-platform"])
}))
}))
default = []
validation {
condition = length(distinct([for x in var.nodeset_tpu : x.nodeset_name])) == length(var.nodeset_tpu)
error_message = "All TPU nodesets must have a unique name."
}
}
#############
# PARTITION #
#############
variable "partitions" {
description = <<EOD
Cluster partitions as a list. See module slurm_partition.
EOD
type = list(object({
default = optional(bool, false)
enable_job_exclusive = optional(bool, false)
network_storage = optional(list(object({
server_ip = string
remote_mount = string
local_mount = string
fs_type = string
mount_options = string
})), [])
partition_conf = optional(map(string), {})
partition_name = string
partition_nodeset = optional(list(string), [])
partition_nodeset_dyn = optional(list(string), [])
partition_nodeset_tpu = optional(list(string), [])
resume_timeout = optional(number)
suspend_time = optional(number, 300)
suspend_timeout = optional(number)
}))
validation {
condition = length(var.partitions) > 0
error_message = "Partitions cannot be empty."
}
}
#########
# SLURM #
#########
variable "enable_devel" {
type = bool
description = "Enables development mode. Not for production use."
default = false
}
variable "enable_debug_logging" {
type = bool
description = "Enables debug logging mode. Not for production use."
default = false
}
variable "extra_logging_flags" {
type = map(bool)
description = "The list of extra flags for the logging system to use. See the logging_flags variable in scripts/util.py to get the list of supported log flags."
default = {}
}
variable "enable_cleanup_compute" {
description = <<EOD
Enables automatic cleanup of compute nodes and resource policies (e.g.
placement groups) managed by this module, when cluster is destroyed.
NOTE: Requires Python and script dependencies.
*WARNING*: Toggling this may impact the running workload. Deployed compute nodes
may be destroyed and their jobs will be requeued.
EOD
type = bool
default = false
}
variable "enable_slurm_gcp_plugins" {
description = <<EOD
Enables calling hooks in scripts/slurm_gcp_plugins during cluster resume and suspend.
EOD
type = any
default = false
}
variable "enable_bigquery_load" {
description = <<EOD
Enables loading of cluster job usage into big query.
NOTE: Requires Google Bigquery API.
EOD
type = bool
default = false
}
variable "cloud_parameters" {
description = "cloud.conf options."
type = object({
no_comma_params = optional(bool, false)
resume_rate = optional(number, 0)
resume_timeout = optional(number, 300)
suspend_rate = optional(number, 0)
suspend_timeout = optional(number, 300)
})
default = {}
}
variable "disable_default_mounts" {
description = <<-EOD
Disable default global network storage from the controller
* /usr/local/etc/slurm
* /etc/munge
* /home
* /apps
If these are disabled, the slurm etc and munge dirs must be added manually,
or some other mechanism must be used to synchronize the slurm conf files
and the munge key across the cluster.
EOD
type = bool
default = false
}
variable "network_storage" {
description = <<EOD
Storage to mounted on all instances.
* server_ip : Address of the storage server.
* remote_mount : The location in the remote instance filesystem to mount from.
* local_mount : The location on the instance filesystem to mount to.
* fs_type : Filesystem type (e.g. "nfs").
* mount_options : Options to mount with.
EOD
type = list(object({
server_ip = string
remote_mount = string
local_mount = string
fs_type = string
mount_options = string
}))
default = []
}
variable "login_network_storage" {
description = <<EOD
Storage to mounted on login and controller instances
* server_ip : Address of the storage server.
* remote_mount : The location in the remote instance filesystem to mount from.
* local_mount : The location on the instance filesystem to mount to.
* fs_type : Filesystem type (e.g. "nfs").
* mount_options : Options to mount with.
EOD
type = list(object({
server_ip = string
remote_mount = string
local_mount = string
fs_type = string
mount_options = string
}))
default = []
}
variable "slurmdbd_conf_tpl" {
description = "Slurm slurmdbd.conf template file path."
type = string
default = null
}
variable "slurm_conf_tpl" {
description = "Slurm slurm.conf template file path."
type = string
default = null
}
variable "cgroup_conf_tpl" {
description = "Slurm cgroup.conf template file path."
type = string
default = null
}
variable "controller_startup_scripts" {
description = "List of scripts to be ran on controller VM startup."
type = list(object({
filename = string
content = string
}))
default = []
}
variable "controller_startup_scripts_timeout" {
description = <<EOD
The timeout (seconds) applied to each script in controller_startup_scripts. If
any script exceeds this timeout, then the instance setup process is considered
failed and handled accordingly.
NOTE: When set to 0, the timeout is considered infinite and thus disabled.
EOD
type = number
default = 300
}
variable "login_startup_scripts" {
description = "List of scripts to be ran on login VM startup."
type = list(object({
filename = string
content = string
}))
default = []
}
variable "login_startup_scripts_timeout" {
description = <<EOD
The timeout (seconds) applied to each script in login_startup_scripts. If
any script exceeds this timeout, then the instance setup process is considered
failed and handled accordingly.
NOTE: When set to 0, the timeout is considered infinite and thus disabled.
EOD
type = number
default = 300
}
variable "compute_startup_scripts" {
description = "List of scripts to be ran on compute VM startup."
type = list(object({
filename = string
content = string
}))
default = []
}
variable "compute_startup_scripts_timeout" {
description = <<EOD
The timeout (seconds) applied to each script in compute_startup_scripts. If
any script exceeds this timeout, then the instance setup process is considered
failed and handled accordingly.
NOTE: When set to 0, the timeout is considered infinite and thus disabled.
EOD
type = number
default = 300
}
variable "prolog_scripts" {
description = <<EOD
List of scripts to be used for Prolog. Programs for the slurmd to execute
whenever it is asked to run a job step from a new job allocation.
See https://slurm.schedmd.com/slurm.conf.html#OPT_Prolog.
EOD
type = list(object({
filename = string
content = string
}))
default = []
}
variable "epilog_scripts" {
description = <<EOD
List of scripts to be used for Epilog. Programs for the slurmd to execute
on every node when a user's job completes.
See https://slurm.schedmd.com/slurm.conf.html#OPT_Epilog.
EOD
type = list(object({
filename = string
content = string
}))
default = []
}
variable "cloudsql" {
description = <<EOD
Use this database instead of the one on the controller.
* server_ip : Address of the database server.
* user : The user to access the database as.
* password : The password, given the user, to access the given database. (sensitive)
* db_name : The database to access.
EOD
type = object({
server_ip = string
user = string
password = string # sensitive
db_name = string
})
default = null
sensitive = true
}