feat(ingress): render regex paths as synapse match_expr routes#43
Open
pigri wants to merge 3 commits into
Open
feat(ingress): render regex paths as synapse match_expr routes#43pigri wants to merge 3 commits into
pigri wants to merge 3 commits into
Conversation
Gateway RegularExpression path matches and nginx use-regex Ingress paths
were dropped ("no regex path support"), but synapse supports regex
routing via match_expr. Render them as match_expr regex routes instead:
- routeCfg.matchExpr + annSettings.useRegex; addRegexRoute() keyed by the
regex (first-writer-wins), match_expr = http.request.path matches "<re>"
- emit match_expr in both the v1 and v2 upstreams schemas
- rulePaths returns prefixes + regexes; HTTPRoute RegularExpression and
Ingress paths under nginx.ingress.kubernetes.io/use-regex now produce
regex routes (primary host + server-aliases)
Tests: TestRulePaths updated; new TestRegexRouteRender covers v1+v2.
An Ingress/HTTPRoute path regex matches from the beginning of the request path (nginx use-regex / Gateway semantics); k8s also requires the stored Ingress path to begin with "/", so the leading ^ is supplied by the renderer. Prevents an unanchored match (e.g. /x/api/runs/1/stream).
Add a Path matching section (Prefix/Exact/RegularExpression/use-regex → match_expr, ^-anchored) and the --upstreams-out-configmap / --resolve-backend-cluster-ips ingress-mode flags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ingress renderer dropped regex path matches ("synapse v1 has no regex path support"), but synapse supports regex routing via
match_expr. Render them as regex routes instead.RegularExpression+ nginxuse-regexIngress paths →match_expr: http.request.path matches "<regex>", anchored at^(matches from the start of the path; k8s also requires the stored path to begin with/, so the^is supplied by the renderer)routeCfg.matchExpr+annSettings.useRegex;addRegexRoute()(first-writer-wins); emitmatch_exprin both the v1 and v2 upstreams schemasrulePathsnow returns prefixes + regexes; the Ingress + HTTPRoute callers emit regex routes (primary host + server-aliases)--upstreams-out-configmap/--resolve-backend-cluster-ipsflagsTests:
TestRulePathsupdated; newTestRegexRouteRender+TestRegexAnchoring.go build / vet / test ./...green, gofmt clean.