spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

Status UNKNOWN with Eureka and Config Server

Open ukleeberger opened this issue 10 years ago • 12 comments

Hi Guys,

we encountered a strange behavior with an Spring Boot app registered to an Eureka Server with use of a Config Server. If we set eureka.client.healthcheck.enabled=true and spring.cloud.config.discovery.enabled=true the app is registered to Eureka with an Status of UNKNOWN. If you disable the healthcheck it all works as expected. We are using Brixton.SR4 and Boot 1.4.0.RELEASE

This seems to be the same problem : http://stackoverflow.com/questions/38578705/springboot-app-registers-unknown-with-eureka-in-brixton-sr3

ukleeberger avatar Aug 18 '16 15:08 ukleeberger

what is the output of /health which is what eureka.client.healthcheck.enabled=true translates to send to eureka.

spencergibb avatar Aug 18 '16 16:08 spencergibb

/health endpoint says UP

ukleeberger avatar Aug 18 '16 16:08 ukleeberger

From a personal recent experience, an unknown status from eureka with your actuactor endpoints showing UP usually means that the your discovery client didnt't called back Eureka to register it's server port once the servlet container has booted. Is your app defined with server.port=0 ?

daniellavoie avatar Aug 18 '16 17:08 daniellavoie

no, static port

ukleeberger avatar Aug 18 '16 17:08 ukleeberger

Could you provide a repository of a project containing an eureka server and eureka config simulating the problem ? The Eureka Client bootstrapping is sensitive, lots of race conditions involved.

daniellavoie avatar Aug 18 '16 20:08 daniellavoie

Ok created a sample Repository https://github.com/ukleeberger/unkown_issue/tree/master

ukleeberger avatar Aug 20 '16 08:08 ukleeberger

According to the documentation, eureka.client.healthcheck.enabled should be set in application.yml. In your example you are setting it in bootstrap.yml. When you move that property to application.yml you no longer have the UNKOWN status.

ryanjbaxter avatar Aug 22 '16 14:08 ryanjbaxter

Thx that was the problem. Now everything works as expected.

ukleeberger avatar Aug 24 '16 15:08 ukleeberger

To add more explicit note

spencergibb avatar Aug 30 '16 15:08 spencergibb

So, the current practice is to have some configuration, such as the following configuration

# user/bootstrap.yml
spring.application.name: user

register.center: http://127.0.0.1:8761/eureka/,xxx
eureka:
  client:
    registry-fetch-interval-seconds: 20
    serviceUrl.defaultZone: ${register.center}

spring.cloud.config:
  discovery.enabled: true
  discovery.serviceId: config-server
  name: all,user
  profile: dev

management.endpoints.web.exposure.include: "*"

To write to bootstrap.yml, there are more environments (dev, test, production), so there are more files (bootstrap-test.yml, bootstrap-prod.yml),

and then some configuration must be written in config-server, it is divided into different environments, so there is a corresponding user-dev.yml user-test.yml user-prod.yml configuration, which is used to save like this

# config-server/user-dev.yml
spring:
  datasource:
    url: jdbc:mysql://ip:port/db
    username: root
    password: root
    hikari:
      minimumIdle: xx
      maximumPoolSize: xx
  redis:
    host: 127.0.0.1
    port: 6379

this config can be load with lcation or git svn etc...

Finally, I have to create application.yml applocation-test.yml, application-prod.yml in each project to save the following configuration.

# user/application.yml
eureka:
  client.healthcheck.enabled: true
  instance:
    prefer-ip-address: true
    lease-renewal-interval-in-seconds: 20
    lease-expiration-duration-in-seconds: 60

1 server have 9 configuration, Are you sure this is not funny???

liuanxin avatar Sep 02 '18 04:09 liuanxin

I am not even sure what the problem is. Please open a separate issue which clearly states what the problem is.

ryanjbaxter avatar Sep 04 '18 15:09 ryanjbaxter

So, the current practice is to have some configuration, such as the following configuration

# user/bootstrap.yml
spring.application.name: user

register.center: http://127.0.0.1:8761/eureka/,xxx
eureka:
  client:
    registry-fetch-interval-seconds: 20
    serviceUrl.defaultZone: ${register.center}

spring.cloud.config:
  discovery.enabled: true
  discovery.serviceId: config-server
  name: all,user
  profile: dev

management.endpoints.web.exposure.include: "*"

To write to bootstrap.yml, there are more environments (dev, test, production), so there are more files (bootstrap-test.yml, bootstrap-prod.yml),

and then some configuration must be written in config-server, it is divided into different environments, so there is a corresponding user-dev.yml user-test.yml user-prod.yml configuration, which is used to save like this

# config-server/user-dev.yml
spring:
  datasource:
    url: jdbc:mysql://ip:port/db
    username: root
    password: root
    hikari:
      minimumIdle: xx
      maximumPoolSize: xx
  redis:
    host: 127.0.0.1
    port: 6379

this config can be load with lcation or git svn etc...

Finally, I have to create application.yml applocation-test.yml, application-prod.yml in each project to save the following configuration.

# user/application.yml
eureka:
  client.healthcheck.enabled: true
  instance:
    prefer-ip-address: true
    lease-renewal-interval-in-seconds: 20
    lease-expiration-duration-in-seconds: 60

1 server have 9 configuration, Are you sure this is not funny???

And then you have the configuration service, so, there is much more source of truth :).

jfsanchez91 avatar Mar 18 '19 10:03 jfsanchez91