Skip to content

Commit

Permalink
fix: move websocket config under config.route.v3.RouteAction
Browse files Browse the repository at this point in the history
Signed-off-by: Jesse Haka <haka.jesse@gmail.com>
  • Loading branch information
zetaab committed Feb 23, 2024
1 parent c5cd964 commit a54f8dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
8 changes: 0 additions & 8 deletions internal/xds/translator/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 11 additions & 8 deletions internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a54f8dd

Please sign in to comment.