From a54f8dd5c3f93fbd654a7de35944fe2fe928b03a Mon Sep 17 00:00:00 2001 From: Jesse Haka Date: Fri, 23 Feb 2024 12:47:58 +0200 Subject: [PATCH] fix: move websocket config under config.route.v3.RouteAction Signed-off-by: Jesse Haka --- internal/xds/translator/listener.go | 8 -------- internal/xds/translator/route.go | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/internal/xds/translator/listener.go b/internal/xds/translator/listener.go index 268cc1dd41c7..40b6c0b22998 100644 --- a/internal/xds/translator/listener.go +++ b/internal/xds/translator/listener.go @@ -242,14 +242,6 @@ func (t *Translator) addXdsHTTPFilterChain(xdsListener *listenerv3.Listener, irL mgr.HttpFilters = append(mgr.HttpFilters, xdsfilters.GRPCWeb) // always enable grpc stats filter mgr.HttpFilters = append(mgr.HttpFilters, xdsfilters.GRPCStats) - } else { - // Allow websocket upgrades for HTTP 1.1 - // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism - mgr.UpgradeConfigs = []*hcmv3.HttpConnectionManager_UpgradeConfig{ - { - UpgradeType: "websocket", - }, - } } if http3Listener { diff --git a/internal/xds/translator/route.go b/internal/xds/translator/route.go index c711e64daf5e..abfb0c77165a 100644 --- a/internal/xds/translator/route.go +++ b/internal/xds/translator/route.go @@ -57,20 +57,23 @@ func buildXdsRoute(httpRoute *ir.HTTPRoute) (*routev3.Route, error) { router.Action = &routev3.Route_Route{Route: routeAction} default: + routeAction := buildXdsRouteAction(httpRoute.Destination.Name) + if httpRoute.Mirrors != nil { + routeAction.RequestMirrorPolicies = buildXdsRequestMirrorPolicies(httpRoute.Mirrors) + } if httpRoute.BackendWeights.Invalid != 0 { // If there are invalid backends then a weighted cluster is required for the route - routeAction := buildXdsWeightedRouteAction(httpRoute) - if httpRoute.Mirrors != nil { - routeAction.RequestMirrorPolicies = buildXdsRequestMirrorPolicies(httpRoute.Mirrors) - } - router.Action = &routev3.Route_Route{Route: routeAction} - } else { - routeAction := buildXdsRouteAction(httpRoute.Destination.Name) + routeAction = buildXdsWeightedRouteAction(httpRoute) if httpRoute.Mirrors != nil { routeAction.RequestMirrorPolicies = buildXdsRequestMirrorPolicies(httpRoute.Mirrors) } - router.Action = &routev3.Route_Route{Route: routeAction} } + routeAction.UpgradeConfigs = []*routev3.RouteAction_UpgradeConfig{ + { + UpgradeType: "websocket", + }, + } + router.Action = &routev3.Route_Route{Route: routeAction} } // Hash Policy