Skip to content

Add reservation name check validator#5185

Merged
saara-tyagi27 merged 4 commits into
GoogleCloudPlatform:developfrom
saara-tyagi27:validate-reservation-name-check
Feb 12, 2026
Merged

Add reservation name check validator#5185
saara-tyagi27 merged 4 commits into
GoogleCloudPlatform:developfrom
saara-tyagi27:validate-reservation-name-check

Conversation

@saara-tyagi27

Copy link
Copy Markdown
Contributor

Summary

This PR adds a new validator, test_reservation_exists, to ensure that Google Cloud reservations specified in a blueprint are valid and available. It supports both local and shared reservations and provides smart diagnostic hints for zone mismatches.

Key Changes

  • Reservation Validation: Checks for the existence of a reservation in the specified project and zone using the Compute Engine API.
  • Shared Reservation Support: Automatically detects and parses full resource paths (projects/{project}/reservations/{name}) to validate reservations across different projects.
  • Broad Naming Detection: Dynamically attaches the validator to any blueprint variable matching the pattern reservation or reservation_name (including prefixed versions)
  • Smart Diagnostics: If a reservation is missing in the target zone but exists elsewhere in the project, the validator provides a helpful "Hint" suggesting the correct zone.
  • Automatic Registration: Dynamically attaches the validator to any blueprint variable matching the pattern *(.)_reservation_name.

To wrap up your PR, here is a high-level summary of the testing performed, structured to demonstrate the robustness of the new validator.


Testing Summary

  • Positive Paths: Verified local names, full resource paths, and $(vars) expansion.
  • Error Handling: Confirmed clear messaging for zone mismatches.
  • Edge Cases: Verified that empty values are skipped (opt-out) and malformed paths are handled gracefully.

@saara-tyagi27 saara-tyagi27 added the release-improvements Added to release notes under the "Improvements" heading. label Feb 4, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @saara-tyagi27, 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 significantly enhances the blueprint validation capabilities by introducing a robust mechanism to verify the existence and availability of Google Cloud reservations. It intelligently handles both local and shared reservations, providing detailed diagnostics and helpful hints when reservations are found in unexpected zones. This ensures that blueprints are configured with valid reservation references, preventing deployment failures related to non-existent or misplaced reservations.

Highlights

  • New Reservation Validator: Introduced test_reservation_exists to validate Google Cloud reservations in blueprints, ensuring they are valid and available.
  • Shared Reservation Support: The validator now correctly parses and validates reservations specified with full resource paths (e.g., projects/{project}/reservations/{name}), enabling support for shared reservations across different projects.
  • Intelligent Zone Mismatch Diagnostics: If a reservation is not found in the specified zone but exists in other zones within the same project, the validator provides a helpful hint suggesting the correct zones, improving user experience and debugging.
  • Dynamic Validator Attachment: The test_reservation_exists validator is automatically applied to any blueprint variable whose name matches patterns like reservation or reservation_name (including prefixed versions like my_reservation_name).
Changelog
  • pkg/validators/cloud.go
    • Added regexp import for pattern matching.
    • Defined reservationNameRegex and resKeyRegex for parsing reservation paths and identifying reservation-related variables.
    • Implemented findReservationInOtherZones to search for a given reservation across all zones within a project.
    • Introduced TestReservationExists function, which performs the core reservation validation logic, including direct checks, access checks, diagnostic searches for zone mismatches, and handling of shared reservation paths.
    • Added testReservationExists function to integrate the new validator into the existing blueprint validation framework.
  • pkg/validators/validators.go
    • Declared testReservationExistsName constant.
    • Registered the testReservationExists function in the implementations map, making it available for use.
    • Modified the defaults function to automatically attach the testReservationExists validator to blueprint variables that match the resKeyRegex pattern (e.g., reservation_name, my_reservation).
  • pkg/validators/validators_test.go
    • Updated TestDefaultValidators with new test cases to verify that the testReservationExists validator is correctly added to blueprints containing reservation_name or my_reservation variables.
  • tools/validate_configs/validate_configs.sh
    • Added test_reservation_exists to the VALIDATORS_TO_SKIP list in the run_test function, preventing it from being run during certain integration tests.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request since its creation.
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.

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

Copy link
Copy Markdown
Contributor

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 validator, test_reservation_exists, to verify Google Cloud reservations. The implementation is robust, handling both local and shared reservations, and provides helpful diagnostic hints for zone mismatches. The validator is also automatically applied to blueprint variables that match a reservation name pattern, which is a great usability feature. My review found one minor issue with a redundant warning message, for which I've provided a suggestion to improve clarity.

Comment thread pkg/validators/cloud.go Outdated
@saara-tyagi27 saara-tyagi27 marked this pull request as ready for review February 5, 2026 05:25
@saara-tyagi27 saara-tyagi27 requested review from a team and samskillman as code owners February 5, 2026 05:25
@saara-tyagi27 saara-tyagi27 added release-key-new-features Added to release notes under the "Key New Features" heading. and removed release-key-new-features Added to release notes under the "Key New Features" heading. labels Feb 5, 2026
Comment thread pkg/validators/cloud.go Outdated
Comment thread pkg/validators/cloud.go Outdated
@saara-tyagi27 saara-tyagi27 merged commit ba5699b into GoogleCloudPlatform:develop Feb 12, 2026
13 of 79 checks passed
@saara-tyagi27 saara-tyagi27 deleted the validate-reservation-name-check branch February 12, 2026 06:48
kadupoornima pushed a commit to kadupoornima/cluster-toolkit that referenced this pull request Feb 17, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants