Skip to content

Commit 0f99be1

Browse files
danehanssam-heilbronnfuden
authored
Adds Support for TCPRoute Status (#10387)
Signed-off-by: Daneyon Hansen <[email protected]> Co-authored-by: Sam Heilbron <[email protected]> Co-authored-by: Nathan Fudenberg <[email protected]>
1 parent 7dd0bee commit 0f99be1

File tree

12 files changed

+396
-134
lines changed

12 files changed

+396
-134
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
changelog:
2+
- type: FIX
3+
issueLink: https://github.com/k8sgateway/k8sgateway/issues/10365
4+
resolvesIssue: true
5+
description: >-
6+
Adds support for setting TCPRoute status and managing status conditions.

projects/gateway2/proxy_syncer/proxy_syncer_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func TestIsRouteStatusEqual(t *testing.T) {
6969
Namespace: ptr.To[gwv1.Namespace](gwv1.Namespace("default")),
7070
},
7171
},
72+
{
73+
ParentRef: gwv1.ParentReference{
74+
Group: ptr.To[gwv1.Group](gwv1.Group(wellknown.GatewayGroup)),
75+
Kind: ptr.To[gwv1.Kind](gwv1.Kind(wellknown.TCPRouteKind)),
76+
Name: "parent",
77+
Namespace: ptr.To[gwv1.Namespace](gwv1.Namespace("default")),
78+
},
79+
},
7280
},
7381
}
7482
// Same as status1
@@ -82,6 +90,14 @@ func TestIsRouteStatusEqual(t *testing.T) {
8290
Namespace: ptr.To[gwv1.Namespace](gwv1.Namespace("default")),
8391
},
8492
},
93+
{
94+
ParentRef: gwv1.ParentReference{
95+
Group: ptr.To[gwv1.Group](gwv1.Group(wellknown.GatewayGroup)),
96+
Kind: ptr.To[gwv1.Kind](gwv1.Kind(wellknown.TCPRouteKind)),
97+
Name: "parent",
98+
Namespace: ptr.To[gwv1.Namespace](gwv1.Namespace("default")),
99+
},
100+
},
85101
},
86102
}
87103
// Different from status1
@@ -95,6 +111,14 @@ func TestIsRouteStatusEqual(t *testing.T) {
95111
Namespace: ptr.To[gwv1.Namespace](gwv1.Namespace("my-other-ns")),
96112
},
97113
},
114+
{
115+
ParentRef: gwv1.ParentReference{
116+
Group: ptr.To[gwv1.Group](gwv1.Group(wellknown.GatewayGroup)),
117+
Kind: ptr.To[gwv1.Kind](gwv1.Kind(wellknown.TCPRouteKind)),
118+
Name: "parent",
119+
Namespace: ptr.To[gwv1.Namespace](gwv1.Namespace("my-other-ns")),
120+
},
121+
},
98122
},
99123
}
100124

projects/gateway2/query/query_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"github.com/solo-io/gloo/projects/gateway2/wellknown"
2424
)
2525

26+
//go:generate go run github.com/golang/mock/mockgen -destination mocks/mock_queries.go -package mocks github.com/solo-io/gloo/projects/gateway2/query GatewayQueries
27+
2628
var _ = Describe("Query", func() {
2729
var (
2830
scheme *runtime.Scheme

projects/gateway2/translator/gateway_translator_test.go

+68-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
"k8s.io/apimachinery/pkg/types"
1313
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
14+
gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
1415

1516
"github.com/solo-io/gloo/projects/gateway2/reports"
1617
)
@@ -115,7 +116,7 @@ var _ = DescribeTable("Basic GatewayTranslator Tests",
115116
Name: "example-gateway",
116117
}}),
117118
Entry(
118-
"route with missing backend reports correctly",
119+
"httproute with missing backend reports correctly",
119120
translatorTestCase{
120121
inputFile: "http-routing-missing-backend",
121122
outputFile: "http-routing-missing-backend.yaml",
@@ -139,7 +140,7 @@ var _ = DescribeTable("Basic GatewayTranslator Tests",
139140
},
140141
}),
141142
Entry(
142-
"route with invalid backend reports correctly",
143+
"httproute with invalid backend reports correctly",
143144
translatorTestCase{
144145
inputFile: "http-routing-invalid-backend",
145146
outputFile: "http-routing-invalid-backend.yaml",
@@ -181,6 +182,71 @@ var _ = DescribeTable("Basic GatewayTranslator Tests",
181182
Namespace: "default",
182183
Name: "example-gateway",
183184
},
185+
assertReports: func(gwNN types.NamespacedName, reportsMap reports.ReportMap) {
186+
route := &gwv1a2.TCPRoute{
187+
ObjectMeta: metav1.ObjectMeta{
188+
Name: "example-tcp-route",
189+
Namespace: "default",
190+
},
191+
}
192+
routeStatus := reportsMap.BuildRouteStatus(context.TODO(), route, "")
193+
Expect(routeStatus).NotTo(BeNil())
194+
Expect(routeStatus.Parents).To(HaveLen(1))
195+
resolvedRefs := meta.FindStatusCondition(routeStatus.Parents[0].Conditions, string(gwv1.RouteConditionResolvedRefs))
196+
Expect(resolvedRefs).NotTo(BeNil())
197+
Expect(resolvedRefs.Status).To(Equal(metav1.ConditionTrue))
198+
Expect(resolvedRefs.Reason).To(Equal(string(gwv1.RouteReasonResolvedRefs)))
199+
},
200+
}),
201+
Entry(
202+
"tcproute with missing backend reports correctly",
203+
translatorTestCase{
204+
inputFile: "tcp-routing/missing-backend.yaml",
205+
outputFile: "tcp-routing/missing-backend.yaml",
206+
gwNN: types.NamespacedName{
207+
Namespace: "default",
208+
Name: "example-gateway",
209+
},
210+
assertReports: func(gwNN types.NamespacedName, reportsMap reports.ReportMap) {
211+
route := &gwv1a2.TCPRoute{
212+
ObjectMeta: metav1.ObjectMeta{
213+
Name: "example-tcp-route",
214+
Namespace: "default",
215+
},
216+
}
217+
routeStatus := reportsMap.BuildRouteStatus(context.TODO(), route, "")
218+
Expect(routeStatus).NotTo(BeNil())
219+
Expect(routeStatus.Parents).To(HaveLen(1))
220+
resolvedRefs := meta.FindStatusCondition(routeStatus.Parents[0].Conditions, string(gwv1.RouteConditionResolvedRefs))
221+
Expect(resolvedRefs).NotTo(BeNil())
222+
Expect(resolvedRefs.Status).To(Equal(metav1.ConditionFalse))
223+
Expect(resolvedRefs.Message).To(Equal("services \"example-tcp-svc\" not found"))
224+
},
225+
}),
226+
Entry(
227+
"tcproute with invalid backend reports correctly",
228+
translatorTestCase{
229+
inputFile: "tcp-routing/invalid-backend.yaml",
230+
outputFile: "tcp-routing/invalid-backend.yaml",
231+
gwNN: types.NamespacedName{
232+
Namespace: "default",
233+
Name: "example-gateway",
234+
},
235+
assertReports: func(gwNN types.NamespacedName, reportsMap reports.ReportMap) {
236+
route := &gwv1a2.TCPRoute{
237+
ObjectMeta: metav1.ObjectMeta{
238+
Name: "example-tcp-route",
239+
Namespace: "default",
240+
},
241+
}
242+
routeStatus := reportsMap.BuildRouteStatus(context.TODO(), route, "")
243+
Expect(routeStatus).NotTo(BeNil())
244+
Expect(routeStatus.Parents).To(HaveLen(1))
245+
resolvedRefs := meta.FindStatusCondition(routeStatus.Parents[0].Conditions, string(gwv1.RouteConditionResolvedRefs))
246+
Expect(resolvedRefs).NotTo(BeNil())
247+
Expect(resolvedRefs.Status).To(Equal(metav1.ConditionFalse))
248+
Expect(resolvedRefs.Message).To(Equal("unknown backend kind"))
249+
},
184250
}),
185251
Entry(
186252
"tcp gateway with multiple backend services",

0 commit comments

Comments
 (0)