-
Notifications
You must be signed in to change notification settings - Fork 652
GEP for regex-based path rewrites: initial commit #4361
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
base: main
Are you sure you want to change the base?
Conversation
|
Welcome @muxanasov! |
|
Hi @muxanasov. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
robscott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @muxanasov!
geps/gep-4359/index.md
Outdated
|
|
||
| ## Goals | ||
|
|
||
| Close the feature gap for Gateway API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of just closing the feature gap, I'd recommend focusing on the specific capabilities you want to express with the API, such as:
- Rewrite the path of a request based on a regular expression, regardless of initial match type
- Substitute matching section(s) in the regular expression with predefined values
On point 2, I'm not sure if the goal is to substitute multiple or just a single match, and how the substitution should be formatted - multiple inputs or just one?
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: muxanasov The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/release-note-none |
|
|
||
| ## New Fields relationship | ||
|
|
||
| The relationship between new fields shluld stay invartiant across different underlying implementaions and dataplanes. The syntax, however, may vary depending on the implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The relationship between new fields shluld stay invartiant across different underlying implementaions and dataplanes. The syntax, however, may vary depending on the implementation. | |
| The relationship between new fields should be consistent across different underlying implementations and dataplanes. The syntax, however, may vary depending on the implementation. |
robscott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @muxanasov!
|
|
||
| While relationship between pattern and substitution are invariant across implementaitons, the regex syntax is implemntation scpeific. | ||
|
|
||
| Here we show examples that use Google's [RE2](https://github.com/google/re2) engine and should work in Envoy's [regex_rewrite](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-field-config-route-v3-routeaction-regex-rewrite). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you write a conformance test plan, I'd recommend suggesting that we find a way to configure the regex format, and then ensuring that the conformance tests are written in a way that they can support multiple formats. We could start with RE2, but it should be possible to plug in other formats.
| hostnames: | ||
| - "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd recommend leaving this out as it's implied.
|
|
||
| This GEP proposes the following API changes: | ||
|
|
||
| * Update [httproute_types.go](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go) by adding and new `HTTPRegexModifier` field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Update [httproute_types.go](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go) by adding and new `HTTPRegexModifier` field | |
| * Update [httproute_types.go](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go) by adding a new `HTTPRegexModifier` field |
| Close the regex-based path rewrites feature gap for Gateway API, i.e.: | ||
| * Rewrite the path of a request based on a regular expression, regardless of initial match type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly our docs generator requires a new line before lists like this:
| Close the regex-based path rewrites feature gap for Gateway API, i.e.: | |
| * Rewrite the path of a request based on a regular expression, regardless of initial match type | |
| Close the regex-based path rewrites feature gap for Gateway API, i.e.: | |
| * Rewrite the path of a request based on a regular expression, regardless of initial match type |
|
|
||
| The relationship between new fields shluld stay invartiant across different underlying implementaions and dataplanes. The syntax, however, may vary depending on the implementation. | ||
|
|
||
| * `pathPattern` The regular expression used to find portions of a string (hereafter called the “subject string”) that should be replaced. When a new string is produced during the substitution operation, the new string is initially the same as the subject string, but then all matches in the subject string are replaced by the substitution string. If replacing all matches isn’t desired, regular expression anchors can be used to ensure a single match, so as to replace just one occurrence of a pattern. Capture groups can be used in the pattern to extract portions of the subject string, and then referenced in the substitution string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * `pathPattern` The regular expression used to find portions of a string (hereafter called the “subject string”) that should be replaced. When a new string is produced during the substitution operation, the new string is initially the same as the subject string, but then all matches in the subject string are replaced by the substitution string. If replacing all matches isn’t desired, regular expression anchors can be used to ensure a single match, so as to replace just one occurrence of a pattern. Capture groups can be used in the pattern to extract portions of the subject string, and then referenced in the substitution string. | |
| * `pathPattern` The regular expression used to find portions of a string (hereafter called the `subject string`) that should be replaced. When a new string is produced during the substitution operation, the new string is initially the same as the subject string, but then all matches in the subject string are replaced by the substitution string. If replacing all matches isn’t desired, regular expression anchors can be used to ensure a single match, so as to replace just one occurrence of a pattern. Capture groups can be used in the pattern to extract portions of the subject string, and then referenced in the substitution string. |
| relationships: | ||
| seeAlso: | ||
| - https://gateway-api.sigs.k8s.io/geps/gep-726/#future-extension | ||
| references: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also add the references of nginx and haproxy here so we can keep it more agnostic? thanks! :D
|
Hi @muxanasov and thanks for the proposal! I agree this is a very important feature to get people moving to Gateway API, I would just like to put my "ingress-nginx former maintainer" hat a bit: having regexes as part of the API can be very very complex (and somehow dangerous):
That said, I think we do need some feature like this, but if possible I would like to try to scope it to:
Thanks again for the proposal! |
howardjohn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall in favor of the direction but I think the API itself could use a few tweaks
| // Support: Extended | ||
| // | ||
| // +optional | ||
| RegexModifier *HTTPRegexModifier `json:"regexModifier,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just nitpicking on field names here.
This seems a bit odd. It says its about path OR host, but it only has path. Maybe the intent was to add hostPattern and hostSubstitute in the future, but that is somewhat awkward....
Why not adding this under HTTPPathModifier?
So
path:
type: Regex
regex:
match: blah
substitution: blah
this seems more consistent with the existing API
| // +optional | ||
| // +kubebuilder:validation:Minimum=0 | ||
| // +kubebuilder:validation:Maximum=1024 | ||
| PathPattern *string `json:"pathPattern,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required for the GEP but we really really need some examples here for users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And details on the matching semantics. Is it a full string match or substring? Should it match the leading /?
| filters: | ||
| - type: URLRewrite | ||
| urlRewrite: | ||
| regexModifier: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is a good idea but wanted to mention it.
Given regex is implementation specific, and even more so with capture groups, do we event want to bother tying this to regex?
For example, an implementation could support:
pattern: /region/{region}/bucket/{storage}/{object}.pdf
substitution: /{region}/bucket-{storage}/{object}.pdf
which is not regex but fulfills the same purpose (not saying we make that syntax part of the spec, just that if we remove "regex" to "pattern" we could enable it)
What type of PR is this?
/kind documentation
What this PR does / why we need it:
This is to create a new GEP
Does this PR introduce a user-facing change?:
No