From f6f52994428f57895c615e0b898f90604baa22f9 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Mon, 11 Dec 2023 16:51:04 -0500 Subject: [PATCH 1/2] outlier: changing to use statusor Signed-off-by: Alyssa Wilk --- .../common/upstream/cluster_factory_impl.cc | 6 +- .../common/upstream/outlier_detection_impl.cc | 6 +- .../common/upstream/outlier_detection_impl.h | 4 +- .../upstream/outlier_detection_impl_test.cc | 160 ++++++++++++------ tools/code_format/config.yaml | 1 - 5 files changed, 115 insertions(+), 62 deletions(-) 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 From 3835ac394302d9f784a86be64aaf8af3cab8b891 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:54:56 +0000 Subject: [PATCH 2/2] build(deps): bump clang-format from 14.0.6 to 17.0.6 in /tools/base Bumps [clang-format](https://github.com/ssciwr/clang-format-wheel) from 14.0.6 to 17.0.6. - [Release notes](https://github.com/ssciwr/clang-format-wheel/releases) - [Commits](https://github.com/ssciwr/clang-format-wheel/compare/14.0.6...v17.0.6) --- updated-dependencies: - dependency-name: clang-format dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- tools/base/requirements.in | 2 +- tools/base/requirements.txt | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/base/requirements.in b/tools/base/requirements.in index 3adb4648a427..44af75af77ae 100644 --- a/tools/base/requirements.in +++ b/tools/base/requirements.in @@ -4,7 +4,7 @@ aio.api.github>=0.2.5 aiohttp>=3.8.1 aioquic>=0.9.21 cffi>=1.15.0 -clang-format==14.0.6 +clang-format==17.0.6 clang-tidy==14.0.6 colorama coloredlogs diff --git a/tools/base/requirements.txt b/tools/base/requirements.txt index f9945610cf14..f9fbbb979903 100644 --- a/tools/base/requirements.txt +++ b/tools/base/requirements.txt @@ -383,16 +383,22 @@ charset-normalizer==3.3.0 \ --hash=sha256:f8888e31e3a85943743f8fc15e71536bda1c81d5aa36d014a3c0c44481d7db6e \ --hash=sha256:fc52b79d83a3fe3a360902d3f5d79073a993597d48114c29485e9431092905d8 # via requests -clang-format==14.0.6 \ - --hash=sha256:13f2d6d4a2af004a783c65f0921afa8f0384bffcdaf500b6c2cb542edeb0b4a5 \ - --hash=sha256:810c649ab97d208cd418c897d50ab6e958eb8d96854527edd80d0dd21a75e914 \ - --hash=sha256:aaf4edecc46a24f0b572b82cf5827e292ad1c137903427627c4d5f671668cc2b \ - --hash=sha256:bd400c47665dd19afc03f98e747f78ed828abab99c6a1b07e137b35c1cd3cc26 \ - --hash=sha256:c93580945f75de7e01996f1fb3cf67e4dc424f1c864e237c85614fb99a48c7a4 \ - --hash=sha256:d5c96b500d7f8b5d2db5b75ac035be387512850ad589cdc3019666b861382136 \ - --hash=sha256:d780c04334bca80f2b60d25bf53c37bd0618520ee295a7888a11f25bde114ac4 \ - --hash=sha256:d7c1c5e404c58e55f0170f01b3c5611dce6c119e62b5d1020347e0ad97d5a047 \ - --hash=sha256:dbfd60528eb3bb7d7cfe8576faa70845fbf93601f815ef75163d36606e87f388 +clang-format==17.0.6 \ + --hash=sha256:195014a589fde9e2bec447ee1f2efd31f8c9f773b10aa66b510beae6997e6bc5 \ + --hash=sha256:2a1323ca5322e0dead521223155fe2ae1ba81d50abab8e20aaac28f6a94f23b9 \ + --hash=sha256:2c7364a50c4fdb8ce9acc4e0c21627e52f4eebee98ff2d8a19b6d4302d0be23b \ + --hash=sha256:2ddc8b6237520d26d78489e3bb876243d87c3629eb3cd40e1df0c8c6e355d949 \ + --hash=sha256:33c4f1975a6a0a76e5b85165c510c46ae1155f82477a5730e29799e43d78c83a \ + --hash=sha256:393f896db6155d6b8401ebae40df1f9a8cdf15d494d13fb775657c9ec609b586 \ + --hash=sha256:50f082840d2e013160355ed63add4502884344371dda5af12ec0abe68cbc5a36 \ + --hash=sha256:5476f8fba40e4330a4704681386d78751ced0ecbd050bd0687817cca01d4e167 \ + --hash=sha256:5cda40badfb01818ece739509d9cde678fc02660180cc1a55156782ef203704d \ + --hash=sha256:879e831c58a25a9b7527155032a6dc4758716ded69590911468a37629acb13d1 \ + --hash=sha256:9407f0f4cb5a26b96af38bb2261f1c4015127f4d87ce46a61bb3a3c2a3d4f3cc \ + --hash=sha256:a0f744b056cb1595efdb7d2b83a7d73370e506e17fcaa68cd884c2ed029ae0fd \ + --hash=sha256:afc29c4413b5f2f885347f4bdbb7fe81f595faeceafa640c9e67a2d9aa2c7134 \ + --hash=sha256:ccb6f5ce90f24ed0bb314d041a8edcc94d1279c1469669d5855be004d9d6caff \ + --hash=sha256:edd55b840fa6edcdafb1651c3c24c6ea8d911e73be30373e7e8e5741cb585464 # via -r requirements.in clang-tidy==14.0.6 \ --hash=sha256:02bce40a56cc344e20d2f63bef6b85acf9837954559e0091804d6e748dfc0359 \