spring-cloud-netflix: Status Page and Health Indicator paths are broken if configuring custom management context path and using service inside docker
We are facing some problems with custom configured status page and health indicator paths.
We are using Spring Boot 1.5.10
and Spring Cloud Edgware.SR3
. We are using a Spring Boot application annotating @EnableEurekaServer
as the service registry. We are using a Spring Boot application annotating @EnableDiscoveryClient
acting as a business service. We have configured the business service the following way:
management:
context-path: /admin
eureka:
instance:
health-check-url-path: ${management.context-path}/health
status-page-url-path: ${management.context-path}/info
If we are starting up the services locally the business service registers to the service registry and is then accessible through the service registry UI. We also can access the business service management paths directly through a browser or postman like we have configured them. If we are running the service registry in debug mode we can see that the following informations are send:
"homePageUrl":"http://169.254.77.127:33800/"
"statusPageUrl":"http://169.254.77.127:33800/admin/info"
"healthCheckUrl":"http://169.254.77.127:33800/admin/health"
Means all is fine if running the services locally.
But if we are starting up the business service through docker the business service is registering to the eureka service in a way that the paths are looking like the following:
"homePageUrl":"http://169.254.77.127:33800/"
"statusPageUrl":"http://169.254.77.127:8080/admin/admin/info"
"healthCheckUrl":"http://169.254.77.127:8080/admin/admin/health"
As one can see, the path is in some way duplicated and the port is not matching the port of the home page url. If the service registry is running also in docker or locally is not making a difference. We are configuring the business service inside the docker-compose the following way:
business-service:
environment:
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: $EUREKA_URL
EUREKA_INSTANCE_HOSTNAME: $IP
JAVA_TOOL_OPTIONS: -Xmx128m -Deureka.instance.preferIpAddress=false -Deureka.instance.nonSecurePort=33800
SERVER_PORT: 8080
ports:
- 33800:8080
If we are changing the configuration the following way we can solve the problem with the different ports, but it is not solving the problem with the broken path:
business-service:
environment:
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: $EUREKA_URL
EUREKA_INSTANCE_HOSTNAME: $IP
JAVA_TOOL_OPTIONS: -Xmx128m -Deureka.instance.preferIpAddress=false
SERVER_PORT: 33800
ports:
- 33800:33800
We are more or less sure that we are still understanding and therefore doing something wrong. But playing further with the docker configuration did not solve the problem.
But… If we are switching (back) to Spring Cloud Dalston.SR5
all is fine and the services are working as expected (locally and through docker).
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (10 by maintainers)
Commits related to this issue
- Clarify health and status url context path docs. Fixes #2804. — committed to spring-cloud/spring-cloud-netflix by ryanjbaxter 6 years ago
@ryanjbaxter @spencergibb I would like to bring up this issue again because you marked it as ‘documentation’ but I don’t understand how this can solve our problem.
As @gbtec-ext-sergeyuzhakov mentioned here it looks like class DefaultManagementMetadataProvider is doing some stuff which breaks the expected behavior.
Maybe we are understand it wrong and configuring our system in a different way solves the problem. But if this is the case and if this is what you want to document we are really keen to see and try to understand the documentation you are about to enhance.
Otherwise it would be really nice if you could have a second look if the code is really doing what you think it should do.
In 1.4.0 spring-cloud-netflix-eureka-client DefaultManagementMetadataProvider was added. It seems the root cause for the issue. DefaultManagementMetadataProvider#get() returns /admin/admin/health if server.port != 0
Demo project was created to show the issue. https://github.com/gbtec-ag/health-indicator-dalston2edgware-issue By switching <version>Dalston.SR5</version> to <version>Edgware.RELEASE</version> in the pom.xml one can notice in http://localhost:8761/eureka/apps that <healthCheckUrl>http://127.0.0.1:22520/admin/health</healthCheckUrl> changes to <healthCheckUrl>http://127.0.0.1:22520/admin/admin/health</healthCheckUrl>