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

client: set balancer name correctly when using grpc.WithBalancerName() (#2778) #2802

Merged
merged 1 commit into from
May 10, 2019

Conversation

wjywbs
Copy link
Contributor

@wjywbs wjywbs commented May 3, 2019

No description provided.

@wjywbs
Copy link
Contributor Author

wjywbs commented May 3, 2019

@lyuxuan I think this is a fix to #2778. Marking ready for review for ci.

@wjywbs wjywbs marked this pull request as ready for review May 3, 2019 17:49
@lyuxuan
Copy link
Contributor

lyuxuan commented May 8, 2019

I am not sure how this is solving your problem. Can you explain more? Thanks!

@wjywbs
Copy link
Contributor Author

wjywbs commented May 8, 2019

From #2778: "If I pass grpc.WithBalancerName("grpclb") explicitly in grpc.Dial(), the "grpclb: no remote balancer address is available, should never happen" error is reported.

The curBalancerName is only set when ClientConn.switchBalancer() is called. When balancerBuilder is not nil, switchBalancer is not called and curBalancerName is not set to grpclb.

https://github.com/grpc/grpc-go/blob/v1.20.0/balancer_conn_wrappers.go#L182
https://github.com/grpc/grpc-go/blob/v1.20.0/clientconn.go#L517"

Here it will set curBalancerName to the provided cc.dopts.balancerBuilder's name, so grpclb addresses in dns response will not be removed and the "grpclb: no remote balancer address is available" error will not occur.

@dfawley
Copy link
Member

dfawley commented May 9, 2019

@wjywbs you're right that the current behavior seems dubious, and this fix looks reasonable - but why do you want to manually specify the grpclb balancer? The design of grpclb is that it will be selected automatically whenever balancer addresses are returned by the resolver.

@wjywbs
Copy link
Contributor Author

wjywbs commented May 9, 2019

I'm currently using this pattern:

balancer := "round_robin"
if ...
  balancer = "grpclb"
grpc.Dial(grpc.WithBalancerName(balancer)...)

Otherwise I need to find out how to switch to round_robin via dns service config.

@lyuxuan
Copy link
Contributor

lyuxuan commented May 10, 2019

Besides dns service config, another way is to set default service config through WithDefaultServiceConfig.

Thanks for the fix. I am approving it.

@lyuxuan lyuxuan merged commit ab90977 into grpc:master May 10, 2019
@menghanl menghanl added this to the 1.21 Release milestone May 16, 2019
@menghanl menghanl changed the title Fix using grpc.WithBalancerName("grpclb") explicitly (#2778) client: set balancer name correctly when using grpc.WithBalancerName() (#2778) May 16, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 12, 2019
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.

4 participants