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: add HTTP filter is_optional support (gRFC A39) #4221

Merged
merged 3 commits into from Mar 2, 2021

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Feb 23, 2021

This PR contains all of #4206, with the is_optional support as a separate, following commit.

@dfawley
Copy link
Member Author

dfawley commented Feb 25, 2021

This is rebased & ready for review

@@ -144,14 +144,31 @@ func unwrapHTTPFilterConfig(config *anypb.Any) (proto.Message, string, error) {
return s, s.GetTypeUrl(), nil
}

func validateHTTPFilterConfig(cfg *anypb.Any, lds bool) (httpfilter.Filter, httpfilter.FilterConfig, error) {
func validateHTTPFilterConfig(cfg *anypb.Any, lds, optional, validateServer, validateClient bool) (httpfilter.Filter, httpfilter.FilterConfig, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These boolean vars look weird to me.

It seems the checks can be done after this function returns. Do the type assertions there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Optional needs to be supported within the function, or we need to return a magic error so it can be treated specially by the caller, which I dislike (parse/unmarshal errors should not be ignored). I moved the server/client type assertion to the caller though.

@@ -170,9 +187,23 @@ func processHTTPFilterOverrides(cfgs map[string]*anypb.Any) (map[string]httpfilt
}
m := make(map[string]httpfilter.FilterConfig)
for name, cfg := range cfgs {
_, config, err := validateHTTPFilterConfig(cfg, false)
optional := false
if typeURL := cfg.GetTypeUrl(); typeURL == "type.googleapis.com/envoy.config.route.v3.FilterConfig" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a const for the string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or, maybe use https://pkg.go.dev/github.com/golang/protobuf/ptypes#DynamicAny instead of manually check the type? We can do a type assertion on the message.

A similar change can be made for unwrapHTTPFilterConfig(), so you won't need the type string there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or, maybe use pkg.go.dev/github.com/golang/protobuf/ptypes#DynamicAny instead of manually check the type? We can do a type assertion on the message.

I just discovered ptypes.Is; used that instead.

@dfawley dfawley requested a review from menghanl March 1, 2021 16:59
xds/internal/client/xds.go Show resolved Hide resolved
xds/internal/client/xds.go Show resolved Hide resolved
Value: []byte{1, 2, 3},
}

func wrappedOptionalFilter(name string) *anypb.Any {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this function is defined in lds_test, but only used in rds_test..

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true but it seems to fit more in here with the other filter config stuff. I can move it if you feel strongly, LMK.

@menghanl menghanl assigned dfawley and unassigned menghanl Mar 1, 2021
@dfawley dfawley merged commit 29bf29e into grpc:master Mar 2, 2021
@dfawley dfawley deleted the optional branch March 2, 2021 17:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants