From ce4498339d158a9f2f78a91f64d5442d4dcca12e Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Mon, 1 Mar 2021 15:08:47 -0800 Subject: [PATCH] review --- xds/internal/client/lds_test.go | 14 ++++++++++++++ xds/internal/client/xds.go | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/xds/internal/client/lds_test.go b/xds/internal/client/lds_test.go index c75ed7667d5c..32b44da1e4a3 100644 --- a/xds/internal/client/lds_test.go +++ b/xds/internal/client/lds_test.go @@ -119,6 +119,11 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { Name: "serverOnlyCustomFilter", ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: serverOnlyCustomFilterConfig}, } + serverOnlyOptionalCustomFilter = &v3httppb.HttpFilter{ + Name: "serverOnlyOptionalCustomFilter", + ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: serverOnlyCustomFilterConfig}, + IsOptional: true, + } unknownFilter = &v3httppb.HttpFilter{ Name: "unknownFilter", ConfigType: &v3httppb.HttpFilter_TypedConfig{TypedConfig: unknownFilterConfig}, @@ -412,6 +417,15 @@ func (s) TestUnmarshalListener_ClientSide(t *testing.T) { resources: []*anypb.Any{v3LisWithFilters(serverOnlyCustomFilter)}, wantErr: true, }, + { + name: "v3 with optional server-only filter", + resources: []*anypb.Any{v3LisWithFilters(serverOnlyOptionalCustomFilter)}, + wantUpdate: map[string]ListenerUpdate{ + v3LDSTarget: { + RouteConfigName: v3RouteConfigName, MaxStreamDuration: time.Second, + }, + }, + }, { name: "v3 with client-only filter", resources: []*anypb.Any{v3LisWithFilters(clientOnlyCustomFilter)}, diff --git a/xds/internal/client/xds.go b/xds/internal/client/xds.go index c0155609f79d..cdecbe29694e 100644 --- a/xds/internal/client/xds.go +++ b/xds/internal/client/xds.go @@ -223,9 +223,15 @@ func processHTTPFilters(filters []*v3httppb.HttpFilter, server bool) ([]HTTPFilt } if server { if _, ok := httpFilter.(httpfilter.ServerInterceptorBuilder); !ok { + if filter.GetIsOptional() { + continue + } return nil, fmt.Errorf("HTTP filter %q not supported server-side", name) } } else if _, ok := httpFilter.(httpfilter.ClientInterceptorBuilder); !ok { + if filter.GetIsOptional() { + continue + } return nil, fmt.Errorf("HTTP filter %q not supported client-side", name) }