From f15efb63deaf8a84cee358b69434319628e8175a Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 24 Aug 2022 10:27:53 -0700 Subject: [PATCH 1/2] grpc-js: Outlier Detection: fix failure percentage min hosts check --- .../grpc-js/src/load-balancer-outlier-detection.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/grpc-js/src/load-balancer-outlier-detection.ts b/packages/grpc-js/src/load-balancer-outlier-detection.ts index ee400d45..dccca7c0 100644 --- a/packages/grpc-js/src/load-balancer-outlier-detection.ts +++ b/packages/grpc-js/src/load-balancer-outlier-detection.ts @@ -500,7 +500,15 @@ export class OutlierDetectionLoadBalancer implements LoadBalancer { } trace('Running failure percentage check. threshold=' + failurePercentageConfig.threshold + ' request volume threshold=' + failurePercentageConfig.request_volume); // Step 1 - if (this.addressMap.size < failurePercentageConfig.minimum_hosts) { + let addresesWithTargetVolume = 0; + for (const mapEntry of this.addressMap.values()) { + const successes = mapEntry.counter.getLastSuccesses(); + const failures = mapEntry.counter.getLastFailures(); + if (successes + failures >= failurePercentageConfig.request_volume) { + addresesWithTargetVolume += 1; + } + } + if (addresesWithTargetVolume < failurePercentageConfig.minimum_hosts) { return; } From 8664c837db2f03e17b5bfd70a9d352a9a318448a Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 24 Aug 2022 10:59:15 -0700 Subject: [PATCH 2/2] Fix spelling --- packages/grpc-js/src/load-balancer-outlier-detection.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/grpc-js/src/load-balancer-outlier-detection.ts b/packages/grpc-js/src/load-balancer-outlier-detection.ts index dccca7c0..a799e5b0 100644 --- a/packages/grpc-js/src/load-balancer-outlier-detection.ts +++ b/packages/grpc-js/src/load-balancer-outlier-detection.ts @@ -500,15 +500,15 @@ export class OutlierDetectionLoadBalancer implements LoadBalancer { } trace('Running failure percentage check. threshold=' + failurePercentageConfig.threshold + ' request volume threshold=' + failurePercentageConfig.request_volume); // Step 1 - let addresesWithTargetVolume = 0; + let addressesWithTargetVolume = 0; for (const mapEntry of this.addressMap.values()) { const successes = mapEntry.counter.getLastSuccesses(); const failures = mapEntry.counter.getLastFailures(); if (successes + failures >= failurePercentageConfig.request_volume) { - addresesWithTargetVolume += 1; + addressesWithTargetVolume += 1; } } - if (addresesWithTargetVolume < failurePercentageConfig.minimum_hosts) { + if (addressesWithTargetVolume < failurePercentageConfig.minimum_hosts) { return; }