Skip to content
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: 4 additions & 0 deletions xds/internal/httpfilter/fault/fault.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.Fil
return parseConfig(override)
}

func (builder) IsTerminal() bool {
return false
}

var _ httpfilter.ClientInterceptorBuilder = builder{}

func (builder) BuildClientInterceptor(cfg, override httpfilter.FilterConfig) (iresolver.ClientInterceptor, error) {
Expand Down
3 changes: 3 additions & 0 deletions xds/internal/httpfilter/httpfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type Filter interface {
// not accept a custom type. The resulting FilterConfig will later be
// passed to Build.
ParseFilterConfigOverride(proto.Message) (FilterConfig, error)
// IsTerminal returns whether this Filter is terminal or not (i.e. it must
// be last filter in the filter chain).
IsTerminal() bool
}

// ClientInterceptorBuilder constructs a Client Interceptor. If this type is
Expand Down
4 changes: 4 additions & 0 deletions xds/internal/httpfilter/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.Fil
return config{}, nil
}

func (builder) IsTerminal() bool {
return true
}

var (
_ httpfilter.ClientInterceptorBuilder = builder{}
_ httpfilter.ServerInterceptorBuilder = builder{}
Expand Down
4 changes: 4 additions & 0 deletions xds/internal/server/listener_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
wrapperspb "github.com/golang/protobuf/ptypes/wrappers"
"google.golang.org/grpc/internal/grpctest"
"google.golang.org/grpc/internal/testutils"
_ "google.golang.org/grpc/xds/internal/httpfilter/router"
"google.golang.org/grpc/xds/internal/testutils/e2e"
"google.golang.org/grpc/xds/internal/testutils/fakeclient"
"google.golang.org/grpc/xds/internal/xdsclient"
)
Expand Down Expand Up @@ -82,6 +84,7 @@ var listenerWithRouteConfiguration = &v3listenerpb.Listener{
RouteConfigName: "route-1",
},
},
HttpFilters: []*v3httppb.HttpFilter{e2e.RouterHTTPFilter},
}),
},
},
Expand Down Expand Up @@ -143,6 +146,7 @@ var listenerWithFilterChains = &v3listenerpb.Listener{
Action: &v3routepb.Route_NonForwardingAction{},
}}}}},
},
HttpFilters: []*v3httppb.HttpFilter{e2e.RouterHTTPFilter},
}),
},
},
Expand Down
5 changes: 5 additions & 0 deletions xds/internal/testutils/e2e/clientresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ func DefaultClientResources(params ResourceParams) UpdateOptions {
}
}

// RouterHTTPFilter is the HTTP Filter configuration for the Router filter.
var RouterHTTPFilter = HTTPFilter("router", &v3routerpb.Router{})

// DefaultClientListener returns a basic xds Listener resource to be used on
// the client side.
func DefaultClientListener(target, routeName string) *v3listenerpb.Listener {
Expand Down Expand Up @@ -212,6 +215,7 @@ func DefaultServerListener(host string, port uint32, secLevel SecurityLevel) *v3
Action: &v3routepb.Route_NonForwardingAction{},
}}}}},
},
HttpFilters: []*v3httppb.HttpFilter{RouterHTTPFilter},
}),
},
},
Expand Down Expand Up @@ -256,6 +260,7 @@ func DefaultServerListener(host string, port uint32, secLevel SecurityLevel) *v3
Action: &v3routepb.Route_NonForwardingAction{},
}}}}},
},
HttpFilters: []*v3httppb.HttpFilter{RouterHTTPFilter},
}),
},
},
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/xdsclient/filter_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func processNetworkFilters(filters []*v3listenerpb.Filter) (*FilterChain, error)
// HTTPConnectionManager must have valid http_filters." - A36
filters, err := processHTTPFilters(hcm.GetHttpFilters(), true)
if err != nil {
return nil, fmt.Errorf("network filters {%+v} had invalid server side HTTP Filters {%+v}", filters, hcm.GetHttpFilters())
return nil, fmt.Errorf("network filters {%+v} had invalid server side HTTP Filters {%+v}: %v", filters, hcm.GetHttpFilters(), err)
}
if !seenHCM {
// TODO: Implement terminal filter logic, as per A36.
Expand Down
Loading