fix: add validation for CRP and PickFixed cluster names#1190
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds validation improvements for ClusterResourcePlacement (CRP) names and cluster names in PickFixed policies. The changes address issues found during bug bash testing by implementing proper DNS validation rules instead of simple length checks.
- Enhanced CRP name validation to use DNS-1035 label validation instead of just length validation
- Added validation for cluster names in PickFixed policies to ensure they follow DNS-1123 label format
- Updated test cases to reflect the new validation error messages and added coverage for invalid cluster names
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/utils/validator/clusterresourceplacement.go | Updated validation logic for CRP names and PickFixed cluster names with proper DNS validation |
| pkg/utils/validator/clusterresourceplacement_test.go | Updated test error messages and added new test case for invalid cluster names validation |
Signed-off-by: Nont <nont@duck.com>
nwnt
force-pushed
the
add-crp-name-and-clustername-validations
branch
from
September 11, 2025 21:23
866b3f5 to
3cc2eaf
Compare
| } | ||
| uniqueClusterNames := make(map[string]bool) | ||
| for _, name := range policy.ClusterNames { | ||
| nameErr := validation.IsDNS1123Label(name) |
Contributor
There was a problem hiding this comment.
actually it should be IsDNS1123Subdomain and length(name) < 64
Contributor
Author
There was a problem hiding this comment.
changed to what you suggested now.
Signed-off-by: Nont <nont@duck.com>
nwnt
force-pushed
the
add-crp-name-and-clustername-validations
branch
from
September 12, 2025 02:55
85d15f6 to
a7dfad3
Compare
ryanzhang-oss
approved these changes
Sep 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
As a result from the latest bug bash, we want to introduce validations for:
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Run unit tests and add new test cases for negative validation scenarios.