Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: accept either "" or "/" as the prefix for the default route #3535

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions xds/internal/client/v2client_rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func getClusterFromRouteConfiguration(rc *xdspb.RouteConfiguration, host string)
return ""
}
dr := vh.Routes[len(vh.Routes)-1]
if match := dr.GetMatch(); match == nil || match.GetPrefix() != "" {
// The matched virtual host is invalid.
if match := dr.GetMatch(); match == nil || (match.GetPrefix() != "" && match.GetPrefix() != "/") {
// The matched virtual host is invalid. Match is not "" or "/".
return ""
}
if route := dr.GetRoute(); route != nil {
Expand Down
17 changes: 16 additions & 1 deletion xds/internal/client/v2client_rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,25 @@ func (s) TestRDSGetClusterFromRouteConfiguration(t *testing.T) {
wantCluster: "",
},
{
name: "good-route-config",
name: "good-route-config-with-empty-string-route",
rc: goodRouteConfig1,
wantCluster: goodClusterName1,
},
{
// default route's match is not empty string, but "/".
name: "good-route-config-with-slash-string-route",
rc: &xdspb.RouteConfiguration{
Name: goodRouteName1,
VirtualHosts: []*routepb.VirtualHost{{
Domains: []string{goodLDSTarget1},
Routes: []*routepb.Route{{
Match: &routepb.RouteMatch{PathSpecifier: &routepb.RouteMatch_Prefix{Prefix: "/"}},
Action: &routepb.Route_Route{
Route: &routepb.RouteAction{
ClusterSpecifier: &routepb.RouteAction_Cluster{Cluster: goodClusterName1},
}}}}}}},
wantCluster: goodClusterName1,
},
}

for _, test := range tests {
Expand Down