Skip to content

Commit 80ce910

Browse files
committed
extend validation to cover additional_nodegroups
1 parent 253cf94 commit 80ce910

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

environments/site/tofu/variables.tf

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ variable "login" {
5252
be useful for e.g. separating nodes for ssh and Open Ondemand usage, or
5353
to define login nodes with different capabilities such as high-memory.
5454
55-
Keys are names of groups. Keys cannot be 'login', 'compute', or 'control'.
55+
Keys are names of groups, and cannot be 'login', 'compute', 'control', or
56+
keys in the compute or additional_nodegroups variables.
5657
Values are a mapping as follows:
5758
5859
Required:
@@ -107,8 +108,8 @@ variable "compute" {
107108
Mapping defining homogenous groups of compute nodes. Groups are used
108109
in Slurm partition definitions.
109110
110-
Keys are names of groups. Keys cannot be 'compute', 'login', 'control' or 'default'
111-
or be the same as keys in the login variable.
111+
Keys are names of groups, and cannot be 'compute', 'login', 'control', 'default'
112+
or keys in the login or additional_nodegroups variables.
112113
Values are a mapping as follows:
113114
114115
Required:
@@ -153,9 +154,9 @@ variable "compute" {
153154
EOF
154155
}
155156
validation {
156-
condition = length(setintersection(keys(var.compute), keys(var.login))) == 0
157+
condition = length(setintersection(keys(var.login), keys(var.compute))) == 0
157158
error_message = <<-EOF
158-
Compute and login nodegroups cannot have the same name. Invalid var.compute/var.login key(s): ${join(", ", setintersection(keys(var.compute), keys(var.login)))}
159+
Compute and additional nodegroups cannot have the same name - var.compute and var.additional_nodegroups have the same keys(s): ${join(", ", setintersection(keys(var.compute), keys(var.additional_nodegroups)))}
159160
EOF
160161
}
161162
}
@@ -168,7 +169,8 @@ variable "additional_nodegroups" {
168169
These nodes are not in the compute or login inventory groups so they
169170
will not run slurmd.
170171
171-
Keys are names of groups.
172+
Keys are names of groups and cannot be 'login', 'compute, 'control', or
173+
keys in the login or additional_nodegroups variables.
172174
Values are a mapping as for the "login" variable, with the addition of
173175
the optional entry:
174176
@@ -181,6 +183,19 @@ variable "additional_nodegroups" {
181183
- $cluster_name + '_' + $group_name
182184
- 'additional'
183185
EOF
186+
type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
187+
validation {
188+
condition = length(setintersection(keys(var.additional_nodegroups), ["login", "compute", "control"])) == 0
189+
error_message = <<-EOF
190+
Additional nodegroup names cannot be 'compute', 'login' or 'control'. Invalid var.additional_nodegroups key(s): ${join(", ", setintersection(keys(var.compute), ["login", "compute", "control"]))}.
191+
EOF
192+
}
193+
validation {
194+
condition = length(setintersection(keys(var.login), keys(var.compute))) == 0
195+
error_message = <<-EOF
196+
Additional and login nodegroups cannot have the same name - var.additional_nodegroups and var.login have the same keys(s): ${join(", ", setintersection(keys(var.additional_nodegroups), keys(var.login)))}
197+
EOF
198+
}
184199
}
185200

186201
variable "environment_root" {

0 commit comments

Comments
 (0)