fix: prioritize exact Ingress regex routes#7902
fix: prioritize exact Ingress regex routes#7902officialasishkumar wants to merge 2 commits intoKong:mainfrom
Conversation
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc60493f40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| paths[i] = m.addRegexPrefixFn(*path) | ||
| } | ||
| route.Paths = append(route.Paths, paths...) | ||
| route.RegexPriority = kong.Int(max(*route.RegexPriority, regexPriorityFromIngressPath(httpIngressPath))) |
There was a problem hiding this comment.
Avoid applying exact-path priority to all route paths
Updating route.RegexPriority with max(...) per path makes a single route-level priority depend on the longest Exact path in that route, but Kong applies that priority to all regex paths on the route. If one backend has both Exact and Prefix paths (e.g. Exact /very/long/path and Prefix /api), the prefix regex ~/api$ inherits the boosted priority and can beat another backend's Exact /api route, which reverses Kubernetes path precedence for requests to /api.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Handled in 5948db8. Exact-path regex priority is now isolated from prefix-path route buckets, with focused coverage added.
|
|
What this PR does / why we need it:
Ingress
pathType: Exactpaths are translated to Kong regex paths in traditional routing mode. Those routes previously kept the same defaultregex_priorityas other generated regex paths, which could allow a broader Prefix route to win over an Exact route for the same host depending on Kong route ordering.This sets a deterministic default regex priority for Exact Ingress paths based on the path length. Prefix and ImplementationSpecific routes keep the existing default priority, and users can still override the value with
konghq.com/regex-priority.Which issue this PR fixes:
Fixes #7824
Special notes for your reviewer:
Validated locally with:
go test ./internal/dataplane/translator/subtranslatorgo test ./internal/dataplane/translatorgo test ./internal/dataplane/translator/...I did not add a changelog entry because the changelog only contains released-version sections and no unreleased section for new PR entries.
PR Readiness Checklist:
Complete these before marking the PR as
ready to review:CHANGELOG.mdrelease notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR