Skip to content

Commit

Permalink
xds/priority: stop forwarding UpdateSubConnState calls (grpc#6521)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Aug 9, 2023
1 parent dceb6ee commit ce68413
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion xds/internal/balancer/priority/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (b *priorityBalancer) ResolverError(err error) {
}

func (b *priorityBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
b.bg.UpdateSubConnState(sc, state)
b.logger.Errorf("UpdateSubConnState(%v, %+v) called unexpectedly", sc, state)
}

func (b *priorityBalancer) Close() {
Expand Down
23 changes: 12 additions & 11 deletions xds/internal/balancer/priority/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,18 @@ func init() {
ii := i
stub.Register(fmt.Sprintf("%s-%d", initIdleBalancerName, ii), stub.BalancerFuncs{
UpdateClientConnState: func(bd *stub.BalancerData, opts balancer.ClientConnState) error {
sc, err := bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{})
lis := func(state balancer.SubConnState) {
err := fmt.Errorf("wrong picker error")
if state.ConnectivityState == connectivity.Idle {
err = errsTestInitIdle[ii]
}
bd.ClientConn.UpdateState(balancer.State{
ConnectivityState: state.ConnectivityState,
Picker: &testutils.TestConstPicker{Err: err},
})
}

sc, err := bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{StateListener: lis})
if err != nil {
return err
}
Expand All @@ -1747,16 +1758,6 @@ func init() {
})
return nil
},
UpdateSubConnState: func(bd *stub.BalancerData, sc balancer.SubConn, state balancer.SubConnState) {
err := fmt.Errorf("wrong picker error")
if state.ConnectivityState == connectivity.Idle {
err = errsTestInitIdle[ii]
}
bd.ClientConn.UpdateState(balancer.State{
ConnectivityState: state.ConnectivityState,
Picker: &testutils.TestConstPicker{Err: err},
})
},
})
}
}
Expand Down

0 comments on commit ce68413

Please sign in to comment.