host2regex: doesn't take in consideration *#3296
Conversation
|
maybe it's not a good idea to have this at all |
| }, | ||
| } { | ||
| t.Run(ti.msg, func(t *testing.T) { | ||
| regex := createHostRx(ti.host) |
There was a problem hiding this comment.
another idea is to update validation webhook to say if the host regex is valid
| @@ -0,0 +1,3 @@ | |||
| kube_foo__qux____example_org_____qux: | |||
| Host("^([a-z0-9]+(-[a-z0-9]+)?[.]example[.]org[.]?(:[0-9]+)?)$") && PathSubtree("/") | |||
There was a problem hiding this comment.
I think you want
^([a-z0-9][a-z0-9-]*)?[.]example....
Better also to write down in the issue what kind of match or regexp you want to create.
There was a problem hiding this comment.
I want to match a valid hostname, it can't end or start with - I think this ([a-z0-9][a-z0-9-]*) can end with -
There was a problem hiding this comment.
What about foo-bar-qux.example , that your regexp doesn't match?
maybe:
^[a-z0-9]([a-z0-9-]*[a-z0-9])?[.]example....
Not sure if we need the capture group for the full first part of the hostname.
There was a problem hiding this comment.
updated the PR to match it, the new regex [a-z0-9]+((-[a-z0-9]+)?)*
|
See #3297 (comment) |
|
A problem with the current implementation is that a request can flap between 2 or more routes request to |
|
Can this advance, e.g. with a feature toggle to support it? I would say potential conflicts can also be ruled user error and not skipper error. What would be needed if you wanted to elevate the support? Weights? Warnings? |
Make eskip rewrite the host to the right regex in case it starts with `*.`
In case matching of wildcard leaf match don't increase leaf weight
Tested with
```bash
➜ ./bin/skipper -inline-routes 'r0: Host("*.mu.sa") -> inlineContent("hi from 0") -> <shunt>; r1: Host("ab.mu.sa") -> inlineContent("hi from 1") -> <shunt>;' -address=:8080
➜ curl -i -H "Host: ba.mu.sa" http://127.0.0.1:8080
HTTP/1.1 200 OK
Content-Length: 9
Content-Type: text/plain; charset=utf-8
Server: Skipper
Date: Tue, 03 Jun 2025 11:18:23 GMT
hi from 0%
➜ curl -i -H "Host: ab.mu.sa" http://127.0.0.1:8080
HTTP/1.1 200 OK
Content-Length: 9
Content-Type: text/plain; charset=utf-8
Server: Skipper
Date: Tue, 03 Jun 2025 11:18:28 GMT
hi from 1%
```
Signed-off-by: Mustafa Abdelrahman <mustafa.abdelrahman@zalando.de>
8e6c365 to
4144952
Compare
converting host from Ingress/RouteGroup for
Hostpredicate doesn't take into consideration that Ingress support wildcard hostnames (see https://kubernetes.io/docs/concepts/services-networking/ingress/#hostname-wildcards) and we produce invalid regexThis PR adds testcases to reproduce the error, requires fix before merging.
following ingress produce
Error:
Test with
fixes #3297