-
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
balancer/leastrequest: Add least request balancer #6510
Conversation
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'll wait on reviewing the tests until the e2e-style ones are done.
93db4be
to
0ce88c9
Compare
defer func() { | ||
stream.CloseSend() | ||
if _, err = stream.Recv(); err != io.EOF { | ||
t.Fatalf("unexpected error: %v, expected an EOF error", err) | ||
} | ||
}() |
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 think we can just delete all of this and rely on ctx's cancelation to clean up everything.
Same with the other test. Just make the server's handler do a <-stream.Context().Done()
instead of doing a stream.Recv()
in a loop.
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.
Done.
stream.CloseSend() // Finish stream to populate peer. | ||
if _, err = stream.Recv(); err != io.EOF { | ||
t.Fatalf("unexpected error: %v, expected an EOF error", err) | ||
defer func() { |
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.
Same
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.
Done.
if err != nil { | ||
t.Fatalf("testServiceClient.FullDuplexCall failed: %v", err) | ||
} | ||
defer func() { |
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.
Same
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.
Done.
gotAddrCount[p.Addr.String()]++ | ||
} | ||
} | ||
if diff := cmp.Diff(gotAddrCount, wantAddrCount); diff != "" { |
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.
Nit: if you're not showing the diff, just use !cmp.Equal()
instead. (Also in checkRoundRobin
.)
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.
Printed diff here. In check round robin no need for diff so just used !cmp.Equal().
if !ok { | ||
t.Fatalf("testServiceClient.FullDuplexCall has no Peer") | ||
} | ||
if p.Addr != nil { |
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.
Optional: IMO it's cleaner to remove the defensive programming and just let things panic if they're breaking assertions:
p, _ := peer.FromContext(stream.Context)
gotAddrCount[p.Addr.String()]++
But this is fine, 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.
Done.
This PR adds the least request load balancer, speced in https://github.com/grpc/proposal/blob/master/A48-xds-least-request-lb-policy.md.
RELEASE NOTES: