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

tcproute/udproute support multiple backends #3212

Merged
merged 18 commits into from
May 15, 2024

Conversation

zirain
Copy link
Contributor

@zirain zirain commented Apr 17, 2024

fix: #3174

@zirain zirain requested a review from a team as a code owner April 17, 2024 08:51
@zirain zirain changed the title tcproute support multiple backend tcproute/udproute support multiple backend Apr 17, 2024
@zirain zirain changed the title tcproute/udproute support multiple backend tcproute/udproute support multiple backends Apr 17, 2024
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.87%. Comparing base (c30d09f) to head (b80c66f).
Report is 15 commits behind head on main.

❗ Current head b80c66f differs from pull request most recent head 5053054. Consider uploading reports for the commit 5053054 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3212      +/-   ##
==========================================
- Coverage   67.11%   66.87%   -0.25%     
==========================================
  Files         164      163       -1     
  Lines       23818    23307     -511     
==========================================
- Hits        15986    15587     -399     
+ Misses       6912     6814      -98     
+ Partials      920      906      -14     

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

@zirain zirain requested a review from arkodg April 23, 2024 03:41
internal/gatewayapi/route.go Outdated Show resolved Hide resolved
internal/gatewayapi/route.go Outdated Show resolved Hide resolved
zirain added 2 commits May 3, 2024 23:26
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain force-pushed the tcproute-backendrefs branch from b80c66f to bf79459 Compare May 3, 2024 15:26
Signed-off-by: zirain <zirain2009@gmail.com>
Comment on lines 74 to 76
backendWeights := httpRoute.Destination.ToWeightedBackend()
routeAction := buildXdsRouteAction(backendWeights)
routeAction.IdleTimeout = idleTimeout(httpRoute)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @arkodg , this's the key point, use BackendWeights to generate ClusterSpecifier everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for adding this note :). the diff is massive, stared with this file and the IR and this approach makes sense

zirain added 7 commits May 6, 2024 09:10
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain requested a review from arkodg May 9, 2024 21:10
internal/ir/xds.go Outdated Show resolved Hide resolved
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain force-pushed the tcproute-backendrefs branch from b0c5c1e to 16c6627 Compare May 13, 2024 20:32
- backendWeights:
invalid: 1
valid: 0
directResponse:
Copy link
Contributor

Choose a reason for hiding this comment

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

why is directResponse getting removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, see 115fdb1

settings:
- weight: 1
name: tcproute/default/tcproute-1
tls: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why we have an empty tls struct here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see 9084108

zirain added 3 commits May 14, 2024 04:47
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@@ -516,7 +516,8 @@ func (t *Translator) processGRPCRouteRules(grpcRoute *GRPCRouteContext, parentRe

// If the route has no valid backends then just use a direct response and don't fuss with weighted responses
for _, ruleRoute := range ruleRoutes {
if ruleRoute.Destination == nil && ruleRoute.Redirect == nil {
noValidBackends := ruleRoute.Destination == nil || ruleRoute.Destination.ToBackendWeights().Valid == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldnt this be invalidBackendsExist instead of noValidBackends i.e. some instead of all ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noValidBackends = invalidBackendsExist | emptyBackends

Copy link
Contributor

Choose a reason for hiding this comment

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

but noValidBackends also implies validBackends == 0 which is not true here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in current code validBackends == 0 equals emptyBackends

Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain requested a review from arkodg May 13, 2024 22:18
@@ -1158,12 +1136,12 @@ func (t *Translator) processDestination(backendRefContext BackendRefContext,

backendNamespace := NamespaceDerefOr(backendRef.Namespace, route.GetNamespace())
if !t.validateBackendRef(backendRefContext, parentRef, route, resources, backendNamespace, routeType) {
return nil, weight
return &ir.DestinationSetting{Weight: &weight}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a comment here highlighting that this is referring to an invalid weight

}
}

// If the route has no valid backends then just use a direct response and don't fuss with weighted responses
for _, ruleRoute := range ruleRoutes {
if ruleRoute.Destination == nil && ruleRoute.Redirect == nil {
noValidBackends := ruleRoute.Destination == nil || ruleRoute.Destination.ToBackendWeights().Valid == 0
if noValidBackends && ruleRoute.Redirect == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

isnt something like this needed in processHTTPRouteRules as well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

zirain added 2 commits May 15, 2024 09:21
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
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 15, 2024 01:55
@zirain
Copy link
Contributor Author

zirain commented May 15, 2024

/retest

Copy link
Contributor

@shawnh2 shawnh2 left a comment

Choose a reason for hiding this comment

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

lgtm

@zirain zirain merged commit c4b0216 into envoyproxy:main May 15, 2024
20 checks passed
@zirain zirain deleted the tcproute-backendrefs branch May 15, 2024 03:30
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 multiple backends in TCPRoute
3 participants