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

feat: support BackendRef HTTP filters #3246

Merged
merged 13 commits into from May 20, 2024

Conversation

cnvergence
Copy link
Member

@cnvergence cnvergence commented Apr 22, 2024

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #2572 #3338

@cnvergence cnvergence force-pushed the backendref-filters branch 4 times, most recently from 274ac15 to 1188ea7 Compare April 22, 2024 18:40
@cnvergence cnvergence force-pushed the backendref-filters branch 2 times, most recently from 53163a5 to 15f536d Compare May 3, 2024 12:39
@cnvergence cnvergence self-assigned this May 6, 2024
@zirain
Copy link
Contributor

zirain commented May 7, 2024

this may conflict with #3212, should decide which go first.
cc @envoyproxy/gateway-maintainers

@cnvergence cnvergence force-pushed the backendref-filters branch 6 times, most recently from 2285eb6 to 458ced2 Compare May 9, 2024 08:29
@cnvergence cnvergence marked this pull request as ready for review May 9, 2024 08:32
@cnvergence cnvergence requested a review from a team as a code owner May 9, 2024 08:32
@cnvergence
Copy link
Member Author

/retest

Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 78.88889% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 67.33%. Comparing base (8ca2675) to head (cf2bbcf).

Files Patch % Lines
internal/gatewayapi/route.go 70.58% 6 Missing and 4 partials ⚠️
internal/xds/translator/route.go 85.36% 3 Missing and 3 partials ⚠️
internal/gatewayapi/validate.go 72.72% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3246   +/-   ##
=======================================
  Coverage   67.32%   67.33%           
=======================================
  Files         166      166           
  Lines       19211    19275   +64     
=======================================
+ Hits        12934    12979   +45     
- Misses       5347     5358   +11     
- Partials      930      938    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cnvergence
Copy link
Member Author

/retest

@cnvergence
Copy link
Member Author

@zirain rebased the PR, as your changes went first 😄

@arkodg
Copy link
Contributor

arkodg commented May 16, 2024

hey @cnvergence small nits, overall LGTM, thanks for adding this feature !
you will also want to undo parts of #2620 in this PR, or even modify that code to add the status if any of the filters are the ones from below

Path rewrites
Redirect
Mirroring

@cnvergence cnvergence force-pushed the backendref-filters branch 3 times, most recently from fd89de9 to 60d0954 Compare May 18, 2024 23:04
@cnvergence
Copy link
Member Author

/retest

Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
@cnvergence
Copy link
Member Author

/retest

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks !

@arkodg arkodg requested review from a team May 20, 2024 16:32
Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

This PR looks great! Just a few non-blocking nits, which can be addressed in a follow-up PR.

@@ -1225,17 +1225,71 @@ func (t *Translator) processDestination(backendRefContext BackendRefContext,
gwapiv1a2.RouteReasonResolvedRefs,
"Mixed endpointslice address type for the same backendRef is not supported")
}

destinationFilters := t.processDestinationFilters(routeType, backendRefContext, parentRef, route, resources)
Copy link
Member

Choose a reason for hiding this comment

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

Could we remove route parameter here? Passing an unused parameter into this function could be confusing.

Suggested change
destinationFilters := t.processDestinationFilters(routeType, backendRefContext, parentRef, route, resources)
destinationFilters := t.processDestinationFilters(routeType, backendRefContext, parentRef, resources)


switch filters := backendFilters.(type) {
case []gwapiv1.HTTPRouteFilter:
httpFiltersContext = t.ProcessHTTPFilters(parentRef, route, filters, 0, resources)
Copy link
Member

Choose a reason for hiding this comment

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

This is probably not an ideal solution, but it makes it clear that route is not needed in this case.

Suggested change
httpFiltersContext = t.ProcessHTTPFilters(parentRef, route, filters, 0, resources)
httpFiltersContext = t.ProcessHTTPFilters(parentRef, nil, filters, 0, resources)

httpFiltersContext = t.ProcessHTTPFilters(parentRef, route, filters, 0, resources)

case []gwapiv1.GRPCRouteFilter:
httpFiltersContext = t.ProcessGRPCFilters(parentRef, route, filters, resources)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
httpFiltersContext = t.ProcessGRPCFilters(parentRef, route, filters, resources)
httpFiltersContext = t.ProcessGRPCFilters(parentRef, nil, filters, resources)

@@ -222,41 +222,70 @@ func buildXdsStringMatcher(irMatch *ir.StringMatch) *matcherv3.StringMatcher {
return stringMatcher
}

func buildXdsRouteAction(backendWeights *ir.BackendWeights) *routev3.RouteAction {
func buildXdsRouteAction(backendWeights *ir.BackendWeights, settings []*ir.DestinationSetting) *routev3.RouteAction {
// only use weighted cluster when there are invalid weights
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this comment should be updated. Adding a few lines to explain the reason would help people who come later.

@zhaohuabing zhaohuabing self-requested a review May 20, 2024 18:47
@zhaohuabing zhaohuabing merged commit 60888c0 into envoyproxy:main May 20, 2024
23 checks passed
@cnvergence cnvergence deleted the backendref-filters branch May 20, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Filters in BackendRefs
5 participants