Skip to content

Commit

Permalink
Add comments to address review
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Aug 19, 2024
1 parent d82da59 commit 2ed4aff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions balancer/pickfirst_leaf/pickfirst_leaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ func (b *pickfirstBalancer) updateClientConnState(state balancer.ClientConnState

// If its the first resolver update or the balancer was already READY or
// or CONNECTING, enter CONNECTING.
// We may be in TRANSIENT_FAILURE due to a previous empty address list,
// we should still enter CONNECTING because the sticky TF behaviour mentioned
// in A62 applied only when the TRANSIENT_FAILURE is reported dur to connectivity
// failures.
if b.state == connectivity.Ready || b.state == connectivity.Connecting || oldAddrs.Len() == 0 {
// Start connection attempt at first address.
b.state = connectivity.Connecting
Expand All @@ -282,11 +286,15 @@ func (b *pickfirstBalancer) updateClientConnState(state balancer.ClientConnState
})
b.requestConnection()
} else if b.state == connectivity.Idle {
// If this is not the first resolver update and we're in IDLE, remain
// in IDLE until the picker is used.
b.cc.UpdateState(balancer.State{
ConnectivityState: connectivity.Idle,
Picker: &idlePicker{exitIdle: b.ExitIdle},
})
} else if b.state == connectivity.TransientFailure {
// If we're in TRANSIENT_FAILURE, we stay in TRANSIENT_FAILURE until
// we're READY. See A62.
b.requestConnection()
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,8 @@ func (ac *addrConn) resetTransportAndUnlock() {
ac.mu.Unlock()

if err := ac.tryAllAddrs(acCtx, addrs, connectDeadline); err != nil {
// TODO: #7534 - Move re-resolution requests into the pick_first LB policy
// to ensure one resolution request per pass instead of per subconn failure.
ac.cc.resolveNow(resolver.ResolveNowOptions{})
ac.mu.Lock()
if acCtx.Err() != nil {
Expand Down

0 comments on commit 2ed4aff

Please sign in to comment.