Skip to content

Commit 45fb0cc

Browse files
committed
validate nodename groups
1 parent 5bedf73 commit 45fb0cc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

environments/.stackhpc/tofu/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module "cluster" {
7676
control_node_flavor = var.control_node_flavor
7777

7878
login = {
79-
login = {
79+
head = {
8080
nodes = ["login-0"]
8181
flavor = var.other_node_flavor
8282
}

environments/site/tofu/variables.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ 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.
55+
Keys are names of groups. Keys cannot be 'login', 'compute', or 'control'.
5656
Values are a mapping as follows:
5757
5858
Required:
@@ -88,6 +88,12 @@ variable "login" {
8888
EOF
8989

9090
type = any
91+
validation {
92+
condition = length(setintersection(keys(var.login), ["login", "compute", "control"])) == 0
93+
error_message = <<-EOF
94+
Login nodegroup names cannot be 'login', 'compute' or 'control'. Invalid var.login keys: ${join(", ", setintersection(keys(var.login), ["login", "compute", "control"]))}.
95+
EOF
96+
}
9197
}
9298

9399
variable "cluster_image_id" {
@@ -101,7 +107,7 @@ variable "compute" {
101107
Mapping defining homogenous groups of compute nodes. Groups are used
102108
in Slurm partition definitions.
103109
104-
Keys are names of groups.
110+
Keys are names of groups. Keys cannot be 'compute', 'login', 'control' or 'default'.
105111
Values are a mapping as follows:
106112
107113
Required:
@@ -139,6 +145,12 @@ variable "compute" {
139145
EOF
140146

141147
type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
148+
validation {
149+
condition = length(setintersection(keys(var.compute), ["login", "compute", "control", "default"])) == 0
150+
error_message = <<-EOF
151+
Compute nodegroup names cannot be 'compute', 'default', 'login' or 'control'. Invalid var.compute keys: ${join(", ", setintersection(keys(var.compute), ["login", "compute", "control", "default"]))}.
152+
EOF
153+
}
142154
}
143155

144156
# tflint-ignore: terraform_typed_variables

0 commit comments

Comments
 (0)