You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "mchtech (via GitHub)" <gi...@apache.org> on 2023/04/13 01:31:40 UTC

[GitHub] [apisix-ingress-controller] mchtech opened a new issue, #1785: bug: regex path route matching is unstable

mchtech opened a new issue, #1785:
URL: https://github.com/apache/apisix-ingress-controller/issues/1785

   ### Current Behavior
   
   regex path ingress rules are ordered by create time
   
   ### Expected Behavior
   
   regex path ingress rules are ordered by path length (or alphabetical order?) :[ingress-nginx:   first orders the paths by descending length](https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/#path-priority)
   
   
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. config-A:
   ```yaml
   apiVersion: networking.k8s.io/v1
   kind: Ingress
   metadata:
     annotations:
       k8s.apisix.apache.org/use-regex: "true"
     name: ingress-a
     namespace: default
   spec:
     ingressClassName: apisix
     rules:
     - http:
         paths:
         - backend:
             service:
               name: svc-a
               port:
                 name: http
           path: /api/.*   # <---- override ingress-b, but ingress-b is more 'accurate'
           pathType: ImplementationSpecific
   ```
   2. config-B:
   ```yaml
   apiVersion: networking.k8s.io/v1
   kind: Ingress
   metadata:
     annotations:
       k8s.apisix.apache.org/use-regex: "true"
     name: ingress-b
     namespace: default
   spec:
     ingressClassName: apisix
     rules:
     - http:
         paths:
         - backend:
             service:
               name: svc-b
               port:
                 name: http
           path: /api/bbb/.*
           pathType: ImplementationSpecific
   ```
   3. if first create `ingress-b` (then create `ingress-a`), apisix works as expect
   4. if first create `ingress-a` (then create `ingress-b`), `/api/bbb/ccc` will still route to `svc-a` (should be `svc-b`)
   
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.2.0
   - Operating system (run `uname -a`): oracle linux 8.6 kernel 5.6.11
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx version: openresty/1.21.4.1
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): 3.5.4
   - APISIX Dashboard version, if relevant: 0.8.0
   - Plugin runner version, for issues related to plugin runners: -
   - LuaRocks version, for installation issues (run `luarocks --version`): -
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] mchtech closed issue #1785: question: regex path route matching is unstable

Posted by "mchtech (via GitHub)" <gi...@apache.org>.
mchtech closed issue #1785: question: regex path route matching is unstable
URL: https://github.com/apache/apisix-ingress-controller/issues/1785


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1785: question: regex path route matching is unstable

Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on issue #1785:
URL: https://github.com/apache/apisix-ingress-controller/issues/1785#issuecomment-1506367563

   In fact, this is not a bug. The document you referenced in the issue is from the Ingres-NGINX project, which explains the priority of regular expression matching in NGINX. However, APISIX Ingress uses APISIX as its data plane. APISIX is different from NGINX and has its own routing components.
   
   FYI:
   
   - [Router radixtree | Apache APISIX® -- Cloud-Native API Gateway](https://apisix.apache.org/docs/apisix/router-radixtree/)
   
   -  [Router | Apache APISIX® -- Cloud-Native API Gateway](https://apisix.apache.org/docs/apisix/terminology/router/)
   - [Route | Apache APISIX® -- Cloud-Native API Gateway](https://apisix.apache.org/docs/apisix/terminology/route/)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] mchtech commented on issue #1785: question: regex path route matching is unstable

Posted by "mchtech (via GitHub)" <gi...@apache.org>.
mchtech commented on issue #1785:
URL: https://github.com/apache/apisix-ingress-controller/issues/1785#issuecomment-1507133399

   I only use `apisix-ingress-controller` to "sync" K8s APISIX Ingress resources to `apisix` routes.
   
   > order 1
   1. add k8s regex ingress `/api/bbb/.* --> svc-b`: `curl /api/bbb/ccc`: route to `svc-b`
   2. add k8s regex ingress `/api/.*     --> svc-a`: `curl /api/bbb/ccc`: route to `svc-b`
   
   > order 2
   1. add k8s regex ingress `/api/.*     --> svc-a`: `curl /api/bbb/ccc`: route to `svc-a`
   2. add k8s regex ingress `/api/bbb/.* --> svc-b`: `curl /api/bbb/ccc`: route to **`svc-a`** (???)
   3. delete k8s regex ingress `/api/.*     --> svc-a`: `curl /api/bbb/ccc`: route to `svc-b`
   4. add k8s regex ingress `/api/.*     --> svc-a`: `curl /api/bbb/ccc`: route to `svc-b`
   
   Is it a feature?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] mchtech commented on issue #1785: question: regex path route matching is unstable

Posted by "mchtech (via GitHub)" <gi...@apache.org>.
mchtech commented on issue #1785:
URL: https://github.com/apache/apisix-ingress-controller/issues/1785#issuecomment-1579098620

   We have used nginx as L7 LB about 10 years. There are 1000+ "location" rules in nginx configs. All rules are organtized by regex (`location ~ /regex`). (I don't know why. maybe 'regex location' can guarantee the order of rules and reduce probability of config errors)
   
   Because `add priority to the route` is not supported by ingress annotation and risks still exist when using `regex` match in k8s (include ingress-nginx)
   
   we refactor all the rules: convert `regex` match to `prefix` and `exact` match, and copy prod-env requests to test cluster to validate them.
   
   Thanks for your suggestion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1785: question: regex path route matching is unstable

Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on issue #1785:
URL: https://github.com/apache/apisix-ingress-controller/issues/1785#issuecomment-1514747627

   This is not a feature. If you have a strong dependency on the order of them, you can add priority to the route.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org