Skip to content

Commit

Permalink
xds: handle removing drops (#3439)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Mar 10, 2020
1 parent c124257 commit 6eb24e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xds/internal/balancer/edsbalancer/eds_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (edsImpl *edsBalancerImpl) updateDrops(dropPolicies []xdsclient.OverloadDro
dropsChanged = true
}
}
if len(edsImpl.drops) != len(newDrops) {
dropsChanged = true
}
if dropsChanged {
edsImpl.pickerMu.Lock()
edsImpl.drops = newDrops
Expand Down
14 changes: 14 additions & 0 deletions xds/internal/balancer/edsbalancer/eds_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ func (s) TestEDS_OneLocality(t *testing.T) {
t.Errorf("The second 50%% picks should be non-drops, got error %v", err)
}
}

// The same locality, remove drops.
clab6 := xdsclient.NewClusterLoadAssignmentBuilder(testClusterNames[0], nil)
clab6.AddLocality(testSubZones[0], 1, 0, testEndpointAddrs[2:3], nil)
edsb.HandleEDSResponse(xdsclient.ParseEDSRespProtoForTesting(clab6.Build()))

// Pick without drops.
p6 := <-cc.newPickerCh
for i := 0; i < 5; i++ {
gotSCSt, _ := p6.Pick(balancer.PickInfo{})
if !cmp.Equal(gotSCSt.SubConn, sc3, cmp.AllowUnexported(testSubConn{})) {
t.Fatalf("picker.Pick, got %v, want SubConn=%v", gotSCSt, sc3)
}
}
}

// 2 locality
Expand Down

0 comments on commit 6eb24e8

Please sign in to comment.