Skip to content

Commit 0c59ce8

Browse files
authored
xds: routing policy should immediately update a picker that selects base on updated config (backport v1.31.x) (#7233) (#7241)
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.
1 parent 72de6ea commit 0c59ce8

File tree

2 files changed

+216
-81
lines changed

2 files changed

+216
-81
lines changed

xds/src/main/java/io/grpc/xds/XdsRoutingLoadBalancer.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ public void handleResolvedAddresses(final ResolvedAddresses resolvedAddresses) {
8686
} else {
8787
childLbStates.get(actionName).reactivate(action.getProvider());
8888
}
89+
final LoadBalancer childLb = childLbStates.get(actionName).lb;
8990
syncContext.execute(new Runnable() {
9091
@Override
9192
public void run() {
92-
childLbStates.get(actionName).lb
93-
.handleResolvedAddresses(
94-
resolvedAddresses.toBuilder()
95-
.setLoadBalancingPolicyConfig(action.getConfig())
96-
.build());
93+
childLb.handleResolvedAddresses(
94+
resolvedAddresses.toBuilder()
95+
.setLoadBalancingPolicyConfig(action.getConfig())
96+
.build());
9797
}
9898
});
9999
}
@@ -102,6 +102,7 @@ public void run() {
102102
for (String actionName : diff) {
103103
childLbStates.get(actionName).deactivate();
104104
}
105+
updateOverallBalancingState();
105106
}
106107

107108
@Override
@@ -235,12 +236,11 @@ private final class RouteHelper extends ForwardingLoadBalancerHelper {
235236

236237
@Override
237238
public void updateBalancingState(ConnectivityState newState, SubchannelPicker newPicker) {
238-
if (deactivated) {
239-
return;
240-
}
241239
currentState = newState;
242240
currentPicker = newPicker;
243-
updateOverallBalancingState();
241+
if (!deactivated) {
242+
updateOverallBalancingState();
243+
}
244244
}
245245

246246
@Override

0 commit comments

Comments
 (0)