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

update dns policy to have immutable strategy field #498

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/v1alpha1/dnspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type DNSPolicySpec struct {

// +required
// +kubebuilder:validation:Enum=simple;loadbalanced
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="RoutingStrategy is immutable"
// +kubebuilder:default=loadbalanced
RoutingStrategy RoutingStrategy `json:"routingStrategy"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/kuadrant-operator:latest
createdAt: "2024-03-12T12:20:22Z"
createdAt: "2024-03-20T12:29:04Z"
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/Kuadrant/kuadrant-operator
Expand Down
3 changes: 3 additions & 0 deletions bundle/manifests/kuadrant.io_dnspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ spec:
- simple
- loadbalanced
type: string
x-kubernetes-validations:
- message: RoutingStrategy is immutable
rule: self == oldSelf
targetRef:
description: |-
PolicyTargetReference identifies an API object to apply a direct or
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/kuadrant.io_dnspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ spec:
- simple
- loadbalanced
type: string
x-kubernetes-validations:
- message: RoutingStrategy is immutable
rule: self == oldSelf
targetRef:
description: |-
PolicyTargetReference identifies an API object to apply a direct or
Expand Down
11 changes: 11 additions & 0 deletions controllers/dnspolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ var _ = Describe("DNSPolicy controller", func() {
}, TestTimeoutMedium, time.Second).Should(Succeed())
})

It("should not allow changing routing strategy", func() {
Eventually(func(g Gomega) {
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsPolicy), dnsPolicy)
g.Expect(err).NotTo(HaveOccurred())
dnsPolicy.Spec.RoutingStrategy = v1alpha1.LoadBalancedRoutingStrategy
err = k8sClient.Update(ctx, dnsPolicy)
g.Expect(err).To(HaveOccurred())
g.Expect(err).To(MatchError(ContainSubstring("RoutingStrategy is immutable")))
}, TestTimeoutMedium, time.Second).Should(Succeed())
})

It("should not have any health check records created", func() {
// create a health check with the labels for the dnspolicy and the gateway name and namespace that would be expected in a valid target scenario
// this one should get deleted if the gateway is invalid policy ref
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/dnspolicy.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| `targetRef` | [Gateway API PolicyTargetReference](https://gateway-api.sigs.k8s.io/geps/gep-713/?h=policytargetreference#policy-targetref-api) | Yes | Reference to a Kuberentes resource that the policy attaches to |
| `healthCheck` | [HealthCheckSpec](#healthcheckspec) | No | HealthCheck spec |
| `loadBalancing` | [LoadBalancingSpec](#loadbalancingspec) | No | LoadBancking Spec |
| `routingStrategy` | String | Yes | Routing Strategy to use, one of "simple" or "loadbalacned" |
| `routingStrategy` | String (immutable) | Yes | **Immutable!** Routing Strategy to use, one of "simple" or "loadbalacned" |

## HealthCheckSpec

Expand Down
Loading