-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
endpointsharding, lazy: Remove intermediary gracefulswitch balancers #8052
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8052 +/- ##
==========================================
- Coverage 82.29% 82.17% -0.12%
==========================================
Files 384 387 +3
Lines 38926 38981 +55
==========================================
Hits 32034 32034
- Misses 5565 5610 +45
- Partials 1327 1337 +10
|
83370dd
to
0bc66fd
Compare
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.
Mostly looks fine, but the minor API thing should be decided.
@@ -100,7 +99,7 @@ func (crr *customRoundRobin) UpdateClientConnState(state balancer.ClientConnStat | |||
// is guaranteed to happen since the aggregator will always call | |||
// UpdateChildState in its UpdateClientConnState. | |||
return crr.Balancer.UpdateClientConnState(balancer.ClientConnState{ | |||
BalancerConfig: gracefulSwitchPickFirst, | |||
BalancerConfig: nil, // pickfirst can handle nil configs. |
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.
Delete the field entirely to remove complications from example?
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.
Removed throughout.
@@ -236,7 +233,7 @@ func (b *wrrBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error | |||
// This causes child to update picker inline and will thus cause inline | |||
// picker update. | |||
return b.child.UpdateClientConnState(balancer.ClientConnState{ | |||
BalancerConfig: endpointShardingLBConfig, | |||
BalancerConfig: nil, // pickfirst can handle nil configs. |
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.
And then I'd delete it from all our code to avoid clutter. Most LB policies should handle not having configs, except some special xds things.
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.
Removed.
// NewBalancer returns a load balancing policy that manages homogeneous child | ||
// policies each owning a single endpoint. The endpointsharding balancer | ||
// forwards the LoadBalancingConfig in ClientConn state updates to its children. | ||
func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions, childBuilder balancer.Builder, esOpts Options) balancer.Balancer { |
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 wondering about the signature here.
There's a lot of options:
- Keep this & make anyone wanting to use es+lazy wrap lazy in a Builder implementation.
- Keep this & implement a Builder in
lazy
, still. - Create
type ChildBuilder interface { Build(..) .. }
withoutName()
and makelazy
implement that. - Accept a function matching the signature of
Build
here.
None of these are great. I think I might like (4) the best for usability? But I dislike it for understandability. I suppose that could be helped with:
type ChildBuilder = func(...) ... // matching Build
?
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.
Changed to use a type alias. Didn't export the ChildBuilder
type since it's only an alias.
balancer/lazy/lazy.go
Outdated
|
||
func (builder) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Balancer { | ||
// NewBalancer is the constructor for the lazy balancer. | ||
func NewBalancer(cc balancer.ClientConn, bOpts balancer.BuildOptions, childBuilder balancer.Builder) balancer.Balancer { |
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.
The same concerns as above apply here, too.
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.
Changed, using an alias to the type of the balancer.Build
method now.
Presently both
lazy
andendpointsharding
creategracefulswtich
balancers to manage their children. Thegracefulswitch
balancer is unnecessary as the type of the child balancer in not expected to change in existing use cases. Having thegracefulswitch
child requires the child balancer's builder to be registered in the global LB registry. Thelazy
LB is not a complete LB policy and should not be registered globally.This PR makes the constructors of
endpointpointsharding
andlazy
accept the child balancer's builder to avoid using the global registry. This PR also removes theParseConfig
functions/methods inlazy
andendpointsharding
as they will simply forward theLoadBalancingConfig
s to their children. The children are responsible to parse theLoadBalancingConfig
JSON. Sincepickfirst
can use anil
LoadBalancingConfig
, the existing users ofendpointsharding
don't need to provide aLoadBalancingConfig
.RELEASE NOTES:
DisableAutoReconnect
option will not attempt to callExitIdle
automatically on their children when the children report idle.