Merge pull request #2247 from murgatroid99/grpc-js-xds_fix_weight_check

grpc-js-xds: Fix limit representation for priority weight validation
This commit is contained in:
Michael Lumish 2022-10-14 13:57:46 -07:00 committed by GitHub
commit 1ff7dca7e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,8 @@ import { BaseXdsStreamState, HandleResponseResult, RejectedResourceEntry, Resour
const TRACER_NAME = 'xds_client';
const UINT32_MAX = 0xFFFFFFFF;
function trace(text: string): void {
experimental.trace(logVerbosity.DEBUG, TRACER_NAME, text);
}
@ -88,7 +90,7 @@ export class EdsState extends BaseXdsStreamState<ClusterLoadAssignment__Output>
priorityTotalWeights.set(endpoint.priority, (priorityTotalWeights.get(endpoint.priority) ?? 0) + (endpoint.load_balancing_weight?.value ?? 0));
}
for (const totalWeight of priorityTotalWeights.values()) {
if (totalWeight >= 1<<32) {
if (totalWeight > UINT32_MAX) {
return false;
}
}