Skip to content

feat(validations): Add early range based pattern validation#5115

Merged
AdarshK15 merged 9 commits intoGoogleCloudPlatform:developfrom
AdarshK15:pattern-validators
Jan 29, 2026
Merged

feat(validations): Add early range based pattern validation#5115
AdarshK15 merged 9 commits intoGoogleCloudPlatform:developfrom
AdarshK15:pattern-validators

Conversation

@AdarshK15
Copy link
Member

@AdarshK15 AdarshK15 commented Jan 16, 2026

Summary

This PR introduces the range validator to the module-scoped validation framework and applies it to several core and community modules. By moving numeric and length validation into metadata.yaml files, these constraints are caught earlier in the deployment lifecycle.

Key Changes

New RangeValidator: Implements a generic validator to enforce numeric boundaries or length constraints on module settings.

Functionality:
    - Numeric Bounds: Supports min and max checks for integer values.
    - Length Handling: Includes a length_check flag to validate the size of a list; instead of the raw value.

Changes:
Added range validation for the following modules:

    - compute/gke-nodeset: Validates count of entries in network_storage and filestore_id.
    - compute/mig: Ensures at least one version is provided.
    - scheduler/htcondor-access-point: Limits the number of zones.
    - scheduler/schedmd-slurm-gcp-v6-controller: Limits the number of static IPs to a maximum of 1.
    - compute/gke-node-pool: Enforces valid upgrade settings count ranges.
    - internal/slurm-gcp/nodeset_tpu: Enforces valid node count ranges.
    - network/multivpc: Enforces a network count between 2 and 8.
    - file-system/filestore: Enforces minimum capacity requirements.

Added regex validation for the following modules:
    - database/slurm-cloudsql-federation: Validates network_id to ensure the correct path format.
    - modules/file-system/filestore: Validates network_id to ensure the correct path format.
    - modules/file-system/parallelstore: Validates network_id to ensure the correct path format.
    - modules/scheduler/gke-cluster: Validates network_id to ensure the correct path format.
    - database/slurm-cloudsql-federation: Validates network_id to ensure the correct path format.
    - compute/notebook: Validates mount_runner.args to ensure 5 elements.

Testing

Added unit tests covering numeric ranges, list of ints, and also list length validation scenarios.

Documentation

Updated docs/blueprint-validation.md to include usage instructions and examples for the new validator.

@AdarshK15 AdarshK15 added the release-chore To not include into release notes label Jan 16, 2026
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 introduces a new range validator, which is a valuable addition for validating blueprint configurations. The implementation is well-structured and includes a beneficial refactoring of existing validators for better consistency. My review has identified two points for improvement: a minor typo in a user-facing error message and, more significantly, the absence of unit tests for the new RangeValidator. Adding comprehensive tests is crucial to ensure the feature's correctness and long-term maintainability, as per the project's contribution guidelines.

@AdarshK15
Copy link
Member Author

/gemini summary

@AdarshK15
Copy link
Member Author

/gemini review

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request significantly enhances the module-scoped validation framework by introducing a new RangeValidator. This validator allows for the early enforcement of numeric and length constraints directly within metadata.yaml files, improving the robustness and reliability of module configurations. The changes include the implementation of the validator, its application across various modules, and comprehensive testing and documentation.

Highlights

  • New Range Validator: A generic RangeValidator has been introduced to enforce numeric boundaries (min/max) or length constraints on module settings.
  • Flexible Validation Functionality: The RangeValidator supports validating individual numeric values, the number of elements in a list, or the count of segments in a delimited string (with an optional delimiter).
  • Module-Scoped Application: Range validation has been applied to several core and community modules, including gke-nodeset, mig, notebook, htcondor-access-point, schedmd-slurm-gcp-v6-controller, slurm-gcp/nodeset_tpu, multivpc, and filestore.
  • Early Validation: By defining these constraints directly within metadata.yaml files, validation occurs earlier in the deployment lifecycle, catching issues sooner.
  • Regex Validation for Network ID: An existing regex validator was applied to the database/slurm-cloudsql-federation module to ensure the network_id adheres to a specific path format.
  • Comprehensive Testing: Unit tests have been added for the RangeValidator, covering various scenarios such as numeric ranges, list lengths, and delimited string segment counts.
  • Documentation Update: The docs/blueprint-validation.md file has been updated to include usage instructions and examples for the new RangeValidator.
Changelog
  • community/modules/compute/gke-nodeset/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to ensure 'network_storage' and 'filestore_id' lists contain exactly one element.
  • community/modules/compute/mig/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to ensure the 'versions' list contains at least one element.
  • community/modules/compute/notebook/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to ensure 'mount_runner.args' contains exactly 5 space-separated elements.
  • community/modules/database/slurm-cloudsql-federation/metadata.yaml
    • Updated copyright year to 2026.
    • Added regex validation for 'network_id' to enforce a specific path format.
  • community/modules/internal/slurm-gcp/nodeset_tpu/metadata.yaml
    • Added new metadata file with range validation for 'node_count_static' and 'node_count_dynamic_max' to be at least 0.
  • community/modules/scheduler/htcondor-access-point/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to limit the 'zones' list to at most 2 elements.
  • community/modules/scheduler/schedmd-slurm-gcp-v6-controller/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to limit the 'static_ips' list to at most 1 element.
  • docs/blueprint-validation.md
    • Added a new section detailing the 'Range Validator', including its purpose, functionality, and an example definition.
  • modules/file-system/filestore/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to ensure 'size_gb' is at least 1024 GiB.
  • modules/network/multivpc/metadata.yaml
    • Updated copyright year to 2026.
    • Added range validation to ensure 'network_count' is between 2 and 8.
  • pkg/validators/metadata_validator_helpers.go
    • Updated copyright year to 2026.
    • Introduced a new helper function 'parseIntInput' for safely parsing integer values from input maps.
  • pkg/validators/metadata_validators.go
    • Updated copyright year to 2026.
    • Implemented the 'RangeValidator' struct and its 'Validate' method, including 'checkBounds' and 'validateTarget' helper functions.
  • pkg/validators/metadata_validators_test.go
    • Updated copyright year to 2026.
    • Added comprehensive unit tests for 'RangeValidator', covering numeric value validation and list/segment length validation.
  • pkg/validators/registry.go
    • Updated copyright year to 2026.
    • Registered the new 'RangeValidator' in the global validator registry.
Activity
  • gemini-code-assist[bot] provided an initial summary of the changes in the pull request.
  • gemini-code-assist[bot] requested unit tests for the newly introduced RangeValidator in pkg/validators/metadata_validators_test.go, citing repository style guidelines.
  • gemini-code-assist[bot] noted a potential typo or leftover test string "abc" in an error message, advising removal for clarity and professionalism.
  • AdarshK15 requested a new summary from gemini-code-assist[bot].

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 introduces a valuable range validator, significantly enhancing the validation framework. The implementation is clean, and it's great to see it immediately applied to various modules, complete with unit tests and documentation. I have a few suggestions to improve the robustness of the new validator.

@AdarshK15 AdarshK15 marked this pull request as ready for review January 20, 2026 12:23
@AdarshK15 AdarshK15 requested review from a team and samskillman as code owners January 20, 2026 12:23
@saara-tyagi27 saara-tyagi27 self-requested a review January 21, 2026 09:57
@AdarshK15 AdarshK15 requested a review from LAVEEN January 27, 2026 07:09
Copy link
Contributor

@LAVEEN LAVEEN left a comment

Choose a reason for hiding this comment

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

LGTM

@AdarshK15 AdarshK15 merged commit 7ec39e9 into GoogleCloudPlatform:develop Jan 29, 2026
67 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-chore To not include into release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants