diff --git a/internal/gatewayapi/route.go b/internal/gatewayapi/route.go index 495cf4963f9..3ceb3ca7951 100644 --- a/internal/gatewayapi/route.go +++ b/internal/gatewayapi/route.go @@ -846,24 +846,22 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour ) continue } - if len(udpRoute.Spec.Rules[0].BackendRefs) != 1 { - parentRef.SetCondition(udpRoute, - gwapiv1.RouteConditionResolvedRefs, - metav1.ConditionFalse, - "InvalidBackend", - "One and only one backend is supported", - ) - continue - } - backendRef := udpRoute.Spec.Rules[0].BackendRefs[0] - ds, _ := t.processDestination(backendRef, parentRef, udpRoute, resources) - // Skip further processing if route destination is not valid - if ds == nil || len(ds.Endpoints) == 0 { + valid := true + for _, backendRef := range udpRoute.Spec.Rules[0].BackendRefs { + ds, _ := t.processDestination(backendRef, parentRef, udpRoute, 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(udpRoute, gwapiv1.RouteConditionResolvedRefs, metav1.ConditionFalse) { parentRef.SetCondition(udpRoute, diff --git a/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.in.yaml b/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.in.yaml index 6dfe97fba5e..fc6b8aec64d 100644 --- a/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.in.yaml +++ b/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.in.yaml @@ -26,8 +26,8 @@ udpRoutes: rules: - backendRefs: - name: service-1 - port: 8080 + port: 8162 weight: 50 - name: service-2 - port: 8080 + port: 8162 weight: 50 diff --git a/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.out.yaml b/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.out.yaml index 69ece808c6b..7141e821a37 100644 --- a/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.out.yaml +++ b/internal/gatewayapi/testdata/gateway-with-listener-with-udproute-with-multiple-backends.out.yaml @@ -67,10 +67,10 @@ udpRoutes: rules: - backendRefs: - name: service-1 - port: 8080 + port: 8162 weight: 50 - name: service-2 - port: 8080 + port: 8162 weight: 50 status: parents: @@ -81,9 +81,9 @@ udpRoutes: 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,22 @@ xdsIR: accessLog: text: - path: /dev/stdout + udp: + - address: 0.0.0.0 + destination: + name: udproute/default/udproute-1/rule/-1 + settings: + - addressType: IP + endpoints: + - host: 7.7.7.7 + port: 8162 + protocol: UDP + weight: 50 + - addressType: IP + endpoints: + - host: 7.7.7.7 + port: 8162 + protocol: UDP + weight: 50 + name: envoy-gateway/gateway-1/udp/udproute-1 + port: 10080