xds: NACK missing route specifier server side (#4925)

* xds: NACK missing route specifier server side
This commit is contained in:
Zach Reyes 2021-11-03 13:25:05 -04:00 committed by GitHub
parent 670c133e56
commit c105005da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 4 deletions

View File

@ -206,12 +206,12 @@ type ListenerUpdate struct {
// RouteConfigName is the route configuration name corresponding to the
// target which is being watched through LDS.
//
// Only one of RouteConfigName and InlineRouteConfig is set.
// Exactly one of RouteConfigName and InlineRouteConfig is set.
RouteConfigName string
// InlineRouteConfig is the inline route configuration (RDS response)
// returned inside LDS.
//
// Only one of RouteConfigName and InlineRouteConfig is set.
// Exactly one of RouteConfigName and InlineRouteConfig is set.
InlineRouteConfig *RouteConfigUpdate
// MaxStreamDuration contains the HTTP connection manager's

View File

@ -637,8 +637,7 @@ func processNetworkFilters(filters []*v3listenerpb.Filter) (*FilterChain, error)
}
filterChain.InlineRouteConfig = &routeU
case nil:
// No-op, as no route specifier is a valid configuration on
// the server side.
return nil, fmt.Errorf("no RouteSpecifier: %+v", hcm)
default:
return nil, fmt.Errorf("unsupported type %T for RouteSpecifier", hcm.RouteSpecifier)
}

View File

@ -770,6 +770,40 @@ func TestNewFilterChainImpl_Failure_BadRouteUpdate(t *testing.T) {
lis *v3listenerpb.Listener
wantErr string
}{
{
name: "missing-route-specifier",
lis: &v3listenerpb.Listener{
FilterChains: []*v3listenerpb.FilterChain{
{
Name: "filter-chain-1",
Filters: []*v3listenerpb.Filter{
{
Name: "hcm",
ConfigType: &v3listenerpb.Filter_TypedConfig{
TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{
HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter},
}),
},
},
},
},
},
DefaultFilterChain: &v3listenerpb.FilterChain{
Filters: []*v3listenerpb.Filter{
{
Name: "hcm",
ConfigType: &v3listenerpb.Filter_TypedConfig{
TypedConfig: testutils.MarshalAny(&v3httppb.HttpConnectionManager{
HttpFilters: []*v3httppb.HttpFilter{emptyRouterFilter},
}),
},
},
},
},
},
wantErr: "no RouteSpecifier",
},
{
name: "not-ads",
lis: &v3listenerpb.Listener{