From f9086a7ff9374d0f9e5db8c88e0703fc10bf620e Mon Sep 17 00:00:00 2001 From: Ivan Orlov Date: Tue, 2 Jan 2024 16:41:48 -0800 Subject: [PATCH] Slurm6. Automagicaly set `nodeset.name` from module id. (#2068) Slurm6. Automagicaly set `nodeset.name` from module id. --- community/examples/hpc-slurm6.yaml | 1 - .../compute/schedmd-slurm-gcp-v6-nodeset/README.md | 2 +- .../modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf | 4 +++- .../compute/schedmd-slurm-gcp-v6-nodeset/metadata.yaml | 2 ++ .../compute/schedmd-slurm-gcp-v6-nodeset/variables.tf | 8 +------- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/community/examples/hpc-slurm6.yaml b/community/examples/hpc-slurm6.yaml index 923691eda4..cf6a15b072 100644 --- a/community/examples/hpc-slurm6.yaml +++ b/community/examples/hpc-slurm6.yaml @@ -41,7 +41,6 @@ deployment_groups: source: community/modules/compute/schedmd-slurm-gcp-v6-nodeset use: [network] settings: - name: ns1 node_count_dynamic_max: 4 machine_type: n2-standard-2 enable_placement: false # the default is: true diff --git a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/README.md b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/README.md index bcc0ad87c8..c754ba63ab 100644 --- a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/README.md +++ b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/README.md @@ -175,7 +175,7 @@ No modules. | [machine\_type](#input\_machine\_type) | Compute Platform machine type to use for this partition compute nodes. | `string` | `"c2-standard-60"` | no | | [metadata](#input\_metadata) | Metadata, provided as a map. | `map(string)` | `{}` | no | | [min\_cpu\_platform](#input\_min\_cpu\_platform) | The name of the minimum CPU platform that you want the instance to use. | `string` | `null` | no | -| [name](#input\_name) | Name of the nodeset. | `string` | `"ghpc"` | no | +| [name](#input\_name) | Name of the nodeset. Automatically populated by the module id if not set | `string` | n/a | yes | | [node\_conf](#input\_node\_conf) | Map of Slurm node line configuration. | `map(any)` | `{}` | no | | [node\_count\_dynamic\_max](#input\_node\_count\_dynamic\_max) | Maximum number of dynamic nodes allowed in this partition. | `number` | `1` | no | | [node\_count\_static](#input\_node\_count\_static) | Number of nodes to be statically created. | `number` | `0` | no | diff --git a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf index e87e20da0a..01eb6cb240 100644 --- a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf +++ b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf @@ -18,6 +18,8 @@ locals { } locals { + name = substr(replace(var.name, "/[^a-z0-9]/", ""), 0, 6) + additional_disks = [ for ad in var.additional_disks : { disk_name = ad.disk_name @@ -34,7 +36,7 @@ locals { node_count_static = var.node_count_static node_count_dynamic_max = var.node_count_dynamic_max node_conf = var.node_conf - nodeset_name = var.name + nodeset_name = local.name disk_auto_delete = var.disk_auto_delete disk_labels = merge(local.labels, var.disk_labels) diff --git a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/metadata.yaml b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/metadata.yaml index 641832182d..929eeecaf0 100644 --- a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/metadata.yaml +++ b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/metadata.yaml @@ -16,3 +16,5 @@ spec: requirements: services: [] +ghpc: + inject_module_id: name diff --git a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/variables.tf b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/variables.tf index d8c70b4802..7d7d964840 100644 --- a/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/variables.tf +++ b/community/modules/compute/schedmd-slurm-gcp-v6-nodeset/variables.tf @@ -13,14 +13,8 @@ # limitations under the License. variable "name" { - description = "Name of the nodeset." + description = "Name of the nodeset. Automatically populated by the module id if not set" type = string - default = "ghpc" - - validation { - condition = can(regex("^[a-z](?:[a-z0-9]{0,5})$", var.name)) - error_message = "Nodeset name (var.name) must begin with a letter, be fully alphanumeric and be 6 characters or less. Regexp: '^[a-z](?:[a-z0-9]{0,5})$'." - } } variable "node_conf" {