Skip to content

Commit

Permalink
tcproute support multiple backend
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed Apr 17, 2024
1 parent c41247b commit bd5e682
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
27 changes: 12 additions & 15 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,6 @@ func (t *Translator) ProcessTCPRoutes(tcpRoutes []*gwapiv1a2.TCPRoute, gateways

func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resources *Resources, xdsIR XdsIRMap) {
for _, parentRef := range tcpRoute.ParentRefs {

// Need to compute Route rules within the parentRef loop because
// any conditions that come out of it have to go on each RouteParentStatus,
// not on the Route as a whole.
Expand All @@ -978,23 +977,21 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
)
continue
}
if len(tcpRoute.Spec.Rules[0].BackendRefs) != 1 {
parentRef.SetCondition(tcpRoute,
gwapiv1.RouteConditionResolvedRefs,
metav1.ConditionFalse,
"InvalidBackend",
"One and only one backend is supported",
)
continue
}

backendRef := tcpRoute.Spec.Rules[0].BackendRefs[0]
ds, _ := t.processDestination(backendRef, parentRef, tcpRoute, resources)
// Skip further processing if route destination is not valid
if ds == nil || len(ds.Endpoints) == 0 {
valid := true
for _, backendRef := range tcpRoute.Spec.Rules[0].BackendRefs {
ds, _ := t.processDestination(backendRef, parentRef, tcpRoute, resources)
// Skip further processing if route destination is not valid
if ds == nil || len(ds.Endpoints) == 0 {
valid = false
continue
}
destSettings = append(destSettings, ds)
}
if !valid {
continue
}
destSettings = append(destSettings, ds)

// If no negative condition has been set for ResolvedRefs, set "ResolvedRefs=True"
if !parentRef.HasCondition(tcpRoute, gwapiv1.RouteConditionResolvedRefs, metav1.ConditionFalse) {
parentRef.SetCondition(tcpRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ tcpRoutes:
status: "True"
type: Accepted
- lastTransitionTime: null
message: One and only one backend is supported
reason: InvalidBackend
status: "False"
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
Expand All @@ -94,3 +94,23 @@ xdsIR:
accessLog:
text:
- path: /dev/stdout
tcp:
- address: 0.0.0.0
destination:
name: tcproute/default/tcproute-1/rule/-1
settings:
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
protocol: TCP
weight: 50
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
protocol: TCP
weight: 50
name: envoy-gateway/gateway-1/tcp/tcproute-1
port: 10080
tls: {}

0 comments on commit bd5e682

Please sign in to comment.