diff --git a/internal/ir/xds.go b/internal/ir/xds.go index ee5db65d4fe..5cfb3cd5080 100644 --- a/internal/ir/xds.go +++ b/internal/ir/xds.go @@ -925,7 +925,7 @@ func (r *RouteDestination) Validate() error { return errs } -func (r *RouteDestination) ToWeightedBackend() *BackendWeights { +func (r *RouteDestination) ToBackendWeights() *BackendWeights { w := &BackendWeights{ Name: r.Name, } diff --git a/internal/xds/translator/route.go b/internal/xds/translator/route.go index 69662a6e07e..f91d27fdf1a 100644 --- a/internal/xds/translator/route.go +++ b/internal/xds/translator/route.go @@ -71,7 +71,7 @@ func buildXdsRoute(httpRoute *ir.HTTPRoute) (*routev3.Route, error) { router.Action = &routev3.Route_Route{Route: routeAction} default: - backendWeights := httpRoute.Destination.ToWeightedBackend() + backendWeights := httpRoute.Destination.ToBackendWeights() routeAction := buildXdsRouteAction(backendWeights) routeAction.IdleTimeout = idleTimeout(httpRoute) @@ -219,6 +219,7 @@ func buildXdsStringMatcher(irMatch *ir.StringMatch) *matcherv3.StringMatcher { } func buildXdsRouteAction(backendWeights *ir.BackendWeights) *routev3.RouteAction { + // only use weighted cluster when there are invalid weights if backendWeights.Invalid == 0 { return &routev3.RouteAction{ ClusterSpecifier: &routev3.RouteAction_Cluster{