Skip to content

feat: enable HTTPRouteHeaderMatching conformance test for onperm traditional router - #4563

Open
tao12345666333 wants to merge 3 commits into
mainfrom
tao12345666333/conformance-httproute-header-matching
Open

feat: enable HTTPRouteHeaderMatching conformance test for onperm traditional router#4563
tao12345666333 wants to merge 3 commits into
mainfrom
tao12345666333/conformance-httproute-header-matching

Conversation

@tao12345666333

@tao12345666333 tao12345666333 commented Jun 9, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Enables the Gateway API HTTPRouteHeaderMatching conformance test for the on-prem traditional_compatible router.

The traditional router now assigns regex_priority to generated Kong routes so overlapping HTTPRoute matches follow Gateway API precedence. Priority is based on a compact rank of the match's precedence class—hostname specificity, path type and length, method presence, effective header count, and effective query parameter count—plus rule/match order to break ties between equally specific matches within the same HTTPRoute.

Each precedence class is assigned its own range:

classRank * traditionalMatchPriorityClassSize + withinRouteOffset

Adding or removing an HTTPRoute whose precedence classes are already present does not renumber routes generated from unrelated HTTPRoutes. Introducing or removing a precedence class can renumber higher-ranked classes. Equally specific matches from different HTTPRoutes share the same priority, so their relative order remains unspecified.

Prioritized header-only matches receive a scoped synthetic catch-all regex path so Kong's traditional router applies regex_priority.

Which issue this PR fixes

Fixes #4454

Special notes for your reviewer:

  • Header-only matches are kept separate from path-and-header matches so they do not inherit unrelated path priority.
  • The synthetic catch-all regex path is limited to prioritized header-only routes. Matches without headers, such as method-only or query-only matches, are unchanged.
  • This PR affects only the on-prem translation path; hybrid gateway behavior is not changed.

PR Readiness Checklist:

  • the CHANGELOG.md release notes have been updated to reflect significant changes

@tao12345666333 tao12345666333 self-assigned this Jun 9, 2026
@tao12345666333 tao12345666333 changed the title test: enable HTTPRouteHeaderMatching conformance test for traditional… test: enable HTTPRouteHeaderMatching conformance test for traditional router Jun 9, 2026
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch 3 times, most recently from 01f9ecf to 464a8e8 Compare June 11, 2026 22:37
@tao12345666333 tao12345666333 added this to the KO v2.3.x milestone Jun 16, 2026
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch 2 times, most recently from 569cdb1 to 0b2b1cf Compare June 17, 2026 08:10
@tao12345666333
tao12345666333 marked this pull request as ready for review June 17, 2026 09:53
@tao12345666333
tao12345666333 requested a review from a team as a code owner June 17, 2026 09:53
@tao12345666333 tao12345666333 changed the title test: enable HTTPRouteHeaderMatching conformance test for traditional router feat: enable HTTPRouteHeaderMatching conformance test for traditional router Jun 18, 2026
@tao12345666333 tao12345666333 changed the title feat: enable HTTPRouteHeaderMatching conformance test for traditional router feat: enable HTTPRouteHeaderMatching conformance test for onperm traditional router Jun 26, 2026
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch from fa6779f to 00e3c2d Compare June 26, 2026 03:36
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch from b8575d9 to 1aaa841 Compare July 27, 2026 11:01
@tao12345666333

Copy link
Copy Markdown
Member Author

/muthur review this pr

@github-actions

Copy link
Copy Markdown

Run report (federated)

Item Detail
Conclusion success
Reviewed commit 1aaa84181dc1d4c7356cbaea0fcf1d1fecae2f1e
Prompt review this pr
Duration 1270s (13 turns)
Input tokens (incl. cache) 442697
Output tokens 11445
Permission denials 10
Total cost $4.6910

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Go Code Review — HTTPRoute traditional-router regex_priority

Verdict APPROVE_WITH_COMMENTS
Critical/High 0
Medium 2

Reviewed git diff origin/main...HEAD (primary: ingress-controller/internal/dataplane/translator/subtranslator/httproute.go and its tests) via the adversarial Go reviewer + findings auditor pipeline. Both agents converged on two substantive issues; I independently verified the encoding mechanism in httproute_atc.go (PathLength is packed raw/unbucketed into bits 23–32, so the rankByClass compaction genuinely re-indexes across every observed class cluster-wide) and confirmed the call site is cluster-wide and flag-independent (translate_httproute.goListHTTPRoutes()TranslateHTTPRoutesToKongstateServices).

I downgraded the reviewer's Critical to Medium: the priority remap is monotonic, so routing/selection order is always preserved — this is a config-churn / stability concern, not a misrouting bug, and the behavior is accurately (if narrowly) documented in both the function comment and CHANGELOG. No overstatement was found in the docs; the finding is that the disclosed stability guarantee is scoped so narrowly it rarely holds in practice.

Additional Risk pass: No leaked secrets, no injection/attack-surface, no resource leaks, and no unbounded growth introduced (the priority maps are bounded by the match count per reconcile). RoutePriorityType is uint64 and the reserved class size (1<<10) comfortably exceeds the real per-HTTPRoute match bound, so no integer overflow. The two golden-file changes and the conformance un-skip are consistent with the feature. Non-Go changes (CHANGELOG, golden YAML, skip list) were manually scanned and raised nothing. No additional concerns found beyond the two findings below.

Comment thread ingress-controller/internal/dataplane/translator/translate_httproute_test.go Outdated
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch from 1aaa841 to c36b7c4 Compare July 28, 2026 10:50
Implement Gateway API match precedence for the traditional (non-expression)
router so that overlapping HTTPRoute matches are evaluated in the order
required by the spec, and remove HTTPRouteHeaderMatching from the traditional
router conformance skip list.

Kong routes translated from HTTPRoute matches are now assigned a
regex_priority derived from the rank of the match's Gateway API precedence
class (path type and length, method, header and query parameter counts) plus,
within a single HTTPRoute, the rule and match order. The priority is computed
as classRank*traditionalMatchPriorityClassSize + within-route offset, so it
depends only on the set of precedence classes in use and on the match's own
HTTPRoute: creating or deleting an HTTPRoute with already-present match shapes
no longer renumbers the routes generated for unrelated HTTPRoutes, preserving
incremental sync and entity-level diffing. Equally specific matches from
different HTTPRoutes share a priority and their relative order remains
unspecified, as before priorities were introduced. A route keeps
regex_priority unset only when its match is in the lowest precedence class in
use and has no within-HTTPRoute tie; lowest-class matches tied within a single
HTTPRoute still receive priorities reflecting their rule and match order.

Header-only matches are split from path matches before route consolidation and
given a catch-all regex path, so Kong can apply regex_priority for header-only
tie-breaks. Header match names are matched case-insensitively: the original
casing of the first occurrence is kept as the Kong route key and later
equivalent names are ignored, as required by the Gateway API specification.

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch from c36b7c4 to 1a37f76 Compare July 29, 2026 07:14
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
@tao12345666333
tao12345666333 force-pushed the tao12345666333/conformance-httproute-header-matching branch from 1a37f76 to cf2d14b Compare July 29, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conformance: enable HTTPRouteHeaderMatching test for traditional_compatible router

1 participant