Skip to content

Commit

Permalink
priority: sync priority with child in use (#5549)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Aug 1, 2022
1 parent c14e29e commit 23f015c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion xds/internal/balancer/priority/balancer.go
Expand Up @@ -260,7 +260,7 @@ func (b *priorityBalancer) run() {
b.handleChildStateUpdate(s.name, s.s)
case resumePickerUpdates:
b.inhibitPickerUpdates = false
b.syncPriority("")
b.syncPriority(b.childInUse)
close(s.done)
}
b.mu.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion xds/internal/balancer/priority/balancer_priority.go
Expand Up @@ -69,6 +69,7 @@ var (
// Caller must hold b.mu.
func (b *priorityBalancer) syncPriority(childUpdating string) {
if b.inhibitPickerUpdates {
b.logger.Infof("Skipping update from child with name %q", childUpdating)
return
}
for p, name := range b.priorities {
Expand All @@ -84,7 +85,7 @@ func (b *priorityBalancer) syncPriority(childUpdating string) {
(child.state.ConnectivityState == connectivity.Connecting && child.initTimer != nil) ||
p == len(b.priorities)-1 {
if b.childInUse != child.name || child.name == childUpdating {
logger.Warningf("ciu, cn, cu: %v, %v, %v", b.childInUse, child.name, childUpdating)
b.logger.Warningf("childInUse, childUpdating: %q, %q", b.childInUse, child.name)
// If we switch children or the child in use just updated its
// picker, push the child's picker to the parent.
b.cc.UpdateState(child.state)
Expand Down
6 changes: 0 additions & 6 deletions xds/internal/balancer/priority/balancer_test.go
Expand Up @@ -176,8 +176,6 @@ func (s) TestPriority_HighPriorityReady(t *testing.T) {
}

select {
case <-cc.NewPickerCh:
t.Fatalf("got unexpected new picker")
case <-cc.NewSubConnCh:
t.Fatalf("got unexpected new SubConn")
case <-cc.RemoveSubConnCh:
Expand Down Expand Up @@ -277,8 +275,6 @@ func (s) TestPriority_SwitchPriority(t *testing.T) {
}

select {
case <-cc.NewPickerCh:
t.Fatalf("got unexpected new picker")
case sc := <-cc.NewSubConnCh:
t.Fatalf("got unexpected new SubConn, %s", sc)
case <-cc.RemoveSubConnCh:
Expand Down Expand Up @@ -1194,8 +1190,6 @@ func (s) TestPriority_MoveReadyChildToHigherPriority(t *testing.T) {
// Because this was a ready child moved to a higher priority, no new subconn
// or picker should be updated.
select {
case <-cc.NewPickerCh:
t.Fatalf("got unexpected new picker")
case <-cc.NewSubConnCh:
t.Fatalf("got unexpected new SubConn")
case <-cc.RemoveSubConnCh:
Expand Down

0 comments on commit 23f015c

Please sign in to comment.