Skip to content

DiscoveryClientHealthIndicator does not respect "light weight operation" of probe() when using CompositeDiscoveryClient #1209

@sruffatti

Description

@sruffatti

I am using spring-cloud-consul. Spring Cloud Consul constructs a ConsulDiscoveryClient, which has an override for DiscoveryClient.probe() for a light weight operation. This lightweight operation is not respected when spring.cloud.discovery.client.health-indicator.use-service-query, is set to false and there are multiple DiscoveryClient beans.

The DiscoveryClientHealthIndicator performs the following operation in the method, health().

if (properties.isUseServicesQuery()) {
	List<String> services = client.getServices();
	builder.status(new Status("UP", description)).withDetail("services", services);
}
else {
	client.probe();
	builder.status(new Status("UP", description));
}

If the property, spring.cloud.discovery.client.health-indicator.use-service-query, is set to false then the DiscoveryClient should use the light weight probe() instead of getServices(). In the case where the client is of type CompositeDiscoveryClient, we end up executing getServices() because the CompositeDiscoveryClient does not override the implementation for probe(). Instead, it uses the default implementation of DiscoveryClient.getProbe(), which calls DiscoveryClient.getServices().

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions