I have a manager application that uses Eureka to discover worker applications. Both are using Spring Cloud Netflix and the auto configurations that they provide to do service registration and discovery.
Occasionally the manager marks an instance as OUT_OF_SERVICE and some time later (on the order of minutes) marks the same instance as UP.
The manager discovers instances using the CloudEurekaClient, and then sets its status:
@Autowired
private CloudEurekaClient cloudEurekaClient;
...
InstanceInfo instance = cloudEurekaClient.getNextServerFromEureka(WORKER_SERVICE_NAME, false);
cloudEurekaClient.setStatus(InstanceInfo.InstanceStatus.OUT_OF_SERVICE, instance);
// do some work
cloudEurekaClient.setStatus(InstanceInfo.InstanceStatus.UP, instance);
This seems to work well. The Eureka server status page shows my instances going from UP to OUT_OF_SERVICE:
However, the CloudEurekaClient doesn't seem to know that an instance is OUT_OF_SERVICE. Instead, using the debugger, I have found that the instance has a status of UP and overridenStatus of UNKNOWN:
Note: If I call cloudEurekaClient.getApplication("worker").getInstances() it shows the 4 UP instances, but no mention of the one that is OUT_OF_SERVICE.
Is this expected? I assumed the eureka client would know that an instance is OUT_OF_SERVICE, but that's not the behavior I'm seeing. This causes problems for a health indicator I have that uses the CloudEurekaClient to show the number of UP and OUT_OF_SERVICE instances.

