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

mongo: add runtime feature flag for drain close behavior #2016

Merged
merged 1 commit into from
Nov 8, 2017
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
4 changes: 4 additions & 0 deletions docs/configuration/network_filters/mongo_proxy_filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ mongo.logging_enabled
% of messages that will be logged. Defaults to 100. If less than 100, queries may be logged
without replies, etc.

mongo.mongo.drain_close_enabled
% of connections that will be drain closed if the server is draining and would otherwise
attempt a drain close. Defaults to 100.

mongo.fault.fixed_delay.percent
Probability of an eligible MongoDB operation to be affected by
the injected fault when there is no active fault.
Expand Down
3 changes: 2 additions & 1 deletion source/common/mongo/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ void ProxyFilter::decodeReply(ReplyMessagePtr&& message) {
break;
}

if (active_query_list_.empty() && drain_decision_.drainClose()) {
if (active_query_list_.empty() && drain_decision_.drainClose() &&
runtime_.snapshot().featureEnabled(MongoRuntimeConfig::get().DrainCloseEnabled, 100)) {
ENVOY_LOG(debug, "drain closing mongo connection");
stats_.cx_drain_close_.inc();

Expand Down
1 change: 1 addition & 0 deletions source/common/mongo/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MongoRuntimeConfigKeys {
const std::string LoggingEnabled{"mongo.logging_enabled"};
const std::string ProxyEnabled{"mongo.proxy_enabled"};
const std::string ConnectionLoggingEnabled{"mongo.connection_logging_enabled"};
const std::string DrainCloseEnabled{"mongo.drain_close_enabled"};
};

typedef ConstSingleton<MongoRuntimeConfigKeys> MongoRuntimeConfig;
Expand Down
2 changes: 2 additions & 0 deletions test/common/mongo/proxy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ TEST_F(MongoProxyFilterTest, ConcurrentQueryWithDrainClose) {
message->flags(0b11);
message->cursorId(1);
message->documents().push_back(Bson::DocumentImpl::create()->addString("hello", "world"));
ON_CALL(runtime_.snapshot_, featureEnabled("mongo.drain_close_enabled", 100))
.WillByDefault(Return(true));
EXPECT_CALL(drain_decision_, drainClose()).WillOnce(Return(true));
drain_timer = new Event::MockTimer(&read_filter_callbacks_.connection_.dispatcher_);
EXPECT_CALL(*drain_timer, enableTimer(std::chrono::milliseconds(0)));
Expand Down