Skip to content

Commit 95f9dd0

Browse files
committed
Fix failover problem by having weighted_target report TF
1 parent 928d0ca commit 95f9dd0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

balancer/weightedtarget/weightedaggregator/aggregator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ func (wbsa *Aggregator) ResumeStateUpdates() {
178178
}
179179
}
180180

181+
// NeedUpdateStateOnResume sets the UpdateStateOnResume bool to true, letting a
182+
// picker update be sent once ResumeStateUpdates is called.
183+
func (wbsa *Aggregator) NeedUpdateStateOnResume() {
184+
wbsa.needUpdateStateOnResume = true
185+
}
186+
181187
// UpdateState is called to report a balancer state change from sub-balancer.
182188
// It's usually called by the balancer group.
183189
//

balancer/weightedtarget/weightedtarget.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ func (b *weightedTargetBalancer) UpdateClientConnState(s balancer.ClientConnStat
143143

144144
b.targets = newConfig.Targets
145145

146+
// To send a TF state update in the case of a configuration with no targets
147+
// passed in.
148+
if len(b.targets) == 0 {
149+
b.stateAggregator.NeedUpdateStateOnResume()
150+
}
151+
146152
return nil
147153
}
148154

0 commit comments

Comments
 (0)