diff --git a/contrib/golang/filters/http/test/test_data/buffer/go.mod b/contrib/golang/filters/http/test/test_data/buffer/go.mod index b192be3f71b1..318833da2bfe 100644 --- a/contrib/golang/filters/http/test/test_data/buffer/go.mod +++ b/contrib/golang/filters/http/test/test_data/buffer/go.mod @@ -3,8 +3,8 @@ module example.com/buffer go 1.20 require ( - github.com/envoyproxy/envoy v1.24.0 - google.golang.org/protobuf v1.31.0 + github.com/envoyproxy/envoy v1.24.0 + google.golang.org/protobuf v1.32.0 ) replace github.com/envoyproxy/envoy => ../../../../../../../ diff --git a/source/common/upstream/cluster_factory_impl.cc b/source/common/upstream/cluster_factory_impl.cc index 48c8779608a2..0cb89487aca2 100644 --- a/source/common/upstream/cluster_factory_impl.cc +++ b/source/common/upstream/cluster_factory_impl.cc @@ -115,10 +115,12 @@ ClusterFactoryImplBase::create(const envoy::config::cluster::v3::Cluster& cluste } } - new_cluster_pair.first->setOutlierDetector(Outlier::DetectorImplFactory::createForCluster( + auto detector_or_error = Outlier::DetectorImplFactory::createForCluster( *new_cluster_pair.first, cluster, server_context.mainThreadDispatcher(), server_context.runtime(), context.outlierEventLogger(), - server_context.api().randomGenerator())); + server_context.api().randomGenerator()); + RETURN_IF_STATUS_NOT_OK(detector_or_error); + new_cluster_pair.first->setOutlierDetector(detector_or_error.value()); return status_or_cluster; } diff --git a/source/common/upstream/outlier_detection_impl.cc b/source/common/upstream/outlier_detection_impl.cc index d74d42b83a99..79a9e304e699 100644 --- a/source/common/upstream/outlier_detection_impl.cc +++ b/source/common/upstream/outlier_detection_impl.cc @@ -23,7 +23,7 @@ namespace Envoy { namespace Upstream { namespace Outlier { -DetectorSharedPtr DetectorImplFactory::createForCluster( +absl::StatusOr DetectorImplFactory::createForCluster( Cluster& cluster, const envoy::config::cluster::v3::Cluster& cluster_config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, EventLoggerSharedPtr event_logger, Random::RandomGenerator& random) { @@ -284,7 +284,7 @@ DetectorImpl::~DetectorImpl() { } } -std::shared_ptr +absl::StatusOr> DetectorImpl::create(Cluster& cluster, const envoy::config::cluster::v3::OutlierDetection& config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, TimeSource& time_source, EventLoggerSharedPtr event_logger, @@ -293,7 +293,7 @@ DetectorImpl::create(Cluster& cluster, const envoy::config::cluster::v3::Outlier new DetectorImpl(cluster, config, dispatcher, runtime, time_source, event_logger, random)); if (detector->config().maxEjectionTimeMs() < detector->config().baseEjectionTimeMs()) { - throwEnvoyExceptionOrPanic( + return absl::InvalidArgumentError( "outlier detector's max_ejection_time cannot be smaller than base_ejection_time"); } detector->initialize(cluster); diff --git a/source/common/upstream/outlier_detection_impl.h b/source/common/upstream/outlier_detection_impl.h index 4044cd0d1ecf..1a70d3c75129 100644 --- a/source/common/upstream/outlier_detection_impl.h +++ b/source/common/upstream/outlier_detection_impl.h @@ -34,7 +34,7 @@ namespace Outlier { */ class DetectorImplFactory { public: - static DetectorSharedPtr + static absl::StatusOr createForCluster(Cluster& cluster, const envoy::config::cluster::v3::Cluster& cluster_config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, EventLoggerSharedPtr event_logger, Random::RandomGenerator& random); @@ -372,7 +372,7 @@ class DetectorConfig { */ class DetectorImpl : public Detector, public std::enable_shared_from_this { public: - static std::shared_ptr + static absl::StatusOr> create(Cluster& cluster, const envoy::config::cluster::v3::OutlierDetection& config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, TimeSource& time_source, EventLoggerSharedPtr event_logger, Random::RandomGenerator& random); diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index a44c14fe557c..2feaf7303dda 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -47,7 +47,8 @@ TEST(OutlierDetectorImplFactoryTest, NoDetector) { NiceMock random; EXPECT_EQ(nullptr, DetectorImplFactory::createForCluster(cluster, defaultStaticCluster("fake_cluster"), - dispatcher, runtime, nullptr, random)); + dispatcher, runtime, nullptr, random) + .value()); } TEST(OutlierDetectorImplFactoryTest, Detector) { @@ -59,7 +60,8 @@ TEST(OutlierDetectorImplFactoryTest, Detector) { NiceMock runtime; NiceMock random; EXPECT_NE(nullptr, DetectorImplFactory::createForCluster(cluster, fake_cluster, dispatcher, - runtime, nullptr, random)); + runtime, nullptr, random) + .value()); } class CallbackChecker { @@ -146,8 +148,10 @@ max_ejection_time: 400s envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); EXPECT_EQ(100UL, detector->config().intervalMs()); EXPECT_EQ(10000UL, detector->config().baseEjectionTimeMs()); @@ -179,8 +183,10 @@ base_ejection_time: 10s envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); EXPECT_EQ(100UL, detector->config().intervalMs()); EXPECT_EQ(10000UL, detector->config().baseEjectionTimeMs()); @@ -209,9 +215,10 @@ max_ejection_time: 3s envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); // Detector should reject the config. - ASSERT_THROW(DetectorImpl::create(cluster_, outlier_detection, dispatcher_, runtime_, - time_system_, event_logger_, random_), - EnvoyException); + ASSERT_FALSE(DetectorImpl::create(cluster_, outlier_detection, dispatcher_, runtime_, + time_system_, event_logger_, random_) + .status() + .ok()); } // Test verifies that legacy config without max_ejection_time value @@ -226,8 +233,10 @@ base_ejection_time: 400s envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); EXPECT_EQ(100UL, detector->config().intervalMs()); EXPECT_EQ(400000UL, detector->config().baseEjectionTimeMs()); @@ -242,7 +251,8 @@ TEST_F(OutlierDetectorImplTest, DestroyWithActive) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); loadRq(hosts_[0], 4, 500); @@ -274,7 +284,8 @@ TEST_F(OutlierDetectorImplTest, DestroyHostInUse) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); detector.reset(); @@ -293,7 +304,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodes) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); addHosts({"tcp://127.0.0.1:81"}); @@ -370,7 +382,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodesWithActiveHCUnejectHost) std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); addHosts({"tcp://127.0.0.1:81"}); @@ -476,8 +489,10 @@ successful_active_health_check_uneject_host: false EXPECT_CALL(*health_checker, addHostCheckCompleteCb(_)).Times(0); ON_CALL(cluster_, healthChecker()).WillByDefault(Return(health_checker.get())); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); addHosts({"tcp://127.0.0.1:81"}); @@ -534,7 +549,8 @@ TEST_F(OutlierDetectorImplTest, ConnectSuccessWithOptionalHTTP_OK) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Make sure that in non-split mode LOCAL_ORIGIN_CONNECT_SUCCESS with optional HTTP code 200 @@ -561,7 +577,8 @@ TEST_F(OutlierDetectorImplTest, ExternalOriginEventsNonSplit) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Make sure that EXT_ORIGIN_REQUEST_SUCCESS cancels EXT_ORIGIN_REQUEST_FAILED @@ -589,7 +606,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaNonHttpCodes) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); addHosts({"tcp://127.0.0.1:81"}); @@ -668,7 +686,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailure) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); ON_CALL(runtime_.snapshot_, featureEnabled(EnforcingConsecutiveGatewayFailureRuntime, 0)) .WillByDefault(Return(true)); @@ -766,7 +785,8 @@ TEST_F(OutlierDetectorImplTest, TimeoutWithHttpCode) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Report several LOCAL_ORIGIN_TIMEOUT with optional Http code 500. Host should be ejected. @@ -839,7 +859,8 @@ TEST_F(OutlierDetectorImplTest, LargeNumberOfTimeouts) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); ON_CALL(runtime_.snapshot_, featureEnabled(EnforcingConsecutiveLocalOriginFailureRuntime, 100)) .WillByDefault(Return(true)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -894,7 +915,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowLocalOriginFailure) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); ON_CALL(runtime_.snapshot_, featureEnabled(EnforcingConsecutiveLocalOriginFailureRuntime, 100)) .WillByDefault(Return(true)); @@ -1009,7 +1031,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailureAnd5xx) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); ON_CALL(runtime_.snapshot_, featureEnabled(EnforcingConsecutiveGatewayFailureRuntime, 0)) .WillByDefault(Return(true)); @@ -1099,7 +1122,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowNonHttpCodesExternalOrigin) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); addHosts({"tcp://127.0.0.1:81"}); @@ -1152,7 +1176,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Turn off 5xx detection to test SR detection in isolation. @@ -1252,7 +1277,8 @@ TEST_F(OutlierDetectorImplTest, ExternalOriginEventsWithSplit) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); for (auto i = 0; i < 100; i++) { hosts_[0]->outlierDetector().putResult(Result::ExtOriginRequestFailed); @@ -1286,7 +1312,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Turn off detecting consecutive local origin failures. @@ -1375,7 +1402,8 @@ TEST_F(OutlierDetectorImplTest, EmptySuccessRate) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); loadRq(hosts_, 200, 503); time_system_.setMonotonicTime(std::chrono::milliseconds(10000)); @@ -1399,7 +1427,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowFailurePercentageExternalOrigin) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Turn off 5xx detection and SR detection to test failure percentage detection in isolation. @@ -1520,7 +1549,8 @@ TEST_F(OutlierDetectorImplTest, BasicFlowFailurePercentageLocalOrigin) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Turn off 5xx detection and SR detection to test failure percentage detection in isolation. @@ -1619,7 +1649,8 @@ TEST_F(OutlierDetectorImplTest, RemoveWhileEjected) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); loadRq(hosts_[0], 4, 500); @@ -1649,7 +1680,8 @@ TEST_F(OutlierDetectorImplTest, Overflow) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); ON_CALL(runtime_.snapshot_, getInteger(MaxEjectionPercentRuntime, _)).WillByDefault(Return(60)); @@ -1678,7 +1710,8 @@ TEST_F(OutlierDetectorImplTest, NotEnforcing) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); loadRq(hosts_[0], 4, 503); @@ -1721,7 +1754,8 @@ TEST_F(OutlierDetectorImplTest, EjectionActiveValueIsAccountedWithoutMetricStora EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); ON_CALL(runtime_.snapshot_, getInteger(MaxEjectionPercentRuntime, _)).WillByDefault(Return(50)); @@ -1759,7 +1793,8 @@ TEST_F(OutlierDetectorImplTest, CrossThreadRemoveRace) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); loadRq(hosts_[0], 4, 500); @@ -1784,7 +1819,8 @@ TEST_F(OutlierDetectorImplTest, CrossThreadDestroyRace) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); loadRq(hosts_[0], 4, 500); @@ -1811,7 +1847,8 @@ TEST_F(OutlierDetectorImplTest, CrossThreadFailRace) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); loadRq(hosts_[0], 4, 500); @@ -1851,8 +1888,10 @@ max_ejection_time_jitter: 13s addHosts({"tcp://127.0.0.4:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1882,8 +1921,10 @@ max_ejection_time_jitter: 13s addHosts({"tcp://127.0.0.2:80"}); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection_, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); loadRq(hosts_[0], 5, 500); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); @@ -1896,7 +1937,8 @@ TEST_F(OutlierDetectorImplTest, Consecutive_5xxAlreadyEjected) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Cause a consecutive 5xx error. loadRq(hosts_[0], 4, 500); @@ -1934,7 +1976,8 @@ TEST_F(OutlierDetectorImplTest, EjectTimeBackoff) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Eject the node by consecutive 5xx errors. @@ -2099,7 +2142,8 @@ TEST_F(OutlierDetectorImplTest, EjectTimeBackoffTimeBasedDetection) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(base_ejection_time), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Turn off 5xx detection to test failure percentage in isolation. @@ -2259,7 +2303,8 @@ TEST_F(OutlierDetectorImplTest, MaxEjectTime) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Verify that maximum_ejection_time caps ejection time. @@ -2353,7 +2398,8 @@ TEST_F(OutlierDetectorImplTest, MaxEjectTimeNotAlligned) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Verify that maximum_ejection_time caps ejection time. @@ -2437,8 +2483,10 @@ max_ejection_time_jitter: 13s envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); EXPECT_EQ(100UL, detector->config().intervalMs()); EXPECT_EQ(10000UL, detector->config().baseEjectionTimeMs()); @@ -2456,8 +2504,10 @@ base_ejection_time: 10s envoy::config::cluster::v3::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); - std::shared_ptr detector(DetectorImpl::create( - cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_, random_)); + std::shared_ptr detector(DetectorImpl::create(cluster_, outlier_detection, + dispatcher_, runtime_, time_system_, + event_logger_, random_) + .value()); EXPECT_EQ(100UL, detector->config().intervalMs()); EXPECT_EQ(10000UL, detector->config().baseEjectionTimeMs()); @@ -2477,7 +2527,8 @@ TEST_F(OutlierDetectorImplTest, EjectionTimeJitterIsInRange) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Set the return value of random(). EXPECT_CALL(random_, random()).WillOnce(Return(123456789UL)); @@ -2507,7 +2558,8 @@ TEST_F(OutlierDetectorImplTest, EjectionTimeJitterIsZeroWhenNotConfigured) { EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create(cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, - event_logger_, random_)); + event_logger_, random_) + .value()); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); // Set the return value of random(). EXPECT_CALL(random_, random()).WillOnce(Return(1234567890UL)); diff --git a/tools/code_format/config.yaml b/tools/code_format/config.yaml index c2afdd7b4117..726716339de8 100644 --- a/tools/code_format/config.yaml +++ b/tools/code_format/config.yaml @@ -103,7 +103,6 @@ paths: - source/common/upstream/subset_lb_config.cc - source/common/upstream/load_balancer_impl.cc - source/common/upstream/cluster_manager_impl.cc - - source/common/upstream/outlier_detection_impl.cc - source/common/upstream/upstream_impl.cc - source/common/upstream/default_local_address_selector_factory.cc - source/common/network/listen_socket_impl.cc