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: Replace IsTerminal() check with IsRouterFilter() check #6281

Closed
wants to merge 1 commit into from
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)
Aditya-Sood marked this conversation as resolved.
Show resolved Hide resolved
}
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