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: add HTTPRoute-rule name to envoy route metadata #4561

Merged
merged 5 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ func (t *Translator) processHTTPRouteRule(httpRoute *HTTPRouteContext, ruleIdx i
Name: irRouteName(httpRoute, ruleIdx, matchIdx),
SessionPersistence: sessionPersistence,
}
irRoute.Metadata = buildRouteMetadata(httpRoute)
if rule.Name != nil {
irRoute.Metadata.SectionName = string(*rule.Name)
Copy link
Member

@zhaohuabing zhaohuabing Oct 30, 2024

Choose a reason for hiding this comment

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

I didn't see the SectionName in the testdata outpout file. Did I miss anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I missed the scenario of matcher-less routes :p

}
processRouteTimeout(irRoute, rule)

if match.Path != nil {
Expand Down Expand Up @@ -696,7 +700,6 @@ func (t *Translator) processHTTPRouteParentRefListener(route RouteContext, route
continue
}
hasHostnameIntersection = true
routeMetadata := buildRouteMetadata(route)

var perHostRoutes []*ir.HTTPRoute
for _, host := range hosts {
Expand All @@ -721,6 +724,10 @@ func (t *Translator) processHTTPRouteParentRefListener(route RouteContext, route
// Remove dots from the hostname before appending it to the IR Route name
// since dots are special chars used in stats tag extraction in Envoy
underscoredHost := strings.ReplaceAll(host, ".", "_")
routeMetadata := routeRoute.Metadata
if routeMetadata == nil { // if metadata was not set in the matcher evaluation phase, build it here
routeMetadata = buildRouteMetadata(route)
}
hostRoute := &ir.HTTPRoute{
Name: fmt.Sprintf("%s/%s", routeRoute.Name, underscoredHost),
Metadata: routeMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ httpRoutes:
backendRefs:
- name: service-1
port: 8080
name: rule-1
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ httpRoutes:
- path:
type: RegularExpression
value: '*.foo.bar.com'
name: rule-1
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ httpRoutes:
- backendRefs:
- name: service-1
port: 8080
name: rule-1

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ httpRoutes:
- backendRefs:
- name: service-1
port: 8080
name: rule-1
status:
parents:
- conditions:
Expand Down