Skip to content

Commit

Permalink
xds: routing policy should immediately update a picker that selects b…
Browse files Browse the repository at this point in the history
…ase on updated config (grpc#7233)

The routing LB policy should immediately the Channel's picker that delegates picking to the updated routes. Otherwise, new RPCs will keep being sent through old routes even if they are removed. This change also includes the fix for syncing state change for child balancers in deactivated state.
  • Loading branch information
voidzcy authored and dfawley committed Jan 15, 2021
1 parent 6a04aac commit 140a9ae
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 81 deletions.
18 changes: 9 additions & 9 deletions xds/src/main/java/io/grpc/xds/XdsRoutingLoadBalancer.java
Expand Up @@ -86,14 +86,14 @@ public void handleResolvedAddresses(final ResolvedAddresses resolvedAddresses) {
} else {
childLbStates.get(actionName).reactivate(action.getProvider());
}
final LoadBalancer childLb = childLbStates.get(actionName).lb;
syncContext.execute(new Runnable() {
@Override
public void run() {
childLbStates.get(actionName).lb
.handleResolvedAddresses(
resolvedAddresses.toBuilder()
.setLoadBalancingPolicyConfig(action.getConfig())
.build());
childLb.handleResolvedAddresses(
resolvedAddresses.toBuilder()
.setLoadBalancingPolicyConfig(action.getConfig())
.build());
}
});
}
Expand All @@ -102,6 +102,7 @@ public void run() {
for (String actionName : diff) {
childLbStates.get(actionName).deactivate();
}
updateOverallBalancingState();
}

@Override
Expand Down Expand Up @@ -235,12 +236,11 @@ private final class RouteHelper extends ForwardingLoadBalancerHelper {

@Override
public void updateBalancingState(ConnectivityState newState, SubchannelPicker newPicker) {
if (deactivated) {
return;
}
currentState = newState;
currentPicker = newPicker;
updateOverallBalancingState();
if (!deactivated) {
updateOverallBalancingState();
}
}

@Override
Expand Down

0 comments on commit 140a9ae

Please sign in to comment.