Skip to content

Commit

Permalink
upstream: use named constants for outlier detection config defaults (e…
Browse files Browse the repository at this point in the history
…nvoyproxy#8221)

Signed-off-by: James Forcier <[email protected]>
  • Loading branch information
csssuf committed Sep 24, 2019
1 parent 02f8f6d commit ebdd6fb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 35 deletions.
74 changes: 39 additions & 35 deletions source/common/upstream/outlier_detection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,45 +207,49 @@ void DetectorHostMonitorImpl::localOriginNoFailure() {
}

DetectorConfig::DetectorConfig(const envoy::api::v2::cluster::OutlierDetection& config)
: interval_ms_(static_cast<uint64_t>(PROTOBUF_GET_MS_OR_DEFAULT(config, interval, 10000))),
base_ejection_time_ms_(
static_cast<uint64_t>(PROTOBUF_GET_MS_OR_DEFAULT(config, base_ejection_time, 30000))),
consecutive_5xx_(
static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, consecutive_5xx, 5))),
consecutive_gateway_failure_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, consecutive_gateway_failure, 5))),
max_ejection_percent_(
static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, max_ejection_percent, 10))),
success_rate_minimum_hosts_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, success_rate_minimum_hosts, 5))),
success_rate_request_volume_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, success_rate_request_volume, 100))),
success_rate_stdev_factor_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, success_rate_stdev_factor, 1900))),
failure_percentage_threshold_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, failure_percentage_threshold, 85))),
failure_percentage_minimum_hosts_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, failure_percentage_minimum_hosts, 5))),
failure_percentage_request_volume_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, failure_percentage_request_volume, 50))),
enforcing_consecutive_5xx_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_consecutive_5xx, 100))),
: interval_ms_(
static_cast<uint64_t>(PROTOBUF_GET_MS_OR_DEFAULT(config, interval, DEFAULT_INTERVAL_MS))),
base_ejection_time_ms_(static_cast<uint64_t>(
PROTOBUF_GET_MS_OR_DEFAULT(config, base_ejection_time, DEFAULT_BASE_EJECTION_TIME_MS))),
consecutive_5xx_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, consecutive_5xx, DEFAULT_CONSECUTIVE_5XX))),
consecutive_gateway_failure_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, consecutive_gateway_failure, DEFAULT_CONSECUTIVE_GATEWAY_FAILURE))),
max_ejection_percent_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, max_ejection_percent, DEFAULT_MAX_EJECTION_PERCENT))),
success_rate_minimum_hosts_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, success_rate_minimum_hosts, DEFAULT_SUCCESS_RATE_MINIMUM_HOSTS))),
success_rate_request_volume_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, success_rate_request_volume, DEFAULT_SUCCESS_RATE_REQUEST_VOLUME))),
success_rate_stdev_factor_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, success_rate_stdev_factor, DEFAULT_SUCCESS_RATE_STDEV_FACTOR))),
failure_percentage_threshold_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, failure_percentage_threshold, DEFAULT_FAILURE_PERCENTAGE_THRESHOLD))),
failure_percentage_minimum_hosts_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, failure_percentage_minimum_hosts, DEFAULT_FAILURE_PERCENTAGE_MINIMUM_HOSTS))),
failure_percentage_request_volume_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, failure_percentage_request_volume, DEFAULT_FAILURE_PERCENTAGE_REQUEST_VOLUME))),
enforcing_consecutive_5xx_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, enforcing_consecutive_5xx, DEFAULT_ENFORCING_CONSECUTIVE_5XX))),
enforcing_consecutive_gateway_failure_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_consecutive_gateway_failure, 0))),
enforcing_success_rate_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_success_rate, 100))),
enforcing_failure_percentage_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_failure_percentage, 0))),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_consecutive_gateway_failure,
DEFAULT_ENFORCING_CONSECUTIVE_GATEWAY_FAILURE))),
enforcing_success_rate_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, enforcing_success_rate, DEFAULT_ENFORCING_SUCCESS_RATE))),
enforcing_failure_percentage_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, enforcing_failure_percentage, DEFAULT_ENFORCING_FAILURE_PERCENTAGE))),
enforcing_failure_percentage_local_origin_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_failure_percentage_local_origin, 0))),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_failure_percentage_local_origin,
DEFAULT_ENFORCING_FAILURE_PERCENTAGE_LOCAL_ORIGIN))),
split_external_local_origin_errors_(config.split_external_local_origin_errors()),
consecutive_local_origin_failure_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, consecutive_local_origin_failure, 5))),
enforcing_consecutive_local_origin_failure_(
static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, enforcing_consecutive_local_origin_failure, 100))),
consecutive_local_origin_failure_(static_cast<uint64_t>(PROTOBUF_GET_WRAPPED_OR_DEFAULT(
config, consecutive_local_origin_failure, DEFAULT_CONSECUTIVE_LOCAL_ORIGIN_FAILURE))),
enforcing_consecutive_local_origin_failure_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_consecutive_local_origin_failure,
DEFAULT_ENFORCING_CONSECUTIVE_LOCAL_ORIGIN_FAILURE))),
enforcing_local_origin_success_rate_(static_cast<uint64_t>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_local_origin_success_rate, 100))) {}
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_local_origin_success_rate,
DEFAULT_ENFORCING_LOCAL_ORIGIN_SUCCESS_RATE))) {}

DetectorImpl::DetectorImpl(const Cluster& cluster,
const envoy::api::v2::cluster::OutlierDetection& config,
Expand Down
20 changes: 20 additions & 0 deletions source/common/upstream/outlier_detection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,26 @@ class DetectorConfig {
const uint64_t consecutive_local_origin_failure_;
const uint64_t enforcing_consecutive_local_origin_failure_;
const uint64_t enforcing_local_origin_success_rate_;

static const uint64_t DEFAULT_INTERVAL_MS = 10000;
static const uint64_t DEFAULT_BASE_EJECTION_TIME_MS = 30000;
static const uint64_t DEFAULT_CONSECUTIVE_5XX = 5;
static const uint64_t DEFAULT_CONSECUTIVE_GATEWAY_FAILURE = 5;
static const uint64_t DEFAULT_MAX_EJECTION_PERCENT = 10;
static const uint64_t DEFAULT_SUCCESS_RATE_MINIMUM_HOSTS = 5;
static const uint64_t DEFAULT_SUCCESS_RATE_REQUEST_VOLUME = 100;
static const uint64_t DEFAULT_SUCCESS_RATE_STDEV_FACTOR = 1900;
static const uint64_t DEFAULT_FAILURE_PERCENTAGE_THRESHOLD = 85;
static const uint64_t DEFAULT_FAILURE_PERCENTAGE_MINIMUM_HOSTS = 5;
static const uint64_t DEFAULT_FAILURE_PERCENTAGE_REQUEST_VOLUME = 50;
static const uint64_t DEFAULT_ENFORCING_CONSECUTIVE_5XX = 100;
static const uint64_t DEFAULT_ENFORCING_CONSECUTIVE_GATEWAY_FAILURE = 0;
static const uint64_t DEFAULT_ENFORCING_SUCCESS_RATE = 100;
static const uint64_t DEFAULT_ENFORCING_FAILURE_PERCENTAGE = 0;
static const uint64_t DEFAULT_ENFORCING_FAILURE_PERCENTAGE_LOCAL_ORIGIN = 0;
static const uint64_t DEFAULT_CONSECUTIVE_LOCAL_ORIGIN_FAILURE = 5;
static const uint64_t DEFAULT_ENFORCING_CONSECUTIVE_LOCAL_ORIGIN_FAILURE = 100;
static const uint64_t DEFAULT_ENFORCING_LOCAL_ORIGIN_SUCCESS_RATE = 100;
};

/**
Expand Down

0 comments on commit ebdd6fb

Please sign in to comment.