Skip to content

Conversation

@YifeiZhuang
Copy link
Member

@YifeiZhuang YifeiZhuang requested a review from dapengzhang0 July 24, 2021 00:56
Set<String> names = new HashSet<>();
for (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter
httpFilter : proto.getHttpFiltersList()) {
NamedFilterConfig lastFilter = new NamedFilterConfig(null, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

This initialization is not the right thing to do. It will produce literal "null" in the error message. The variable lastFilter seems not needed: for client, if the list is empty, throw an exception here; and validate the last filter inside the loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

The lastFilter check outside of the loop was intended to cover the empty list case. Because previous empty filter chains would end up a lame_filter later on, but we removed that part here.
But I think the way you described here is better - functionally the same but error message more friendly. Updated.

}
StructOrError<FilterConfig> filterConfig =
parseHttpFilter(httpFilter, filterRegistry, isForClient);
if (i == proto.getHttpFiltersCount() - 1 && filterConfig != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(For client) fail validation if(i == proto.getHttpFiltersCount() - 1 && filterConfig == null)

Copy link
Member

Choose a reason for hiding this comment

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

Why is this validation client-only? For server-side today parseHttpFilter == false, but if http filters are enabled on server-side, then it seems this is required on server-side as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is nothing to validate on the terminal filter for server-side. Does the last filter in filter chain have to have a typed config for server-side?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, probably yes.
Last time we talked about hcm being the last filter in filter-chain for the server.
Then then it sounded like the terminal filter was for the client. But actually routing config is both a client and server filter.
How do we know that TD is going to follow this?

Side note, I wonder if we will be able to do end to end test for the server side, i might missed something but it does not seem to work: currently parseHttpFilter == false , so filterConfig is null, but the server requires it to be non-null.

Copy link
Member Author

Choose a reason for hiding this comment

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

It only allows on and only one filter in filter chain at server-side, it must be hcm typed config.
But http-filters inside hcm for server-side, it seems grpc/proposal#250 terminal filter change isn't limited to client.

Copy link
Member

Choose a reason for hiding this comment

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

The Listener has an explicit FilterChain message along with FilterChainMatches for deciding which chain to use. That's why I assumed that's what you were talking about. I don't know how common it is to say "filter chain" applying to http filters. It doesn't seem wrong, but may need to be careful. I chose to interpret what you said in light of Ivy's interpretation, where she mentioned hcm which is a network filter. Both of us have been messing with network filters more than some other people, so we may be particularly prone to interpreting it that way.

There is nothing to validate on the terminal filter for server-side. Does the last filter in filter chain have to have a typed config for server-side?

To re-answer this in light of it being about http filters: both client-side and server-side behave the same for validation here (when RBAC flag is enabled, which enables http filters on server-side). Router is "expected" in both cases and RPCs will probably fail if Router isn't present. Any filters after Router are ignored. All of that is covered in gRFC A39.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how common it is to say "filter chain" applying to http filters. It doesn't seem wrong, but may need to be careful.

Actually gRFC A39 is also using the term 'filter chain'.

both client-side and server-side behave the same for validation here (when RBAC flag is enabled, which enables http filters on server-side). Router is "expected" in both cases and RPCs will probably fail if Router isn't present.

If so, the gRFC A36 need be updated to reflect this. @markdroth

Any filters after Router are ignored.

The latest change in gRFC A39 enforces that the Router must be the last filter.

Copy link
Member

Choose a reason for hiding this comment

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

If so, the gRFC A36 need be updated to reflect this.

Nah, that is the old behavior. I'm just not doing a good job keeping track of what the precise currently-expected behavior is. You linked to the gRFC change that changed from the behavior I mentioned (it introduced the concept of "terminal filter"), and that is correct.

The latest change in gRFC A39 enforces that the Router must be the last filter.

That's fine. That gRFC is authoritative.

Copy link
Member

Choose a reason for hiding this comment

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

I misunderstood the purpose of this PR. I was skimming and saw your comment about doing validation specific for client-side only, and that sounded wrong. I wasn't really trying to get in the middle of "what is the client's validation behavior" and instead really only wanted to make sure the client vs server validation was not messed up.

Copy link
Member Author

Choose a reason for hiding this comment

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

it looks there is no doubt that server side httpFilter should also follow terminal filter verification. updated.

@YifeiZhuang YifeiZhuang merged commit a6df9de into grpc:master Sep 9, 2021
YifeiZhuang added a commit to YifeiZhuang/grpc-java that referenced this pull request Sep 10, 2021
… add hcm as terminal network filter verification (grpc#8342)

* xds: add terminal filter verification, remove lame route filter

* move last filter check inline

* add server validate terminal filter
@YifeiZhuang YifeiZhuang deleted the zivy/terminal_filter branch September 10, 2021 00:32
YifeiZhuang added a commit to YifeiZhuang/grpc-java that referenced this pull request Sep 10, 2021
… add hcm as terminal network filter verification (grpc#8342)

* xds: add terminal filter verification, remove lame route filter

* move last filter check inline

* add server validate terminal filter
YifeiZhuang added a commit that referenced this pull request Sep 10, 2021
… add hcm as terminal network filter verification (#8342) (#8507)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants