Skip to content

Commit

Permalink
[ring_hash_policy] IDLE -> Idle
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Sep 7, 2021
1 parent 0530767 commit c5c7578
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions xds/internal/balancer/ringhash/ringhash.go
Expand Up @@ -185,7 +185,7 @@ type ringhashBalancer struct {
// - an address's weight was updated
//
// Note that this function doesn't trigger SubConn connecting, so all the new
// SubConn states are IDLE.
// SubConn states are Idle.
func (b *ringhashBalancer) updateAddresses(addrs []resolver.Address) bool {
var addrsUpdated bool
// addrsSet is the set converted from addrs, it's used for quick lookup of
Expand Down Expand Up @@ -397,7 +397,7 @@ type connectivityStateEvaluator struct {
// - If there is at least one subchannel in READY state, report READY.
// - If there are 2 or more subchannels in TRANSIENT_FAILURE state, report TRANSIENT_FAILURE.
// - If there is at least one subchannel in CONNECTING state, report CONNECTING.
// - If there is at least one subchannel in IDLE state, report IDLE.
// - If there is at least one subchannel in Idle state, report Idle.
// - Otherwise, report TRANSIENT_FAILURE.
//
// Note that if there are 1 connecting, 2 transient failure, the overall state
Expand Down
16 changes: 8 additions & 8 deletions xds/internal/balancer/ringhash/ringhash_test.go
Expand Up @@ -85,15 +85,15 @@ func setupTest(t *testing.T, addrs []resolver.Address) (*testutils.TestClientCon
t.Fatalf("got unexpected new subconn addrs: %v", cmp.Diff(addr1, want, cmp.AllowUnexported(attributes.Attributes{})))
}
sc1 := <-cc.NewSubConnCh
// All the SubConns start in IDLE, and should not Connect().
// All the SubConns start in Idle, and should not Connect().
select {
case <-sc1.(*testutils.TestSubConn).ConnectCh:
t.Errorf("unexpected Connect() from SubConn %v", sc1)
case <-time.After(defaultTestShortTimeout):
}
}

// Should also have a picker, with all SubConns in IDLE.
// Should also have a picker, with all SubConns in Idle.
p1 := <-cc.NewPickerCh
return cc, b, p1
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestThreeSubConnsAffinity(t *testing.T) {
b.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.TransientFailure})
p2 := <-cc.NewPickerCh
// Pick with the same hash should be queued, because the SubConn after the
// first picked is IDLE.
// first picked is Idle.
if _, err := p2.Pick(balancer.PickInfo{Ctx: ctxWithHash(testHash)}); err != balancer.ErrNoSubConnAvailable {
t.Fatalf("first pick returned err %v, want %v", err, balancer.ErrNoSubConnAvailable)
}
Expand All @@ -202,10 +202,10 @@ func TestThreeSubConnsAffinity(t *testing.T) {
}
}

// Now, after backoff, the first picked SubConn will turn IDLE.
// Now, after backoff, the first picked SubConn will turn Idle.
b.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.Idle})
// The picks above should have queued Connect() for the first picked
// SubConn, so this IDLE state change will trigger a Connect().
// SubConn, so this Idle state change will trigger a Connect().
select {
case <-sc0.(*testutils.TestSubConn).ConnectCh:
case <-time.After(defaultTestTimeout):
Expand Down Expand Up @@ -365,7 +365,7 @@ func TestAddrWeightChange(t *testing.T) {
}

// TestSubConnToConnectWhenOverallTransientFailure covers the situation when the
// overall state is TransientFailure, the SubConns turning IDLE will be
// overall state is TransientFailure, the SubConns turning Idle will be
// triggered to Connect(). But not when the overall state is not
// TransientFailure.
func TestSubConnToConnectWhenOverallTransientFailure(t *testing.T) {
Expand All @@ -382,7 +382,7 @@ func TestSubConnToConnectWhenOverallTransientFailure(t *testing.T) {
b.UpdateSubConnState(it.sc.sc, balancer.SubConnState{ConnectivityState: connectivity.TransientFailure})
}

// The next one turning IDLE should Connect().
// The next one turning Idle should Connect().
sc0 := ring0.items[0].sc.sc
b.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.Idle})
select {
Expand All @@ -391,7 +391,7 @@ func TestSubConnToConnectWhenOverallTransientFailure(t *testing.T) {
t.Errorf("timeout waiting for Connect() from SubConn %v", sc0)
}

// If this SubConn is ready. Other SubConns turning IDLE will not Connect().
// If this SubConn is ready. Other SubConns turning Idle will not Connect().
b.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.Connecting})
b.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.Ready})

Expand Down

0 comments on commit c5c7578

Please sign in to comment.