Skip to content
Closed
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
8 changes: 4 additions & 4 deletions xds/internal/xdsclient/xdsresource/unmarshal_lds.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"google.golang.org/grpc/xds/internal/httpfilter"
"google.golang.org/grpc/xds/internal/httpfilter/router"
"google.golang.org/protobuf/types/known/anypb"
)

Expand Down Expand Up @@ -235,14 +236,13 @@ func processHTTPFilters(filters []*v3httppb.HttpFilter, server bool) ([]HTTPFilt
if len(ret) == 0 {
return nil, fmt.Errorf("http filters list is empty")
}
var i int
for ; i < len(ret)-1; i++ {
for i := 0; i < len(ret)-1; i++ {
if ret[i].Filter.IsTerminal() {
return nil, fmt.Errorf("http filter %q is a terminal filter but it is not last in the filter chain", ret[i].Name)
}
}
if !ret[i].Filter.IsTerminal() {
return nil, fmt.Errorf("http filter %q is not a terminal filter", ret[len(ret)-1].Name)
if !router.IsRouterFilter(ret[len(ret)-1].Filter) {
return nil, fmt.Errorf("http filter %q is not a router filter", ret[len(ret)-1].Name)
}
return ret, nil
}
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) {
wantErr: "is a terminal filter but it is not last in the filter chain",
},
{
name: "last not terminal filter",
name: "last not router filter",
resource: testutils.MarshalAny(&v3listenerpb.Listener{
Name: v3LDSTarget,
Address: localSocketAddress,
Expand All @@ -1139,7 +1139,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) {
},
}),
wantName: v3LDSTarget,
wantErr: "is not a terminal filter",
wantErr: "is not a router filter",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be exhaustive, can we have a test where the last filter is a terminal filter, but it is just not the router filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it @easwars, will update once it's done
thank you

},
{
name: "unsupported oneof in typed config of http filter",
Expand Down