Skip to content

Commit

Permalink
fuzz: fix least request LB maximal active_request_bias value (envoypr…
Browse files Browse the repository at this point in the history
…oxy#33245)

* fuzz: fix least request LB maximal active_request_bias value

The default_value of the active_request_bias config field can be high, which will end up setting the weight
value in this line (1.0 / 2^active_request_bias) to essentially make all weights 0.
This PR adds a check to avoid setting this value to more than 25 in the fuzz tests.

Signed-off-by: Adi Suissa-Peleg <[email protected]>
  • Loading branch information
adisuissa authored Apr 2, 2024
1 parent d92decb commit 3a26f5a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 16 additions & 5 deletions test/common/upstream/least_request_load_balancer_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,22 @@ DEFINE_PROTO_FUZZER(const test::common::upstream::LeastRequestLoadBalancerTestCa
MaxChoiceCountForTest);
return;
}
// Validate the correctness of the Slow-Start config values.
if (input.has_least_request_lb_config() &&
input.least_request_lb_config().has_slow_start_config()) {
if (!ZoneAwareLoadBalancerFuzzBase::validateSlowStart(
input.least_request_lb_config().slow_start_config())) {
if (input.has_least_request_lb_config()) {
const auto& least_request_lb_config = input.least_request_lb_config();
// Validate the correctness of the Slow-Start config values.
if (least_request_lb_config.has_slow_start_config() &&
!ZoneAwareLoadBalancerFuzzBase::validateSlowStart(
least_request_lb_config.slow_start_config())) {
return;
}
// Validate that the active_request_bias is not too large (or else it will
// effectively zero all the weights).
if (least_request_lb_config.has_active_request_bias() &&
least_request_lb_config.active_request_bias().default_value() > 25) {
ENVOY_LOG_MISC(debug,
"active_request_bias default_value in the least-request config is too high "
"({} > 25), skipping test as the config is invalid",
least_request_lb_config.active_request_bias().default_value());
return;
}
}
Expand Down

0 comments on commit 3a26f5a

Please sign in to comment.