With Spring Boot Actuator health check endpoint, we can use management.endpoint.health.status.http-mapping.<status> to map a custom status to an HTTP status code. But for Eureka integration, any custom status would map to UNKNOWN status in Eureka since the mapping is not configurable (https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandler.java#L61-L64). It would be nice if we can map custom statuses to UP/DOWN/OUT_OF_SERVICE via properties similar to the health check endpoint HTTP status mapping.
Comment From: OlgaMaciaszek
@kzwang Thanks for submitting this. Would you be interested in creating a PR?
Comment From: beatfreaker
@OlgaMaciaszek Can I work on this ?
Also, before implementing it just wanted to verify if below approach is correct or not
So here at this line EurekaHealthCheckHandler.java#L172 we will receive status returned by Spring Boot Actuator, and in case of custom http-mapping we will receive Status with custom code
So we can have configuration where dev can provide mapping between Actuator custom status and eureka InstanceStatus
for example:
eureka.client.status.mapping.fatal=OUT_OF_SERVICE
eureka.client.status.mapping.custom-actuator-status=UP
which means if actuator returns Status with code fatal we will convert it into InstanceStatus.OUT_OF_SERVICE
and if Status with code custom-actuator-status is received we will convert it into InstanceStatus.UP
Comment From: mxalis
As discussed here the only valid transitions are
STARTING -> UP UP <-> DOWN
So if you ever set the status to OUT_OF_SERVICE, you will not be able to recover back to UP without restarting the service