c0c0n3 / kitt4sme.live

On a mission to bring AI to the shop floor: https://kitt4sme.eu/
MIT License
1 stars 28 forks source link

Platform configurator routing #273

Closed c0c0n3 closed 8 months ago

c0c0n3 commented 1 year ago

Describe the bug

The Istio URL-path routing for Platform Configurator maps /platform-configurator to / but it looks like this doesn't work at least for the /platform-configurator/kits path which gets redirected to /kits instead of /platform-configurator/kits/.

To Reproduce

Open a terminal and run

$ curl -i https://kitt4sme.collab-cloud.eu/platform-configurator/kits/

You should see the response contains a redirect to http://kitt4sme.collab-cloud.eu/kits

HTTP/2 307 
date: Sat, 29 Apr 2023 10:44:01 GMT
server: istio-envoy
content-length: 0
location: http://kitt4sme.collab-cloud.eu/kits
x-envoy-upstream-service-time: 41

If you look at the K8s logs, you should see Platform Configurator actually issues a redirect to /kits:

$ kubectl logs deployment/platform-configurator
INFO:     Started server process [1]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     127.0.0.6:46539 - "GET /kits/ HTTP/1.1" 307 Temporary Redirect

Expected behavior

HTTP clients external to the mesh should be redirected to URLs starting with a path of /platform-configurator/, e.g. /platform-configurator/kits.

Additional context

The above could be done e.g. by changing the Istio routing to

  - match:
    - uri:
        prefix: /platform-configurator/
    route:
    - destination:
        host: platform-configurator.default.svc.cluster.local
        port:
          number: 8000

(notice there's no URL rewrite anymore) and then configuring the Platform Configurator Python app to serve URLs with a base path of /platform-configurator.

vcutrona commented 1 year ago

Hi @c0c0n3 I tried the same with

$ curl -i https://kitt4sme.collab-cloud.eu/platform-configurator/kits

(no trailing slash) and it works fine. It may be because the Platform Configurator handles the request /kits, but not /kits/. What do you think? We're using FastAPI to serve the application, and the issue has been discussed here: https://github.com/tiangolo/fastapi/issues/2060.

vcutrona commented 8 months ago

This bug has been already fixed. However, with the new subdomain-based routing, both requests work (with and without the trailing slash).