-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
KubernetesService discovery by KubernetesService discovery by KubernetesService DiscoveryOcelot feature: Service DiscoveryOcelot feature: Service DiscoveryquestionInitially seen a question could become a new feature or bug or closed ;)Initially seen a question could become a new feature or bug or closed ;)wontfixNo plan to include this issue in the Ocelot core functionality.No plan to include this issue in the Ocelot core functionality.
Description
Both Ocelot API and Price API are running on K8s
There are my source code for Ocelot
packages
<PackageReference Include="Ocelot" />
<PackageReference Include="Ocelot.Provider.Kubernetes" />Program.cs
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Kubernetes;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("ocelot.json", optional: false, reloadOnChange: true)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
builder.Services.AddOcelot()
.AddKubernetes();
var app = builder.Build();
app.UseOcelot().Wait();
app.Run();ocelot.json
{
"Routes": [
{
"Servicename": "price-webapi",
"DownstreamPathTemplate": "/api/price/{everything}",
"UpstreamPathTemplate": "/api/price/{everything}",
"UpstreamHttpMethod": [ "GET", "POST", "PUT", "DELETE" ],
"UseServiceDiscovery": true,
"LoadBalancerOptions": {
"Type": "RoundRobin"
}
}
],
"GlobalConfiguration": {
"ServiceDiscoveryProvider": {
"Type": "Kube",
"Namespace": "cafef-dev1"
}
}
}When I use url from ocelot to route to price-api, I got this error:
[05:33:59 WRN] requestId: 0HN8FDP0KCCDL:00000001, previousRequestId: No PreviousRequestId, message: 'Ocelot Retry strategy for the operation of 'System.Func`1[System.Threading.Tasks.Task`1[KubeClient.Models.EndpointsV1]]' type -> Retry No 1: The predicate has identified erroneous state in the returned result. For further details, implement logging of the result's value or properties within the predicate method.'
[05:33:59 WRN] requestId: 0HN8FDP0KCCDL:00000001, previousRequestId: No PreviousRequestId, message: 'Ocelot Retry strategy for the operation of 'System.Func`1[System.Threading.Tasks.Task`1[KubeClient.Models.EndpointsV1]]' type -> Retry No 2: The predicate has identified erroneous state in the returned result. For further details, implement logging of the result's value or properties within the predicate method.'
[05:33:59 WRN] requestId: 0HN8FDP0KCCDL:00000001, previousRequestId: No PreviousRequestId, message: 'Kube provider. Namespace:cafef-dev1, Service:price-webapi; Unable to use bad result returned by Kube integration endpoint because the final result is invalid/unknown after multiple retries!'
[05:33:59 WRN] requestId: 0HN8FDP0KCCDL:00000001, previousRequestId: No PreviousRequestId, message: 'Error Code: ServicesAreEmptyError Message: There were no services in RoundRobin for 'price-webapi' during LeaseAsync operation! errors found in ResponderMiddleware. Setting error response for request path:/api/price/v1/values, request method: GET'
[05:33:59 INF] Request finished HTTP/1.1 GET http://10.5.45.161:31901/api/price/v1/values - 404 0 null 2147.6126ms
I checked in ocelot api's pod with:
curl http://price-webapi.cafef-dev1.svc.cluster.local:9100/api/price/v1/valuesand got success result.
Please help me fix this issue!
Thanks a lot!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
KubernetesService discovery by KubernetesService discovery by KubernetesService DiscoveryOcelot feature: Service DiscoveryOcelot feature: Service DiscoveryquestionInitially seen a question could become a new feature or bug or closed ;)Initially seen a question could become a new feature or bug or closed ;)wontfixNo plan to include this issue in the Ocelot core functionality.No plan to include this issue in the Ocelot core functionality.