ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.4k stars 1.64k forks source link

Update from 18.0.0 to 23.0.0 broke upstream URLs with 503 #2130

Open patolax opened 4 months ago

patolax commented 4 months ago

Expected Behavior / New Feature

The following routes work 18.0.0 version.

    {
      "UpstreamPathTemplate": "/api/{version}/adapter/resources/firmware",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/resources/firmware",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },
    {
      "UpstreamPathTemplate": "/api/{version}/adapter/resources/script",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/resources/script",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },

Actual Behavior / Motivation for New Feature

However, the 23.3.3 upgrade returns 503 now.

If I make changes to adapter segment of the UpstreamPathTemplate paths to say, first route adapterX and seconde route to adapterY. Things start to work

Steps to Reproduce the Problem

Add this config on 23.3.3

    {
      "UpstreamPathTemplate": "/api/{version}/adapter/resources/firmware",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/resources/firmware",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },
    {
      "UpstreamPathTemplate": "/api/{version}/adapter/resources/script",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/resources/script",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },

Specifications

raman-m commented 4 months ago

Hello Tha!

The following routes work 18.0.0 version. However, the 23.3.3 upgrade returns 503 now.

Could you please attach the content of your logs? I need to review the text of the error message.

To identify the root cause, could you please downgrade from version 23.3.3 to 19.0.0 changing for each major version? This step will assist in pinpointing the precise version that contains the bug and potentially the specific feature that is malfunctioning.


    {
      "UpstreamPathTemplate": "/api/{version}/adapter/resources/firmware",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/resources/firmware",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },
    {
      "UpstreamPathTemplate": "/api/{version}/adapter/resources/script",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/resources/script",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },

and

Subsystem: Service Fabric

The configuration appears correct and should function, but there might be issues, particularly with Service Fabric. Have you considered using a single Catch All route for routing purposes? It looks like both routes could be combined as follows:

    {
      "UpstreamPathTemplate": "/api/{version}/adapter/{everything}",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/api/{version}/adapter/{everything}",
      "DownstreamScheme": "http",
      "ServiceName": "Cloud.Services/adapterService"
    },

Please try this configuration in version 23.3.3 and inform us of the outcome.

raman-m commented 4 months ago

Top Task

Firstly, it's crucial to determine whether this bug is part of version 23.3.3. The most critical test involves downgrading to version 23.2.2 ❗ If version 23.2.2 is not affected by this bug, then it will be included in the v23.3 Hotfixes milestone.

patolax commented 4 months ago

See below for test results of different versions.

18.0.0 OK 19.0.4 OK 20.0.0 OK 21.0.0 OK 22.0.0 OK 23.0.0 NOT OK (503) 23.3.3 NOT OK (503)

Only two paths fail, others work fine.

I will rollback to 22.0.0.

raman-m commented 4 months ago

Thank you for the testing! It's beneficial that this issue is not part of the v23.3 Hotfixes milestone, which aids in faster delivery. It appears the root cause emerged in version 23.0.0. The changes between 22.0.1...23.0.0 need to be reviewed to pinpoint which specific feature affects the Service Fabric path matching. Likely, it is the commit https://github.com/ThreeMammals/Ocelot/commit/f4803c24bf9e9ca3929c78ca8eb23401e3c31c23