Merge pull request #2916 from murgatroid99/grpc-js-xds_ring_hash_fix

grpc-js-xds: ring_hash: Fix proactive connect logic when already connecting
This commit is contained in:
Michael Lumish 2025-03-04 15:21:44 -08:00 committed by GitHub
commit a8142c2bcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -249,16 +249,20 @@ class RingHashLoadBalancer implements LoadBalancer {
if (!(this.currentState === connectivityState.TRANSIENT_FAILURE || this.currentState === connectivityState.CONNECTING)) { if (!(this.currentState === connectivityState.TRANSIENT_FAILURE || this.currentState === connectivityState.CONNECTING)) {
return; return;
} }
let firstIdleChild: LeafLoadBalancer | null = null;
for (const leaf of this.leafMap.values()) { for (const leaf of this.leafMap.values()) {
const leafState = leaf.getConnectivityState(); const leafState = leaf.getConnectivityState();
if (leafState === connectivityState.CONNECTING) { if (leafState === connectivityState.CONNECTING) {
firstIdleChild = null;
break; break;
} }
if (leafState === connectivityState.IDLE) { if (leafState === connectivityState.IDLE && !firstIdleChild) {
leaf.startConnecting(); firstIdleChild = leaf;
break;
} }
} }
if (firstIdleChild) {
firstIdleChild.startConnecting();
}
} }
private calculateAndUpdateState() { private calculateAndUpdateState() {