core: outlier detection max ejection logic update (#9492)

Stop further ejection if the ejection percentage is lesser than or equal
to the maximum ejection percentage. Previously this was only done when
the current ejection percentage was lesser than the maximum.
This commit is contained in:
Terry Wilson 2022-08-25 10:48:28 -07:00 committed by GitHub
parent 70bc7470c6
commit d3331d953d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -733,10 +733,11 @@ public final class OutlierDetectionLoadBalancer extends LoadBalancer {
mean - stdev * (config.successRateEjection.stdevFactor / 1000f); mean - stdev * (config.successRateEjection.stdevFactor / 1000f);
for (AddressTracker tracker : trackersWithVolume) { for (AddressTracker tracker : trackersWithVolume) {
// If we are above the max ejection percentage, don't eject any more. This will allow the // If we are above or equal to the max ejection percentage, don't eject any more. This will
// total ejections to go one above the max, but at the same time it assures at least one // allow the total ejections to go one above the max, but at the same time it assures at
// ejection, which the spec calls for. This behavior matches what Envoy proxy does. // least one ejection, which the spec calls for. This behavior matches what Envoy proxy
if (trackerMap.ejectionPercentage() > config.maxEjectionPercent) { // does.
if (trackerMap.ejectionPercentage() >= config.maxEjectionPercent) {
return; return;
} }
@ -797,10 +798,11 @@ public final class OutlierDetectionLoadBalancer extends LoadBalancer {
// If this address does not have enough volume to be considered, skip to the next one. // If this address does not have enough volume to be considered, skip to the next one.
for (AddressTracker tracker : trackersWithVolume) { for (AddressTracker tracker : trackersWithVolume) {
// If we are above the max ejection percentage, don't eject any more. This will allow the // If we are above or equal to the max ejection percentage, don't eject any more. This will
// total ejections to go one above the max, but at the same time it assures at least one // allow the total ejections to go one above the max, but at the same time it assures at
// ejection, which the spec calls for. This behavior matches what Envoy proxy does. // least one ejection, which the spec calls for. This behavior matches what Envoy proxy
if (trackerMap.ejectionPercentage() > config.maxEjectionPercent) { // does.
if (trackerMap.ejectionPercentage() >= config.maxEjectionPercent) {
return; return;
} }

View File

@ -585,7 +585,7 @@ public class OutlierDetectionLoadBalancerTest {
@Test @Test
public void successRateThreeOutliers_maxEjectionPercentage() { public void successRateThreeOutliers_maxEjectionPercentage() {
OutlierDetectionLoadBalancerConfig config = new OutlierDetectionLoadBalancerConfig.Builder() OutlierDetectionLoadBalancerConfig config = new OutlierDetectionLoadBalancerConfig.Builder()
.setMaxEjectionPercent(20) .setMaxEjectionPercent(30)
.setSuccessRateEjection( .setSuccessRateEjection(
new SuccessRateEjection.Builder() new SuccessRateEjection.Builder()
.setMinimumHosts(3) .setMinimumHosts(3)