Skip to content

Remove Terraform Validation For Machine Type#5173

Merged
LAVEEN merged 3 commits intoGoogleCloudPlatform:developfrom
LAVEEN:rmtfvalidation
Feb 5, 2026
Merged

Remove Terraform Validation For Machine Type#5173
LAVEEN merged 3 commits intoGoogleCloudPlatform:developfrom
LAVEEN:rmtfvalidation

Conversation

@LAVEEN
Copy link
Contributor

@LAVEEN LAVEEN commented Feb 3, 2026

Remove the Terraform Validation for machine type as custom machine types are not supported, so this validation is covered and moved as part of API validation

Submission Checklist

NOTE: Community submissions can take up to 2 weeks to be reviewed.

Please take the following actions before submitting this pull request.

  • Fork your PR branch from the Toolkit "develop" branch (not main)
  • Test all changes with pre-commit in a local branch #
  • Confirm that "make tests" passes all tests
  • Add or modify unit tests to cover code changes
  • Ensure that unit test coverage remains above 80%
  • Update all applicable documentation
  • Follow Cluster Toolkit Contribution guidelines #

@LAVEEN LAVEEN requested review from a team and samskillman as code owners February 3, 2026 09:03
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @LAVEEN, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines the schedmd-slurm-gcp-v6-nodeset module by removing a pre-existing Terraform validation. The validation previously ensured that a user-defined machine type was available across the specified Google Cloud zones. By removing this check, the module's deployment process is made more flexible, potentially allowing for machine types that might not be universally available across all zones but are intended for specific use cases.

Highlights

  • Removed Machine Type Validation: The pull request eliminates the Terraform validation that checked if a specified machine type was available in any of the configured zones.
  • Configuration Simplification: Related data sources (google_compute_machine_types) and local variables used for this validation have been removed, simplifying the module's configuration.
Changelog
  • community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf
    • Removed the data "google_compute_machine_types" "machine_types_by_zone" block.
    • Removed the locals block zones_with_machine_type.
    • Removed the resource "terraform_data" "machine_type_zone_validation" block, which contained the precondition for machine type availability.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the Terraform validation for machine type availability in specified zones. While this change correctly addresses an issue where the validation fails for custom machine types, it also removes a helpful fast-fail mechanism for users who specify an invalid or unavailable standard machine type. I've suggested an improvement to the validation logic to support custom machine types while retaining the validation for standard ones.

Additionally, the pull request description is missing an explanation for the change, which is a violation of the repository's contribution guidelines (rule 43). Please update the description to explain why this validation is being removed.

I am having trouble creating individual review comments. Click here to see my feedback.

community/modules/compute/schedmd-slurm-gcp-v6-nodeset/main.tf (208-232)

medium

Instead of completely removing this validation, consider modifying it to support custom machine types. The current validation is useful for providing a fast-fail with a clear error message for standard machine types, but it fails for custom machine types as they are not returned by the google_compute_machine_types data source.

You could modify the validation to bypass the check for custom machine types. This would preserve the helpful validation for standard machine types while allowing the use of custom ones. The Google Cloud provider will validate the custom machine type at resource creation time.

data "google_compute_machine_types" "machine_types_by_zone" {
  for_each = can(regex("custom-", var.machine_type)) ? toset([]) : local.zones
  project  = var.project_id
  filter   = format("name = \"%s\"", var.machine_type)
  zone     = each.value
}

locals {
  machine_types_by_zone   = data.google_compute_machine_types.machine_types_by_zone
  zones_with_machine_type = [for k, v in local.machine_types_by_zone : k if length(v.machine_types) > 0]
}

resource "terraform_data" "machine_type_zone_validation" {
  input = var.machine_type
  lifecycle {
    precondition {
      condition     = can(regex("custom-", var.machine_type)) || length(local.zones_with_machine_type) > 0
      error_message = <<EOT
        machine type ${var.machine_type} is not available in any of the zones ${jsonencode(local.zones)}. To list zones in which it is available, run:

        gcloud compute machine-types list --filter="name=${var.machine_type}"
        EOT
    }
  }
}

@LAVEEN LAVEEN added the release-improvements Added to release notes under the "Improvements" heading. label Feb 3, 2026
@LAVEEN LAVEEN marked this pull request as draft February 3, 2026 09:10
@LAVEEN LAVEEN added the release-module-improvements Added to release notes under the "Module Improvements" heading. label Feb 3, 2026
@LAVEEN LAVEEN marked this pull request as ready for review February 3, 2026 18:36
@saara-tyagi27 saara-tyagi27 self-requested a review February 5, 2026 06:26
@LAVEEN LAVEEN merged commit f6c8775 into GoogleCloudPlatform:develop Feb 5, 2026
80 of 83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-improvements Added to release notes under the "Improvements" heading. release-module-improvements Added to release notes under the "Module Improvements" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants