-
Notifications
You must be signed in to change notification settings - Fork 3.9k
core, grpclb: change policy selection strategy for Grpclb policy (take two: move logic of querying SRV into Grpclb's own resolver) #6723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core, grpclb: change policy selection strategy for Grpclb policy (take two: move logic of querying SRV into Grpclb's own resolver) #6723
Conversation
…, service config, balancer addresses. Subclass is able to override the resolve logic.
…r will provide GrpclbNameResolver directly. This also eliminate the enableSrv flag.
deb0e12
to
49f7240
Compare
df1d33d
to
d3c6ba1
Compare
I use the Having to use EDIT: Or am I miss-reading this PR and it turns dns+srv on by default? |
This PR is part of the implementation for https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md. The previous part is #6637. I updated the title of this PR. We are eliminating the usage of SRV records other than in gRPCLB. Previously, this is special logic in grpc-core for gRPCLB's design. The system variable How do you use SRV records? Did you implement a special way to use SRV resolved addresses? We expect SRV records are for remote balancer addresses. This is true in existing grpc-core as SRV resolved addresses are tagged with For your case, I believe you would need to implement your own DNS-based name resolver as you are exploiting the internal implementation of |
@ST-DDT, in 1.25.0 we added a dns name resolver to the You should just need to depend on |
} | ||
|
||
@Override | ||
protected boolean doResolve(Listener2 listener) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not wild about how coupled the GrpclbNameResolver is to DnsNameResolver. It looks quite brittle. This method seems to be the biggest issue.
We may want to discuss in person, but it seems we could try to do a delegation strategy or have the caller of this method notify the listener
. Both of those seem to allow a super.doResolve()
approach to let the base class do its work (instead of copying it here and treating the base class as a utility class). As it stands, it would be more straight-forward to have a shared utility class instead of extend
ing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworked this method extension. Introduced an struct for grouping components of resolution result, caller of this method will populate items out and invoke the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am a bit afraid, but refactoring looks good.
grpclb/src/main/java/io/grpc/grpclb/SecretGrpclbNameResolverProvider.java
Show resolved
Hide resolved
grpclb/src/test/java/io/grpc/grpclb/GrpclbNameResolverTest.java
Outdated
Show resolved
Hide resolved
…ervice config resolution in child class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Do not merge until #6705 is merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code organization looks much better. I'm not approving since I've not really done a review, but what I see seems good.
…query_srv_logic_into_grpclb
…e two: move logic of querying SRV into Grpclb's own resolver) (grpc#6723) Eliminated the code path of resolving Grpclb balancer addresses in grpc-core and moved it into GrpclbNameResolver, which is a subclass of DnsNameResolver. Main changes: - Slightly changed ResourceResolver and its JNDI implementation. ResourceResolver#resolveSrv(String) returns a list of SrvRecord so that it only parse SRV records and does nothing more. It's gRPC's name resolver's logic to use information parsed from SRV records. - Created a GrpclbNameResolver class that extends DnsNameResolver. Logic of using information from SRV records to set balancer addresses as ResolutionResult attributes is implemented in GrpclbNameResolver only. - Refactored DnsNameResolver, mainly the resolveAll(...) method. Logics for resolving backend addresses and service config are modularized into resolveAddresses() and resolveServiceConfig() methods respectively. They are shared implementation for subclasses (i.e., GrpclbNameResolver).
This is the second part of implementation for gRPCLB selection. Previous part is #6637.
Main changes in this PR:
Slightly changed
ResourceResolver
and its JNDI implementation.ResourceResolver#resolveSrv(String)
returns a list ofSrvRecord
so that it only parse SRV records and does nothing more. It's gRPC's name resolver's logic to use information parsed from SRV records.Created a
GrpclbNameResolver
class that extendsDnsNameResolver
. Logic of using information from SRV records to set balancer addresses as ResolutionResult attributes is implemented inGrpclbNameResolver
only.Refactored
DnsNameResolver
, mainly theresolveAll(...)
method. Logics for resolving backend addresses and service config are modularized intoresolveAddresses()
andresolveServiceConfig()
methods respectively. They are shared implementation for subclasses (i.e.,GrpclbNameResolver
).TODO:
AltsProtocolNegotiator
has some special logic for creating channel handler, which depends on the implementation detail that grpclb balancer addresses are tagged withATTR_LB_ADDR_AUTHORITY
attributes. We may want to eliminate it and clean upGrpcAttributes. ATTR_LB_ADDR_AUTHORITY
.grpc-alts
module already depends ongrpc-grpclb
, we can still clean upGrpcAttributes. ATTR_LB_ADDR_AUTHORITY
and let it useGrpclbConstants. ATTR_LB_ADDR_AUTHORITY
. I will do that clean up in a separate PR.