Skip to content

Conversation

@justin0u0
Copy link

This PR fixes an issue where the is_immutable configuration was not being applied to nested fields (e.g. HealthCheckConfig.Type).

Verified using route53-controller. The generator now correctly applies validation markers to immutable nested fields in HealthCheckConfig, resulting in the correct x-kubernetes-validations in the output CRD.

diff --git a/apis/v1alpha1/types.go b/apis/v1alpha1/types.go
index afc17d0..e25f221 100644
--- a/apis/v1alpha1/types.go
+++ b/apis/v1alpha1/types.go
@@ -148,14 +148,18 @@ type HealthCheckConfig struct {
 	IPAddress                    *string          `json:"ipAddress,omitempty"`
 	InsufficientDataHealthStatus *string          `json:"insufficientDataHealthStatus,omitempty"`
 	Inverted                     *bool            `json:"inverted,omitempty"`
-	MeasureLatency               *bool            `json:"measureLatency,omitempty"`
-	Port                         *int64           `json:"port,omitempty"`
-	Regions                      []*string        `json:"regions,omitempty"`
-	RequestInterval              *int64           `json:"requestInterval,omitempty"`
-	ResourcePath                 *string          `json:"resourcePath,omitempty"`
-	RoutingControlARN            *string          `json:"routingControlARN,omitempty"`
-	SearchString                 *string          `json:"searchString,omitempty"`
-	Type                         *string          `json:"type,omitempty"`
+	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+	MeasureLatency *bool     `json:"measureLatency,omitempty"`
+	Port           *int64    `json:"port,omitempty"`
+	Regions        []*string `json:"regions,omitempty"`
+	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+	RequestInterval *int64  `json:"requestInterval,omitempty"`
+	ResourcePath    *string `json:"resourcePath,omitempty"`
+	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+	RoutingControlARN *string `json:"routingControlARN,omitempty"`
+	SearchString      *string `json:"searchString,omitempty"`
+	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+	Type *string `json:"type,omitempty"`
 }
 
 // A complex type that contains the last failure reason as reported by one Amazon
diff --git a/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml b/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml
index ea5e040..d55c176 100644
--- a/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml
+++ b/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml
@@ -82,6 +82,9 @@ spec:
                     type: string
                   measureLatency:
                     type: boolean
+                    x-kubernetes-validations:
+                    - message: Value is immutable once set
+                      rule: self == oldSelf
                   port:
                     format: int64
                     type: integer
@@ -92,14 +95,23 @@ spec:
                   requestInterval:
                     format: int64
                     type: integer
+                    x-kubernetes-validations:
+                    - message: Value is immutable once set
+                      rule: self == oldSelf
                   resourcePath:
                     type: string
                   routingControlARN:
                     type: string
+                    x-kubernetes-validations:
+                    - message: Value is immutable once set
+                      rule: self == oldSelf
                   searchString:
                     type: string
                   type:
                     type: string
+                    x-kubernetes-validations:
+                    - message: Value is immutable once set
+                      rule: self == oldSelf
                 type: object
               tags:
                 description: |-

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and jlbutler December 4, 2025 06:09
@ack-prow
Copy link

ack-prow bot commented Dec 4, 2025

Hi @justin0u0. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ack-prow ack-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 4, 2025
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thank you @justin0u0 !

@ack-prow
Copy link

ack-prow bot commented Dec 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, justin0u0

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the approved label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants