Skip to content

Support for MatcherTree Re-Entry#38564

Closed
bsurber wants to merge 2 commits into
envoyproxy:mainfrom
bsurber:matcher-tree-reentry
Closed

Support for MatcherTree Re-Entry#38564
bsurber wants to merge 2 commits into
envoyproxy:mainfrom
bsurber:matcher-tree-reentry

Conversation

@bsurber

@bsurber bsurber commented Feb 25, 2025

Copy link
Copy Markdown
Contributor

Commit Message:
Add support for re-entry into a MatcherTree, which can be enabled for specific classes as appropriate. This allows for continuing evaluation of an input against the remainder of a MatcherTree when both a) the MatcherTree type could feasibly match a single input to multiple matchers, and b) having additional matches is relevant to the calling filter.

Included is the implementation for ListMatcher as an example. Separate PRs will follow with implementations for other MatcherTree children classes where appropriate: e.g. PrefixMapMatcher will support re-entry but it wouldn't make sense for ExactMapMatcher.

Additional Description: An example of how this can be used can be found in a branching PR #38576, enabling a preview / darklaunch mode for matchers in the rate_limit_quota filter.

Risk Level: Moderate - changes to common library, though no changes to existing behaviors
Testing: Unit & integration testing
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #38564 was opened by bsurber.

see: more, trace.

@bsurber bsurber closed this Feb 25, 2025
@bsurber bsurber reopened this Feb 25, 2025
@bsurber

bsurber commented Feb 25, 2025

Copy link
Copy Markdown
Contributor Author

The evaluateMatch interface feels a bit awkward but it does avoid adding templating to the MaybeMatchResult struct (required if we want to add the reentrant unique_ptr from the MatchResult directly into the MaybeMatchResult). Suggestions are welcome once the PR is fully opened.

@bsurber
bsurber force-pushed the matcher-tree-reentry branch from 45ffca7 to 6a4e290 Compare February 25, 2025 20:53
…-entry into nested matchers.

Signed-off-by: Brian Surber <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 12, 2025
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot closed this Apr 19, 2025
ravenblackx added a commit that referenced this pull request May 28, 2025
…38726)

Commit Message:
- Add a `keep_matching` field to OnMatch to mark Matchers that should be
recorded when matched but should not be the final matched + enforced
action.
- Implement support for `keep_matching` using MatcherTree re-entry.
- Re-entry is implemented in PR #38564 as well for a separate review if
this PR gets closed.
- ListMatcher was chosen as the simplest example usecase /
proof-of-concept for re-entry, but implementation in other MatcherTree
children will follow in separate PRs (namely prefix_map_matcher).
- Centralize recursion handling & re-entry logic into
`evaluateMatch(...)`, leaving each MatchTree child class to implement
the simplest possible `match(...)` logic (find a match and return it +
optionally a reentrant).
- Previously recursion handling was inconsistent across the MatchTree
children, and this saves each child from having to re-implement
recursion, `keep_handling` processing, etc.
- TrieMatcher also required a reentrant implementation as part of moving
recursion logic out of its `match(...)` logic.


Additional Description:
- The final goal is to implement preview / darklaunch Matchers whose
actions are logged or added to metadata, but not enforced.
- An initial implementation of preview matched actions just using
re-entry was drafted for the rate_limit_quota filter in PR #38576,
prompting the request to instead add this `keep_matching` feature to the
Matcher API for re-usability.
- This change will also depend on a duplicate, matcher proto change in
[github.com/cnf/xds](cncf/xds#117).

Risk Level: moderate - includes changes to widely-used libraries
Testing: Unit + Integration testing, loadtesting WIP
Docs Changes:
Release Notes:
Platform Specific Features:
~[Optional Runtime guard:]~
~[Optional Fixes #Issue]~
~[Optional Fixes commit #PR or SHA]~
~[Optional Deprecated:]~
[API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):
The new `keep_matching` field is not marked as WIP as its implementation
should be tested for any breaking changes.

---------

Signed-off-by: Brian Surber <[email protected]>
Signed-off-by: Raven Black <[email protected]>
Co-authored-by: Raven Black <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale stalebot believes this issue/PR has not been touched recently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant