-
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
roundrobin: Delegate subchannel creation to pickfirst #7966
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7966 +/- ##
=======================================
Coverage 82.29% 82.29%
=======================================
Files 387 387
Lines 39065 39067 +2
=======================================
+ Hits 32147 32152 +5
- Misses 5582 5602 +20
+ Partials 1336 1313 -23
|
01ef7af
to
3a594f6
Compare
balancer/roundrobin/roundrobin.go
Outdated
|
||
func init() { | ||
balancer.Register(newBuilder()) | ||
var err error | ||
endpointShardingLBConfig, err = endpointsharding.ParseConfig(json.RawMessage(endpointsharding.PickFirstConfig)) |
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 was in the other PR, too.
Probably we should have endpointsharding
produce a parsed PF config if it's going to be used frequently?
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.
test/roundrobin_test.go
Outdated
@@ -173,7 +175,9 @@ func (s) TestRoundRobin_NewAddressWhileBlocking(t *testing.T) { | |||
|
|||
// Send a resolver update with a valid backend to push the channel to Ready | |||
// and unblock the above RPC. | |||
r.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: backends[0].Address}}}) | |||
r.UpdateState(resolver.State{Endpoints: []resolver.Endpoint{ |
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 needed to be done eventually. But maybe for similar things in the future...it could have been easier for this PR (and may still be easier when dealing with future migration PRs) to make the manual resolver's UpdateState
and InitialState
methods set Endpoints
according to the default behavior if it's unset.
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 change was not required since the code to populate endpoints based using addresses is present in resolver_wrapper.go:
Lines 125 to 132 in f35fb34
if s.Endpoints == nil { | |
s.Endpoints = make([]resolver.Endpoint, 0, len(s.Addresses)) | |
for _, a := range s.Addresses { | |
ep := resolver.Endpoint{Addresses: []resolver.Address{a}, Attributes: a.BalancerAttributes} | |
ep.Addresses[0].BalancerAttributes = nil | |
s.Endpoints = append(s.Endpoints, ep) | |
} | |
} |
I've reverted changes to tests that use the manual resolver. In tests that call balancer.UpdateClientConnState
directly, without creating a real channel, conversion from addresses to endpoints is required.
balancer/roundrobin/roundrobin.go
Outdated
func (b *rrBalancer) ExitIdle() { | ||
// Should always be ok, as child is endpoint sharding. | ||
if ei, ok := b.child.(balancer.ExitIdler); ok { | ||
ei.ExitIdle() | ||
} | ||
} |
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 is still necessary, unfortunately, as only balancer.Balancer
functions are transferred when embedding.
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.
Reverted.
Closing for now and prioritizing the changes to make Ringhash a petiole policy. Will also make the changes to have the metrics recorder retrieved from a method on the ClientConn as per the offline discussion. Will re-open when I'm back on this. |
This PR switches round round robin to defer to pick first instead of creating and handling SubConns itself. This is part of Dualstack, and makes this a petiole. This PR makes roundrobin a wrapper around the endpoint sharding policy that implements the roundrobin logic.
RELEASE NOTES:
Endpoints
field instead of theAddresses
field in resolver state updates.