Skip to content

Conversation

@nwnt
Copy link
Contributor

@nwnt nwnt commented Sep 10, 2025

Description of your changes

As a result from the latest bug bash, we want to introduce validations for:

  • the CRP resource name, which currently only validates the length but not the characters in the name.
  • the cluster names for PickFixed policy.

I have:

  • Run make reviewable to 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.

@nwnt nwnt changed the title Add validation for CRP and PickFixed cluster names Fix: add validation for CRP and PickFixed cluster names Sep 10, 2025
@nwnt nwnt changed the title Fix: add validation for CRP and PickFixed cluster names fix: add validation for CRP and PickFixed cluster names Sep 10, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@nwnt nwnt force-pushed the add-crp-name-and-clustername-validations branch from 866b3f5 to 3cc2eaf Compare September 11, 2025 21:23
}
uniqueClusterNames := make(map[string]bool)
for _, name := range policy.ClusterNames {
nameErr := validation.IsDNS1123Label(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

actually it should be IsDNS1123Subdomain and length(name) < 64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to what you suggested now.

@nwnt nwnt force-pushed the add-crp-name-and-clustername-validations branch from 85d15f6 to a7dfad3 Compare September 12, 2025 02:55
@nwnt nwnt merged commit f2a7442 into Azure:main Sep 12, 2025
23 of 26 checks passed
@nwnt nwnt deleted the add-crp-name-and-clustername-validations branch September 12, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants