diff --git a/internal/gatewayapi/route.go b/internal/gatewayapi/route.go index 1b0ac613bdd5..495cf4963f94 100644 --- a/internal/gatewayapi/route.go +++ b/internal/gatewayapi/route.go @@ -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. @@ -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, diff --git a/internal/gatewayapi/testdata/gateway-with-listener-with-tcproute-with-multiple-backends.out.yaml b/internal/gatewayapi/testdata/gateway-with-listener-with-tcproute-with-multiple-backends.out.yaml index d87a590cc694..43d2db730ddf 100644 --- a/internal/gatewayapi/testdata/gateway-with-listener-with-tcproute-with-multiple-backends.out.yaml +++ b/internal/gatewayapi/testdata/gateway-with-listener-with-tcproute-with-multiple-backends.out.yaml @@ -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: @@ -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: {}