-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
xds/internal/xdsclient: Add support for String Matcher Header Matcher in RDS #6313
Conversation
if !ok { | ||
return false | ||
} | ||
return hsm.stringMatcher.Match(v) != hsm.invert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior here is unclear in some cases:
- If a header is missing, should it always report
false
? Or should it reporttrue
ifinvert=true
? - If a header value is
""
, is that distinct from the header being missing, in any way? - Is the check immediately above designed to only detect an error in usage? Because it doesn't consider (1) at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my chat thread. I think this is WAI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- See Eric's explanation here: HeaderMatcher.invert_match should invert the operation, not the result #4896
- Yes, a set empty header string is logically distinct from it not being presence
- No, this is part of the logic for the header matcher (not an error in usage, a header matcher can be called with metadata not containing the header key set in the matcher), as per explanation in 1
md: metadata.Pairs("th", "not-match"), | ||
invert: true, | ||
want: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases that cover the unusual corner cases mentioned above once we determine the correct behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added 3 test cases, invert and not invert for missing, and invert for empty string wanting true.
md metadata.MD | ||
invert bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: please swap these two in order (here and in the test cases) since invert
is part of the matcher and md
is the input passed to the matcher. OR: build the matcher in the testcase list and put it in there instead of the individual fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Chose the first option and swapped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
case *v3routepb.HeaderMatcher_StringMatch: | ||
sm, err := matcher.StringMatcherFromProto(ht.StringMatch) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("route %+v has an invalid string matcher: %v", err, ht.StringMatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't correct formatting, I need to fix.
Fixes #6226. This PR adds support for String Matching in Header Matching for routes. It converts and validates the proto StringMatcher received from the control plane in the xDS Client, then creates a HeaderMatcher for it in ServiceConfig. Tests at xDS Client layer and header matcher layer, anything further will be too specific for an e2e test (as discussed about testing Philosophy with Eric and Doug, leave more specific behavior checks to unit tests and e2e tests as sanity checks to not bloat number and time of e2e tests).
RELEASE NOTES: