Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: use locality from the connected address for load reporting #7378

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments (3/x).
  • Loading branch information
townba committed Jul 8, 2024
commit 66478fb81b25b638506fc78948ce4ba219b972f3
16 changes: 0 additions & 16 deletions internal/testutils/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"google.golang.org/grpc/balancer"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/internal"
"google.golang.org/grpc/internal/grpcsync"
"google.golang.org/grpc/resolver"
)
Expand Down Expand Up @@ -77,21 +76,6 @@ func (tsc *TestSubConn) UpdateState(state balancer.SubConnState) {
}
}

// UpdateStateAndConnectedAddress saves the connected address to state if the
// connectivity state is Ready and pushes the state to the listener if one is
// registered.
func (tsc *TestSubConn) UpdateStateAndConnectedAddress(state balancer.SubConnState, addr resolver.Address) {
<-tsc.connectCalled.Done()
if state.ConnectivityState == connectivity.Ready {
sca := internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
sca(&state, addr)
}
if tsc.stateListener != nil {
tsc.stateListener(state)
return
}
}

// Shutdown pushes the SubConn to the ShutdownSubConn channel in the parent
// TestClientConn.
func (tsc *TestSubConn) Shutdown() {
Expand Down
6 changes: 5 additions & 1 deletion xds/internal/balancer/clusterimpl/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"google.golang.org/grpc/balancer/base"
"google.golang.org/grpc/balancer/roundrobin"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/internal"
"google.golang.org/grpc/internal/balancer/stub"
"google.golang.org/grpc/internal/grpctest"
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
Expand Down Expand Up @@ -637,7 +638,10 @@ func (s) TestLoadReporting(t *testing.T) {
t.Fatal(err.Error())
}

sc1.UpdateStateAndConnectedAddress(balancer.SubConnState{ConnectivityState: connectivity.Ready}, addrs[0])
scs := balancer.SubConnState{ConnectivityState: connectivity.Ready}
sca := internal.SetConnectedAddress.(func(*balancer.SubConnState, resolver.Address))
sca(&scs, addrs[0])
sc1.UpdateState(scs)
// Test pick with one backend.
const successCount = 5
const errorCount = 5
Expand Down
Loading