Skip to content
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

grpclb: enter fallback if no balancer addresses are available #3119

Merged
merged 8 commits into from Oct 31, 2019

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Oct 22, 2019

This is necessary because there's another way to select grpclb (by specifying grpclb in service config's balancing policy field). So it's possible that grpclb is picked, but resolver doesn't have any balancer addresses.

When an update without balancer address is received, grpclb closes the underlying ClientConn to remote balancer, and enters fallback mode.

Note that grpclb waits until the ClientConn and the RPC goroutines are actually closed to do the fallback work. This can avoid race caused by async close.

fixes #3064

@@ -426,6 +426,8 @@ func (lb *lbBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error

addrs := ccs.ResolverState.Addresses
if len(addrs) == 0 {
// There's should be at least one address, either grpclb server or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

PermitWithoutStream: true,
}))

// DialContext using manualResolver.Scheme, which is a random scheme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer accurate (both parts).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return nil, nil, errors.New("received unexpected server name")
if authority != string(b) {
fmt.Printf("test-creds: got authority from ClientConn %q, expected by server %q\n", authority, string(b))
return nil, nil, errors.New("received unexpected server nameq")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nameq?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dfawley dfawley assigned menghanl and unassigned dfawley Oct 29, 2019
@menghanl menghanl force-pushed the grpclb_fallback_noBalancerAddress branch from 46a2366 to e86ba20 Compare October 30, 2019 19:01
@menghanl menghanl merged commit 459a38a into grpc:master Oct 31, 2019
@menghanl menghanl deleted the grpclb_fallback_noBalancerAddress branch October 31, 2019 16:43
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

grpclb: fallback gracefully if no balancer addresses are provided
2 participants