Skip to content

fix: name AIGatewayRoute HTTPRoute rules#2334

Open
Aias00 wants to merge 3 commits into
envoyproxy:mainfrom
Aias00:fix/multiple-aigatewayroute-api-keys
Open

fix: name AIGatewayRoute HTTPRoute rules#2334
Aias00 wants to merge 3 commits into
envoyproxy:mainfrom
Aias00:fix/multiple-aigatewayroute-api-keys

Conversation

@Aias00

@Aias00 Aias00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Name generated HTTPRoute rules for AIGatewayRoute resources so Envoy Gateway policies can target a specific rule with targetRefs.sectionName. Single-rule routes use the AIGatewayRoute name as the section name, while multi-rule routes use a stable -rule- name and preserve the existing route-not-found catch-all rule name.

Related Issues/PRs (if applicable)

Fixes #1474.

Special notes for reviewers (if applicable)

Validation:

  • go test ./internal/controller
  • go test ./internal/controller -run 'Test_newHTTPRoute|TestAIGatewayRouteHTTPRouteRuleName' -coverprofile=/tmp/ai-gateway-1474-controller-targeted.cover\n- go tool cover -func=/tmp/ai-gateway-1474-controller-targeted.cover | rg 'aiGatewayRouteHTTPRouteRuleName|newHTTPRoute|total:'\n- make lint\n\ngo test ./... was started but interrupted after several minutes while waiting on the crdcel package to run Helm CRD retrieval; no test failure output was produced before interruption.

@Aias00
Aias00 requested a review from a team as a code owner July 7, 2026 10:01
Copilot AI review requested due to automatic review settings July 7, 2026 10:01
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the controller’s generated HTTPRoute rules for AIGatewayRoute resources to assign deterministic HTTPRouteRule.Name values so Envoy Gateway policies can target specific rules via targetRefs.sectionName (notably for per-route/rule SecurityPolicy use cases).

Changes:

  • Assign a stable Name to each generated non-default HTTPRouteRule (single-rule routes use the route name; multi-rule routes use <route>-rule-<index>).
  • Keep the existing catch-all default rule name (route-not-found) while centralizing it as a constant.
  • Add unit tests covering rule naming behavior, including truncation to stay within Gateway API length limits.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/controller/ai_gateway_route.go Names generated HTTPRoute rules deterministically and preserves the default route-not-found rule name.
internal/controller/ai_gateway_route_test.go Updates existing expectations and adds targeted tests for the new rule naming helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Aias00
Aias00 force-pushed the fix/multiple-aigatewayroute-api-keys branch from 0339f04 to 421efff Compare July 7, 2026 10:09
@codecov-commenter

codecov-commenter commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.84%. Comparing base (a7aa458) to head (fe04896).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2334   +/-   ##
=======================================
  Coverage   84.83%   84.84%           
=======================================
  Files         148      148           
  Lines       21877    21888   +11     
=======================================
+ Hits        18559    18570   +11     
  Misses       2197     2197           
  Partials     1121     1121           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Aias00

Aias00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

/retest

Signed-off-by: liuhy <liuhongyu@apache.org>
@Aias00
Aias00 force-pushed the fix/multiple-aigatewayroute-api-keys branch from 421efff to 7919655 Compare July 10, 2026 15:49
@missBerg missBerg added the area/routing Routing, fallback, resilience, InferencePool integration label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/routing Routing, fallback, resilience, InferencePool integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple AiGatewayRoute with each API Key

4 participants