Skip to content

NameResolver refresh not triggered if empty addresses returned #5692

@pkwarren

Description

@pkwarren

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.20.0

What did you expect to see?

I've implemented a custom NameResolver to resolve addresses in Consul (DNS or HTTP). We're pairing this name resolver with the RoundRobinLoadBalancer to provide simple client-side load balancing.

While integration testing, I found that if we return an empty list of addresses in the name resolver, no refresh is ever triggered on the NameResolver (leading to a permanent error of UNAVAILABLE for all calls). If I change the NameResolver implementation to call Listener.onError() instead when no addresses are found, refresh() will eventually be triggered and the problem can resolve itself.

When writing the name resolver, I believe I may have gotten tripped up on this comment (which makes it sound like onAddresses() with an empty list is equivalent to onError()):

* @param servers the resolved server addresses. An empty list will trigger {@link #onError}

For reference, the DNS name resolver doesn't pass an empty list of addresses:

if (servers.isEmpty()) {
savedListener.onError(Status.UNAVAILABLE.withDescription(
"No DNS backend or balancer addresses found for " + host));
return;
}

I'm not sure if this is expected behavior and I know this is an experimental API, but wanted to report in case this wasn't the desired behavior.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions