-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: add variable to exclude ai zones from available zones #2531
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @lennydong-rogo, 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 introduces a new optional variable, Highlights
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.
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 introduces a new variable exclude_ai_zones to filter out AI-specific zones from the list of available zones, which is a good fix for the issue described.
However, the changes have been applied to auto-generated files (main.tf and variables.tf) instead of their source templates in the autogen/main/ directory. This is a critical issue as the changes will be lost during the next code generation. I've left comments on the respective files with instructions on how to apply the changes to the correct template files.
I've also included a suggestion to improve the clarity of the filtering logic.
| input = var.exclude_ai_zones ? [ | ||
| for zone in data.google_compute_zones.available[0].names : zone | ||
| if !can(regex("-ai\\d+[a-z]$", zone)) | ||
| ] : data.google_compute_zones.available[0].names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is auto-generated from a template. Your changes will be overwritten. Please apply your changes to the template file autogen/main/main.tf.tmpl instead.
You should replace the random_shuffle.available_zones resource in autogen/main/main.tf.tmpl with the logic you've added.
While you're at it, I'd also suggest using regexall for better readability. The !can(regex(...)) pattern works, but it's a bit of a trick that relies on regex erroring on no match. Using length(regexall(...)) == 0 is more explicit about the intent.
Here is the suggested replacement for the random_shuffle resource in autogen/main/main.tf.tmpl:
resource "random_shuffle" "available_zones" {
count = local.zone_count == 0 ? 1 : 0
input = var.exclude_ai_zones ? [
for zone in data.google_compute_zones.available[0].names : zone
if length(regexall("-ai\\d+[a-z]$", zone)) == 0
] : data.google_compute_zones.available[0].names
result_count = 3
}| variable "exclude_ai_zones" { | ||
| description = "(Optional) Controls whether to exclude AI zones from the dynamically fetched google_compute_zones" | ||
| type = bool | ||
| default = false | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is auto-generated from a template. Your changes will be overwritten. Please add the new exclude_ai_zones variable to the template file autogen/main/variables.tf.tmpl instead. Here is the suggested addition for autogen/main/variables.tf.tmpl:
variable "exclude_ai_zones" {
description = "(Optional) Controls whether to exclude AI zones from the dynamically fetched google_compute_zones"
type = bool
default = false
}
As noted in: hashicorp/terraform-provider-google#25914
It seems the GCP API for returning compute zones began returning ai zones, as a result of the recent introduction of AI zones on 16th Jan in
us-central1This PR adds a variable to allow users to exclude AI zones when using the GKE module