Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScheduledStartingRateLimiter: do not except, but log instead #355

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/client/process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void ProcessImpl::shutdown() {

const std::vector<ClientWorkerPtr>& ProcessImpl::createWorkers(const uint32_t concurrency) {
// TODO(oschaaf): Expose kMinimalDelay in configuration.
const std::chrono::milliseconds kMinimalWorkerDelay = 500ms;
const std::chrono::milliseconds kMinimalWorkerDelay = 500ms + (concurrency * 50ms);
ASSERT(workers_.empty());

// We try to offset the start of each thread so that workers will execute tasks evenly spaced in
Expand Down
2 changes: 1 addition & 1 deletion source/common/rate_limiter_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ScheduledStartingRateLimiter::ScheduledStartingRateLimiter(
: ForwardingRateLimiterImpl(std::move(rate_limiter)),
scheduled_starting_time_(scheduled_starting_time) {
if (timeSource().monotonicTime() >= scheduled_starting_time_) {
throw NighthawkException("Scheduled starting time needs to be in the future");
ENVOY_LOG(error, "Scheduled starting time exceeded. This may cause unintended bursty traffic.");
}
}

Expand Down
5 changes: 3 additions & 2 deletions test/rate_limiter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ TEST_F(RateLimiterTest, ScheduledStartingRateLimiterTestBadArgs) {
EXPECT_CALL(unsafe_mock_rate_limiter, timeSource)
.Times(AtLeast(1))
.WillRepeatedly(ReturnRef(time_system));
EXPECT_THROW(ScheduledStartingRateLimiter(std::move(mock_rate_limiter), timing);
, NighthawkException);
EXPECT_NO_THROW(ScheduledStartingRateLimiter(std::move(mock_rate_limiter), timing));
// TODO(XXX): once we can, verify a warning gets logged while running the line
// above.
}
}

Expand Down