Remove Terraform Validation For Machine Type#5173
Remove Terraform Validation For Machine Type#5173LAVEEN merged 3 commits intoGoogleCloudPlatform:developfrom
Conversation
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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)
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
}
}
}
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.