spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.18k stars 758 forks source link

Load balancer does not contain an instance for the service [EKS environment] #719

Closed billelmehdi closed 1 year ago

billelmehdi commented 2 years ago

Hi, I have few services deployed in EKS and some of them have issues to be reached.

I have this exception:

2022-06-01 11:27:39.383  WARN 1 --- [nio-8080-exec-3] o.s.c.l.core.RoundRobinLoadBalancer      : No servers available for service: backend-service
2022-06-01 11:27:39.383  WARN 1 --- [nio-8080-exec-3] .s.c.o.l.FeignBlockingLoadBalancerClient : Load balancer does not contain an instance for the service backend-service
2022-06-01 11:27:39.385 ERROR 1 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.FeignException$ServiceUnavailable: [503] during [GET] to [http://backend-service/api/v1/provider?areas&services=103] [ServicesProxy#findProvidersByLocationAndService(Integer[],Integer[])]: [Load balancer does not contain an instance for the service backend-service]] with root cause

feign.FeignException$ServiceUnavailable: [503] during [GET] to [http://backend-service/api/v1/provider?areas&services=103] [ServicesProxy#findProvidersByLocationAndService(Integer[],Integer[])]: [Load balancer does not contain an instance for the service services-service]
        at feign.FeignException.serverErrorStatus(FeignException.java:237) ~[feign-core-10.12.jar:na]

caller application.yaml:

server:
  port: 8080
  shutdown: graceful
spring:
  config:
    activate:
      on-profile: prod
  lifecycle:
    timeout-per-shutdown-phase: 10s
feign:
  client:
    config:
      default:
        connectTimeout: 10000
        readTimeout: 50000

I also added both annotations to main class:

@EnableDiscoveryClient
@EnableFeignClients("com.wheels.search")

caller class:

@FeignClient(name="backend-service")
public interface ServicesProxy {...}

here is an extract of the pom:

<spring-cloud.version>2020.0.4</spring-cloud.version>
spring boot v <version>2.5.5</version>

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-kubernetes-all</artifactId>
            <version>1.1.10.RELEASE</version>
        </dependency>
OlgaMaciaszek commented 1 year ago

Hello @billelmehdi; The Spring Cloud Kubernetes version compatible with Spring Cloud 2020.0.4 is 2.1.3. You should not need to specify it at all, but just get it from the bom (dependencyManagement). Please fix that and verify if the issue persists.

spring-cloud-issues commented 1 year ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 1 year ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.