Skip to content

Commit

Permalink
updroute 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 bd5e682 commit 611a5d7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
26 changes: 12 additions & 14 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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

0 comments on commit 611a5d7

Please sign in to comment.