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

elliminate premature termination of DNS controller logic #655

Merged
merged 1 commit into from
May 24, 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
23 changes: 23 additions & 0 deletions controllers/dnspolicy_controller_single_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/kuadrant/kuadrant-operator/api/v1alpha1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
)

Expand Down Expand Up @@ -48,6 +49,7 @@ var _ = Describe("DNSPolicy Single Cluster", func() {
Expect(k8sClient.Create(ctx, managedZone)).To(Succeed())

gateway = NewGatewayBuilder(TestGatewayName, gatewayClass.Name, testNamespace).
WithHTTPListener("foo", "foo.example.com").
WithHTTPListener(TestListenerNameOne, TestHostOne).
WithHTTPListener(TestListenerNameWildcard, TestHostWildcard).
Gateway
Expand All @@ -71,6 +73,12 @@ var _ = Describe("DNSPolicy Single Cluster", func() {
},
}
gateway.Status.Listeners = []gatewayapiv1.ListenerStatus{
{
Name: "foo",
SupportedKinds: []gatewayapiv1.RouteGroupKind{},
AttachedRoutes: 0,
Conditions: []metav1.Condition{},
},
mikenairn marked this conversation as resolved.
Show resolved Hide resolved
{
Name: TestListenerNameOne,
SupportedKinds: []gatewayapiv1.RouteGroupKind{},
Expand Down Expand Up @@ -122,6 +130,21 @@ var _ = Describe("DNSPolicy Single Cluster", func() {
})

It("should create dns records", func() {

Eventually(func(g Gomega, ctx context.Context) {

g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsPolicy), dnsPolicy)).To(Succeed())
g.Expect(dnsPolicy.Status.Conditions).To(
ContainElement(MatchFields(IgnoreExtras, Fields{
"Type": Equal(string(kuadrant.PolicyConditionEnforced)),
"Status": Equal(metav1.ConditionFalse),
"Reason": Equal(string(kuadrant.PolicyReasonEnforced)),
"Message": Equal("DNSPolicy has been partially enforced"),
})),
)

}, TestTimeoutMedium, TestRetryIntervalMedium, ctx).Should(Succeed())

Eventually(func(g Gomega, ctx context.Context) {
recordList := &kuadrantdnsv1alpha1.DNSRecordList{}
err := k8sClient.List(ctx, recordList, &client.ListOptions{Namespace: testNamespace})
Expand Down
2 changes: 1 addition & 1 deletion controllers/dnspolicy_dnsrecords.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
if err := r.dnsHelper.deleteDNSRecordForListener(ctx, gatewayWrapper, listener); client.IgnoreNotFound(err) != nil {
return fmt.Errorf("failed to delete dns record for listener %s : %w", listener.Name, err)
}
return nil
continue

Check warning on line 93 in controllers/dnspolicy_dnsrecords.go

View check run for this annotation

Codecov / codecov/patch

controllers/dnspolicy_dnsrecords.go#L93

Added line #L93 was not covered by tests
}

dnsRecord, err := r.desiredDNSRecord(gatewayWrapper, dnsPolicy, listener, listenerGateways, mz)
Expand Down
Loading