Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CEL rule to validate field immutability for direct Compute resources #3193

Closed
wants to merge 1 commit into from

Conversation

gemmahou
Copy link
Collaborator

Change description

b/377531379

Checked all three direct compute resources(forwarding rule, firewall policy rule, target tcp proxy), added CEL rule on the immutable and required fields, following https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/master/docs/develop-resources/api-conventions/validations.md#option-2

Note: We haven't turned on direct reconciliation for those compute resources yet, instead, we use the "alpha.cnrm.cloud.google.com/reconciler: "direct"" annotation to opt-in. So they are still protected by the immutable webhook for now.

Tests you have done

  • Run make ready-pr to ensure this PR is ready for review.
  • Perform necessary E2E testing for changed resources.

Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cheftako for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@@ -102,12 +102,14 @@ type ComputeFirewallPolicyRuleSpec struct {
// +optional
EnableLogging *bool `json:"enableLogging,omitempty"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="the field is immutable"
Copy link
Collaborator

Choose a reason for hiding this comment

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

These fields are related to identity. We do not need the immutable check, but set this as required.

Copy link
Collaborator Author

@gemmahou gemmahou Nov 19, 2024

Choose a reason for hiding this comment

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

They are required fields now. If no immutable check is needed, we can close this PR.

@gemmahou
Copy link
Collaborator Author

No immutability checks on fields are needed.

@gemmahou gemmahou closed this Nov 19, 2024
@gemmahou gemmahou deleted the immutable-flag branch November 19, 2024 20:51
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.

3 participants