Fix missing region#4113
Conversation
Fixes error (when using multivpc networks and provider overrides):
Error: cannot determine self_link for subnetwork "***": Cannot determine region: set in this resource, or set provider-level 'region' or 'zone'.
with module.slurm_controller.module.slurm_nodeset_template["debugnodeset"].module.instance_template.google_compute_instance_template.tpl,
on modules/embedded/community/modules/internal/slurm-gcp/internal_instance_template/main.tf line 70, in resource "google_compute_instance_template" "tpl":
70: resource "google_compute_instance_template" "tpl" {
There was a problem hiding this comment.
Hello @wiktorn, 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!
Summary of Changes
This pull request addresses an issue where the region could not be determined when using multi-VPC networks and provider overrides. The fix involves ensuring that the region is always explicitly provided to the google_compute_instance_template resource. This is achieved by making the region variable mandatory in the instance_template and internal_instance_template modules and passing the region value from the partition.tf module.
Highlights
- Bug Fix: Fixes the 'cannot determine self_link for subnetwork' error when using multi-VPC networks and provider overrides.
- Variable Validation: Adds validation to the
regionvariable in theinstance_templateandinternal_instance_templatemodules to prevent similar errors in the future. - Module Modification: Modifies the
partition.tfmodule to pass theregionvalue to theslurm_nodeset_templatemodule.
Changelog
- community/modules/internal/slurm-gcp/instance_template/README.md
- Updates the documentation to reflect that the
regioninput variable is now required.
- Updates the documentation to reflect that the
- community/modules/internal/slurm-gcp/instance_template/variables.tf
- Changes the
regionvariable to be non-nullable, enforcing that a value must be provided.
- Changes the
- community/modules/internal/slurm-gcp/internal_instance_template/README.md
- Updates the documentation to reflect that the
regioninput variable is now required.
- Updates the documentation to reflect that the
- community/modules/internal/slurm-gcp/internal_instance_template/variables.tf
- Changes the
regionvariable to be non-nullable, enforcing that a value must be provided.
- Changes the
- community/modules/scheduler/schedmd-slurm-gcp-v6-controller/partition.tf
- Passes the
regionvalue from the partition configuration to theslurm_nodeset_templatemodule.
- Passes the
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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.
A region's need,
No longer can it be freed,
Must be defined now.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request aims to fix an error related to determining the region for instance templates, particularly in multi-VPC scenarios. The approach of making the region variable non-nullable in the instance_template and internal_instance_template modules is a good step towards ensuring a region is always defined. The updates to the README files correctly reflect these changes.
However, there's a critical point in how the region is supplied from the schedmd-slurm-gcp-v6-controller module's nodeset configuration that needs addressing.
Summary of Findings
- Potential Null Value for Non-Nullable Region Variable: In
community/modules/scheduler/schedmd-slurm-gcp-v6-controller/partition.tf, theregionforslurm_nodeset_templateis set toeach.value.region. However,each.value.regioncan benullif not specified in thenodesetconfiguration, as it's an optional field. Thisnullvalue would then be passed to theslurm_nodeset_templatemodule whereregionis defined withnullable = false, causing a Terraform error. This needs to be addressed, for example, by usingcoalesce(each.value.region, var.region).
Merge Readiness
The pull request makes good progress in addressing the missing region issue by enforcing the region requirement in the template modules. However, there is a critical issue identified in community/modules/scheduler/schedmd-slurm-gcp-v6-controller/partition.tf where a null value could be passed for the region, leading to a Terraform error. This critical issue should be addressed before merging. I am not authorized to approve pull requests, so please ensure further review and approval once the suggested changes are made.
|
/gcbrun |
Fixes error (when using multivpc networks and provider overrides): Error: cannot determine self_link for subnetwork "***":
This is a better way to fix this than #3046
Added a validation to variables to prevent this types of errors in other places / future.
This error is present, if provider_overrides are present in the blueprint, such as:
Submission Checklist
NOTE: Community submissions can take up to 2 weeks to be reviewed.
Please take the following actions before submitting this pull request.