Merge pull request #2331 from murgatroid99/grpc-js-xds_cluster_weight_limit

grpc-js-xds: weighted clusters: stop checking total_weight, check weight sum <= uint32 max
This commit is contained in:
Michael Lumish 2023-01-20 10:59:14 -08:00 committed by GitHub
commit 3fe218525a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -32,6 +32,8 @@ const SUPPPORTED_HEADER_MATCH_SPECIFIERS = [
'suffix_match'];
const SUPPORTED_CLUSTER_SPECIFIERS = ['cluster', 'weighted_clusters', 'cluster_header'];
const UINT32_MAX = 0xFFFFFFFF;
function durationToMs(duration: Duration__Output | null): number | null {
if (duration === null) {
return null;
@ -130,14 +132,11 @@ export class RdsState extends BaseXdsStreamState<RouteConfiguration__Output> imp
}
}
if (route.route!.cluster_specifier === 'weighted_clusters') {
if (route.route.weighted_clusters!.total_weight?.value === 0) {
return false;
}
let weightSum = 0;
for (const clusterWeight of route.route.weighted_clusters!.clusters) {
weightSum += clusterWeight.weight?.value ?? 0;
}
if (weightSum !== route.route.weighted_clusters!.total_weight?.value ?? 100) {
if (weightSum === 0 || weightSum > UINT32_MAX) {
return false;
}
if (EXPERIMENTAL_FAULT_INJECTION) {