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
what is the output of /health which is what eureka.client.healthcheck.enabled=true translates to send to eureka.
/health endpoint says UP
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 ?
no, static port
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.
Ok created a sample Repository
https://github.com/ukleeberger/unkown_issue/tree/master
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.
Thx that was the problem. Now everything works as expected.
To add more explicit note
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???
I am not even sure what the problem is. Please open a separate issue which clearly states what the problem is.
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: 6379this 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: 601 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 :).
Most helpful comment
According to the documentation,
eureka.client.healthcheck.enabledshould be set inapplication.yml. In your example you are setting it inbootstrap.yml. When you move that property toapplication.ymlyou no longer have theUNKOWNstatus.