Skip to content

Commit ebc3c51

Browse files
authored
internal/balancergroup: remove usage of UpdateSubConnState (#6528)
1 parent 5da2731 commit ebc3c51

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

internal/balancergroup/balancergroup.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,6 @@ func (sbc *subBalancerWrapper) exitIdle() (complete bool) {
115115
return true
116116
}
117117

118-
func (sbc *subBalancerWrapper) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
119-
b := sbc.balancer
120-
if b == nil {
121-
// This sub-balancer was closed. This can happen when EDS removes a
122-
// locality. The balancer for this locality was already closed, and the
123-
// SubConns are being deleted. But SubConn state change can still
124-
// happen.
125-
return
126-
}
127-
b.UpdateSubConnState(sc, state)
128-
}
129-
130118
func (sbc *subBalancerWrapper) updateClientConnState(s balancer.ClientConnState) error {
131119
sbc.ccState = &s
132120
b := sbc.balancer
@@ -244,7 +232,7 @@ type BalancerGroup struct {
244232
// incomingMu guards all operations in the direction:
245233
// Sub-balancer-->ClientConn. Including NewSubConn, RemoveSubConn. It also
246234
// guards the map from SubConn to balancer ID, so updateSubConnState needs
247-
// to hold it shortly to find the sub-balancer to forward the update.
235+
// to hold it shortly to potentially delete from the map.
248236
//
249237
// UpdateState is called by the balancer state aggretator, and it will
250238
// decide when and whether to call.
@@ -449,12 +437,11 @@ func (bg *BalancerGroup) connect(sb *subBalancerWrapper) {
449437

450438
// Following are actions from the parent grpc.ClientConn, forward to sub-balancers.
451439

452-
// updateSubConnState handles the state for the subconn. It finds the
453-
// corresponding balancer and forwards the update to cb.
440+
// updateSubConnState forwards the update to cb and updates scToSubBalancer if
441+
// needed.
454442
func (bg *BalancerGroup) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState, cb func(balancer.SubConnState)) {
455443
bg.incomingMu.Lock()
456-
config, ok := bg.scToSubBalancer[sc]
457-
if !ok {
444+
if _, ok := bg.scToSubBalancer[sc]; !ok {
458445
bg.incomingMu.Unlock()
459446
return
460447
}
@@ -467,16 +454,14 @@ func (bg *BalancerGroup) updateSubConnState(sc balancer.SubConn, state balancer.
467454
bg.outgoingMu.Lock()
468455
if cb != nil {
469456
cb(state)
470-
} else {
471-
config.updateSubConnState(sc, state)
472457
}
473458
bg.outgoingMu.Unlock()
474459
}
475460

476461
// UpdateSubConnState handles the state for the subconn. It finds the
477462
// corresponding balancer and forwards the update.
478463
func (bg *BalancerGroup) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
479-
bg.updateSubConnState(sc, state, nil)
464+
bg.logger.Errorf("UpdateSubConnState(%v, %+v) called unexpectedly", sc, state)
480465
}
481466

482467
// UpdateClientConnState handles ClientState (including balancer config and

0 commit comments

Comments
 (0)