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

Fix panics on balancer and resolver updates #1684

Merged
merged 2 commits into from
Nov 22, 2017

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Nov 22, 2017

  • NewAddress with empty list (addrConn with an empty address list)
  • NewServiceConfig to switch balancer before the first balancer is built

updates #1683

This makes NewSubConn() with empty list return an error, and makes UpdateAddress() with empty list tear the addrConn down. The SubConn won't be usable after this.
Eventually we want to make the SubConn with empty address list stay in TransientFailure but still usable, and balancer still can update this SubConn's address. This will be done in a follow-up PR.

 - NewAddress with empty list
 - NewServiceConfig to switch balancer before the first balancer is built
@@ -183,6 +184,9 @@ func (ccb *ccBalancerWrapper) handleResolvedAddrs(addrs []resolver.Address, err
}

func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) {
if len(addrs) <= 0 {
return nil, fmt.Errorf("grpc: cannot create SubConn with empty address list")
Copy link
Member

Choose a reason for hiding this comment

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

Should we try to make NewSubConn([]) do the same thing that sc := NewSubConn([foo]); sc.UpdateAddresses([]) would do, for consistency?

// makes sure we don't call close on nil balancerWrapper.
r.NewServiceConfig(`{"loadBalancingPolicy": "round_robin"}`) // This should not panic.

time.Sleep(time.Second) //Sleep to make sure the service config is handled by ClientConn.
Copy link
Member

Choose a reason for hiding this comment

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

Space after //

@dfawley dfawley changed the title Fix panics on resolver updates Fix panics on balancer and resolver updates Nov 22, 2017
@menghanl menghanl merged commit 10873b3 into grpc:master Nov 22, 2017
@menghanl menghanl deleted the panic_resolver_updates branch November 22, 2017 21:59
@dfawley dfawley added this to the 1.9 Release milestone Jan 2, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 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.

2 participants