Skip to content

Commit

Permalink
Check if specific-reservation-required for reservation in slurm-gcp v6
Browse files Browse the repository at this point in the history
  • Loading branch information
harshthakkar01 committed May 21, 2024
1 parent 499b77d commit 83234bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ 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) | >= 3.83 |
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 5.11 |

## Providers

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

## Modules

Expand All @@ -149,6 +149,7 @@ No modules.
|------|------|
| [google_compute_default_service_account.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_default_service_account) | data source |
| [google_compute_image.slurm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source |
| [google_compute_reservation.reservation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_reservation) | data source |

## Inputs

Expand Down
25 changes: 25 additions & 0 deletions community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,28 @@ locals {
data "google_compute_default_service_account" "default" {
project = var.project_id
}

# tflint-ignore: terraform_unused_declarations
data "google_compute_reservation" "reservation" {
count = var.reservation_name != "" ? 1 : 0
name = var.reservation_name
project = var.project_id
zone = var.zone

lifecycle {
postcondition {
condition = self.self_link != null
error_message = "couldn't find the reservation ${var.reservation_name}}"
}

postcondition {
condition = coalesce(self.specific_reservation_required, true)
error_message = <<EOT
your reservation has to be specific,
see https://cloud.google.com/compute/docs/instances/reservations-overview#how-reservations-work
for more information. if it's intentionally automatic, don't specify
it in the blueprint.
EOT
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.83"
version = ">= 5.11"
}
}
provider_meta "google" {
Expand Down

0 comments on commit 83234bd

Please sign in to comment.