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 (#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 committed Jul 22, 2020
1 parent 9f49e48 commit e4215b4
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 e4215b4

Please sign in to comment.