Skip to content
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

Example configurations break proxying #410

Closed
jmezach opened this issue Sep 11, 2020 · 4 comments
Closed

Example configurations break proxying #410

jmezach opened this issue Sep 11, 2020 · 4 comments
Labels
Type: Bug Something isn't working

Comments

@jmezach
Copy link
Contributor

jmezach commented Sep 11, 2020

Describe the bug

I was following along with the example configurations provided in the docs and I received errors when trying to invoke one of my endpoints. Specifically I get the error:

System.InvalidOperationException: Chosen destination has no configs set: 'cluster1'
   at Microsoft.ReverseProxy.Middleware.ProxyInvokerMiddleware.Invoke(HttpContext context)
   at RR.ApiGateway.LegacyCookieAuthentication.LegacyCookieAuthenticationMiddleware.InvokeAsync(HttpContext context) in /Users/jonathanm/Projects/RR/RR.ApiGateway/LegacyCookieAuthentication/LegacyCookieAuthenticationMiddleware.cs:line 75
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

After doing some digging I found out that this is caused by the name of the destination. For example, using the following config (as seen in the docs) yields the error:

{
  "ReverseProxy": {
    "Routes": [
      {
        "RouteId": "route1",
        "ClusterId": "cluster1",
        "Match": {
          "Path": "{**catch-all}"
        },
      }
    ],
    "Clusters": {
      "cluster1": {
        "Destinations": {
          "cluster1/destination1": {
            "Address": "https://example.com/"
          }
        }
      }
    }
  }
}

However, changing the name of the destination to not include the slash and the error goes away. I'm pretty sure this used to work earlier, but I'm guessing something has changed since preview 3 when I last tried it. Perhaps it has to do with #357 but I'm not sure.

To Reproduce

Follow the docs to the letter and you should be able to reproduce this.

Further technical details

Version: 1.0.0-preview.4
Platform: macOS

@jmezach jmezach added the Type: Bug Something isn't working label Sep 11, 2020
@Tratcher
Copy link
Member

Tratcher commented Sep 11, 2020

I can't reproduce this on preview4 or master on Windows. Maybe it's a mac specific config binding issue? That would be odd.

If you set the "Microsoft" log category to "Debug" you should see something like this at startup:

info: Microsoft.ReverseProxy.Configuration.ConfigurationConfigProvider[1]
      Loading proxy data from config.
dbug: Microsoft.ReverseProxy.Service.Management.ProxyConfigManager[24]
      Destination 'cluster1/destination1' has been added.
dbug: Microsoft.ReverseProxy.Service.Management.ProxyConfigManager[21]
      Cluster 'cluster1' has been added.
dbug: Microsoft.ReverseProxy.Service.Management.ProxyConfigManager[27]
      Route 'route1' has been added.
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[0]
      Using development certificate: CN=localhost (Thumbprint: 6AF99613A8A925A8A954AB17BFE46919DDEAD7A0)
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
dbug: Microsoft.AspNetCore.Hosting.Diagnostics[0]
      Loaded hosting startup assembly MyProxy
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.

Note the destination name. What do you see in your logs?

That should match what's reported in the exception here:

throw new InvalidOperationException($"Chosen destination has no configs set: '{destination.DestinationId}'");

@jmezach
Copy link
Contributor Author

jmezach commented Sep 11, 2020

Hmm, I just tried it again on my dev box and I can't reproduce it there either. Difference is that on my dev box I'm using just the appsettings.development.json file. But in my test environment I'm loading config from Consul using Winton.Extensions.Configuration.Consul which plugs into ASP.NET Core's configuration framework. My guess is that there's something funky going on there, although I think I've seen this combination work properly before.

I'll file an issue with that library to see if they can figure out what's going on here. I don't think its a YARP problem at the moment. If that changes I'll re-open this issue.

@jmezach
Copy link
Contributor Author

jmezach commented Sep 14, 2020

@Tratcher Turns out this was indeed an issue in the library I was using. They are working on a fix and I've already verified that the fix works. Sorry to bother you with this.

@Tratcher
Copy link
Member

Glad you got it sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants