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/rds: NACK unknown route action cluster specifier #4788

Merged
merged 2 commits into from Sep 28, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions xds/internal/test/xds_server_integration_test.go
Expand Up @@ -439,23 +439,29 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) {
// "Fully-qualified RPC method name with leading slash. Same as :path header".
},
// Incorrect Action, so RPC's that match this route should get denied.
Action: &v3routepb.Route_Route{},
Action: &v3routepb.Route_Route{
Route: &v3routepb.RouteAction{ClusterSpecifier: &v3routepb.RouteAction_Cluster{Cluster: ""}},
},
},
// Another routing rule that can be selectively triggered based on incoming RPC.
{
Match: &v3routepb.RouteMatch{
PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/grpc.testing.TestService/UnaryCall"},
},
// Wrong action (!Non_Forwarding_Action) so RPC's that match this route should get denied.
Action: &v3routepb.Route_Route{},
Action: &v3routepb.Route_Route{
Route: &v3routepb.RouteAction{ClusterSpecifier: &v3routepb.RouteAction_Cluster{Cluster: ""}},
},
},
// Another routing rule that can be selectively triggered based on incoming RPC.
{
Match: &v3routepb.RouteMatch{
PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/grpc.testing.TestService/StreamingInputCall"},
},
// Wrong action (!Non_Forwarding_Action) so RPC's that match this route should get denied.
Action: &v3routepb.Route_Route{},
Action: &v3routepb.Route_Route{
Route: &v3routepb.RouteAction{ClusterSpecifier: &v3routepb.RouteAction_Cluster{Cluster: ""}},
},
},
// Not matching route, this is be able to get invoked logically (i.e. doesn't have to match the Route configurations above).
}},
Expand Down
14 changes: 14 additions & 0 deletions xds/internal/xdsclient/rds_test.go
Expand Up @@ -1231,6 +1231,20 @@ func (s) TestRoutesProtoToSlice(t *testing.T) {
},
wantErr: true,
},
{
name: "unsupported cluster specifier",
routes: []*v3routepb.Route{
{
Match: &v3routepb.RouteMatch{
PathSpecifier: &v3routepb.RouteMatch_Prefix{Prefix: "/a/"},
},
Action: &v3routepb.Route_Route{
Route: &v3routepb.RouteAction{
ClusterSpecifier: &v3routepb.RouteAction_ClusterSpecifierPlugin{}}},
},
},
wantErr: true,
},
{
name: "default totalWeight is 100 in weighted clusters action",
routes: []*v3routepb.Route{
Expand Down
2 changes: 2 additions & 0 deletions xds/internal/xdsclient/xds.go
Expand Up @@ -555,6 +555,8 @@ func routesProtoToSlice(routes []*v3routepb.Route, logger *grpclog.PrefixLogger,
}
case *v3routepb.RouteAction_ClusterHeader:
continue
default:
return nil, fmt.Errorf("route %+v, has an unknown ClusterSpecifier: %+v", r, a)
}

msd := action.GetMaxStreamDuration()
Expand Down