Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlurmGCP. Move source_image_logic down to template module #3455

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ modules. For support with the underlying modules, see the instructions in the
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 5.11 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | >= 5.11 |
No providers.

## Modules

Expand All @@ -78,9 +75,7 @@ modules. For support with the underlying modules, see the instructions in the

## Resources

| Name | Type |
|------|------|
| [google_compute_image.slurm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source |
No resources.

## Inputs

Expand All @@ -104,7 +99,7 @@ modules. For support with the underlying modules, see the instructions in the
| <a name="input_enable_spot_vm"></a> [enable\_spot\_vm](#input\_enable\_spot\_vm) | Enable the partition to use spot VMs (https://cloud.google.com/spot-vms). | `bool` | `false` | no |
| <a name="input_feature"></a> [feature](#input\_feature) | The node feature, used to bind nodes to the nodeset. If not set, the nodeset name will be used. | `string` | `null` | no |
| <a name="input_guest_accelerator"></a> [guest\_accelerator](#input\_guest\_accelerator) | List of the type and count of accelerator cards attached to the instance. | <pre>list(object({<br/> type = string,<br/> count = number<br/> }))</pre> | `[]` | no |
| <a name="input_instance_image"></a> [instance\_image](#input\_instance\_image) | Defines the image that will be used in the Slurm node group VM instances.<br/><br/>Expected Fields:<br/>name: The name of the image. Mutually exclusive with family.<br/>family: The image family to use. Mutually exclusive with name.<br/>project: The project where the image is hosted.<br/><br/>For more information on creating custom images that comply with Slurm on GCP<br/>see the "Slurm on GCP Custom Images" section in docs/vm-images.md. | `map(string)` | <pre>{<br/> "family": "slurm-gcp-6-8-hpc-rocky-linux-8",<br/> "project": "schedmd-slurm-public"<br/>}</pre> | no |
| <a name="input_instance_image"></a> [instance\_image](#input\_instance\_image) | Defines the image that will be used in the Slurm node group VM instances.<br/><br/>Expected Fields:<br/>name: The name of the image. Mutually exclusive with family.<br/>family: The image family to use. Mutually exclusive with name.<br/>project: The project where the image is hosted.<br/><br/>For more information on creating custom images that comply with Slurm on GCP<br/>see the "Slurm on GCP Custom Images" section in docs/vm-images.md. | `map(string)` | `null` | no |
| <a name="input_instance_image_custom"></a> [instance\_image\_custom](#input\_instance\_image\_custom) | A flag that designates that the user is aware that they are requesting<br/>to use a custom and potentially incompatible image for this Slurm on<br/>GCP module.<br/><br/>If the field is set to false, only the compatible families and project<br/>names will be accepted. The deployment will fail with any other image<br/>family or name. If set to true, no checks will be done.<br/><br/>See: https://goo.gle/hpc-slurm-images | `bool` | `false` | no |
| <a name="input_labels"></a> [labels](#input\_labels) | Labels to add to partition compute instances. Key-value pairs. | `map(string)` | `{}` | no |
| <a name="input_machine_type"></a> [machine\_type](#input\_machine\_type) | Compute Platform machine type to use for this partition compute nodes. | `string` | `"c2-standard-60"` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ locals {
nodeset_name = substr(replace(var.name, "/[^a-z0-9]/", ""), 0, 14)
feature = coalesce(var.feature, local.nodeset_name)

disable_automatic_updates_metadata = var.allow_automatic_updates ? {} : { google_disable_automatic_updates = "TRUE" }

metadata = merge(
local.disable_automatic_updates_metadata,
{ slurmd_feature = local.feature },
var.metadata
)
Expand Down Expand Up @@ -84,16 +81,18 @@ module "slurm_nodeset_template" {
labels = local.labels
machine_type = var.machine_type

min_cpu_platform = var.min_cpu_platform
on_host_maintenance = var.on_host_maintenance
termination_action = try(var.spot_instance_config.termination_action, null)
preemptible = var.preemptible
spot = var.enable_spot_vm
service_account = local.service_account
gpu = one(local.guest_accelerator) # requires gpu_definition.tf
source_image_family = local.source_image_family # requires source_image_logic.tf
source_image_project = local.source_image_project_normalized # requires source_image_logic.tf
source_image = local.source_image # requires source_image_logic.tf
min_cpu_platform = var.min_cpu_platform
on_host_maintenance = var.on_host_maintenance
termination_action = try(var.spot_instance_config.termination_action, null)
preemptible = var.preemptible
spot = var.enable_spot_vm
service_account = local.service_account
gpu = one(local.guest_accelerator) # requires gpu_definition.tf

instance_image = var.instance_image
instance_image_custom = var.instance_image_custom
allow_automatic_updates = var.allow_automatic_updates


subnetwork = var.subnetwork_self_link
additional_networks = var.additional_networks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,7 @@ variable "instance_image" {
see the "Slurm on GCP Custom Images" section in docs/vm-images.md.
EOD
type = map(string)
default = {
family = "slurm-gcp-6-8-hpc-rocky-linux-8"
project = "schedmd-slurm-public"
}

validation {
condition = can(coalesce(var.instance_image.project))
error_message = "In var.instance_image, the \"project\" field must be a string set to the Cloud project ID."
}

validation {
condition = can(coalesce(var.instance_image.name)) != can(coalesce(var.instance_image.family))
error_message = "In var.instance_image, exactly one of \"family\" or \"name\" fields must be set to desired image family or name."
}
default = null
}

variable "instance_image_custom" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
terraform {
required_version = ">= 1.3"

required_providers {
google = {
source = "hashicorp/google"
version = ">= 5.11"
}
}
provider_meta "google" {
module_name = "blueprints/terraform/hpc-toolkit:schedmd-slurm-gcp-v6-nodeset-dynamic/v1.44.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ No modules.
| Name | Type |
|------|------|
| [terraform_data.machine_type_zone_validation](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [google_compute_image.slurm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source |
| [google_compute_machine_types.machine_types_by_zone](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_machine_types) | data source |
| [google_compute_reservation.reservation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_reservation) | data source |
| [google_compute_zones.available](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_zones) | data source |
Expand Down Expand Up @@ -181,7 +180,7 @@ No modules.
| <a name="input_enable_spot_vm"></a> [enable\_spot\_vm](#input\_enable\_spot\_vm) | Enable the partition to use spot VMs (https://cloud.google.com/spot-vms). | `bool` | `false` | no |
| <a name="input_future_reservation"></a> [future\_reservation](#input\_future\_reservation) | If set, will make use of the future reservation for the nodeset. Input can be either the future reservation name or its selfLink in the format 'projects/PROJECT\_ID/zones/ZONE/futureReservations/FUTURE\_RESERVATION\_NAME'.<br/>See https://cloud.google.com/compute/docs/instances/future-reservations-overview | `string` | `""` | no |
| <a name="input_guest_accelerator"></a> [guest\_accelerator](#input\_guest\_accelerator) | List of the type and count of accelerator cards attached to the instance. | <pre>list(object({<br/> type = string,<br/> count = number<br/> }))</pre> | `[]` | no |
| <a name="input_instance_image"></a> [instance\_image](#input\_instance\_image) | Defines the image that will be used in the Slurm node group VM instances.<br/><br/>Expected Fields:<br/>name: The name of the image. Mutually exclusive with family.<br/>family: The image family to use. Mutually exclusive with name.<br/>project: The project where the image is hosted.<br/><br/>For more information on creating custom images that comply with Slurm on GCP<br/>see the "Slurm on GCP Custom Images" section in docs/vm-images.md. | `map(string)` | <pre>{<br/> "family": "slurm-gcp-6-8-hpc-rocky-linux-8",<br/> "project": "schedmd-slurm-public"<br/>}</pre> | no |
| <a name="input_instance_image"></a> [instance\_image](#input\_instance\_image) | Defines the image that will be used in the Slurm node group VM instances.<br/><br/>Expected Fields:<br/>name: The name of the image. Mutually exclusive with family.<br/>family: The image family to use. Mutually exclusive with name.<br/>project: The project where the image is hosted.<br/><br/>For more information on creating custom images that comply with Slurm on GCP<br/>see the "Slurm on GCP Custom Images" section in docs/vm-images.md. | `map(string)` | `null` | no |
| <a name="input_instance_image_custom"></a> [instance\_image\_custom](#input\_instance\_image\_custom) | A flag that designates that the user is aware that they are requesting<br/>to use a custom and potentially incompatible image for this Slurm on<br/>GCP module.<br/><br/>If the field is set to false, only the compatible families and project<br/>names will be accepted. The deployment will fail with any other image<br/>family or name. If set to true, no checks will be done.<br/><br/>See: https://goo.gle/hpc-slurm-images | `bool` | `false` | no |
| <a name="input_instance_properties"></a> [instance\_properties](#input\_instance\_properties) | Override the instance properties. Used to test features not supported by Slurm GCP,<br/>recommended for advanced usage only.<br/>See https://cloud.google.com/compute/docs/reference/rest/v1/regionInstances/bulkInsert<br/>If any sub-field (e.g. scheduling) is set, it will override the values computed by<br/>SlurmGCP and ignoring values of provided vars. | `any` | `null` | no |
| <a name="input_instance_template"></a> [instance\_template](#input\_instance\_template) | DEPRECATED: Instance template can not be specified for compute nodes. | `string` | `null` | no |
Expand Down
17 changes: 6 additions & 11 deletions community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ locals {
}

locals {
disable_automatic_updates_metadata = var.allow_automatic_updates ? {} : { google_disable_automatic_updates = "TRUE" }

metadata = merge(
local.disable_automatic_updates_metadata,
var.metadata
)

name = substr(replace(var.name, "/[^a-z0-9]/", ""), 0, 14)

additional_disks = [
Expand Down Expand Up @@ -77,17 +70,19 @@ locals {

labels = local.labels
machine_type = terraform_data.machine_type_zone_validation.output
metadata = local.metadata
metadata = var.metadata
min_cpu_platform = var.min_cpu_platform

on_host_maintenance = var.on_host_maintenance
preemptible = var.preemptible
region = var.region
service_account = local.service_account
shielded_instance_config = var.shielded_instance_config
source_image_family = local.source_image_family # requires source_image_logic.tf
source_image_project = local.source_image_project_normalized # requires source_image_logic.tf
source_image = local.source_image # requires source_image_logic.tf

instance_image = var.instance_image
instance_image_custom = var.instance_image_custom
allow_automatic_updates = var.allow_automatic_updates

subnetwork_self_link = var.subnetwork_self_link
additional_networks = var.additional_networks
access_config = local.access_config
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,7 @@ variable "instance_image" {
see the "Slurm on GCP Custom Images" section in docs/vm-images.md.
EOD
type = map(string)
default = {
family = "slurm-gcp-6-8-hpc-rocky-linux-8"
project = "schedmd-slurm-public"
}

validation {
condition = can(coalesce(var.instance_image.project))
error_message = "In var.instance_image, the \"project\" field must be a string set to the Cloud project ID."
}

validation {
condition = can(coalesce(var.instance_image.name)) != can(coalesce(var.instance_image.family))
error_message = "In var.instance_image, exactly one of \"family\" or \"name\" fields must be set to desired image family or name."
}
default = null
}

variable "instance_image_custom" {
Expand Down
Loading
Loading