Skip to content

Commit

Permalink
elliminate premature termination of DNS controller logic
Browse files Browse the repository at this point in the history
  • Loading branch information
maksymvavilov committed May 24, 2024
1 parent ad84ac6 commit 54cb7ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
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{},
},
{
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 @@ func (r *DNSPolicyReconciler) reconcileGatewayDNSRecords(ctx context.Context, gw
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

0 comments on commit 54cb7ce

Please sign in to comment.