Skip to content

Commit fb48b13

Browse files
committed
make feature togglable
1 parent d6f67f8 commit fb48b13

4 files changed

Lines changed: 44 additions & 11 deletions

File tree

cloud/blockstore/config/rdma.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ message TRdmaTarget
1414
TRdmaEndpoint Endpoint = 1;
1515
NCloud.NProto.TRdmaServer Server = 2; // deprecated
1616
uint32 WorkerThreads = 3;
17+
18+
// Keep track of the client connections and of the volumes mounted over
19+
// them, and show them on a monitoring page.
20+
bool ConnectionMonitoringEnabled = 4;
1721
}
1822

1923
message TRdmaConfig

cloud/blockstore/libs/service_rdma/rdma_target.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,20 +959,23 @@ IStartablePtr CreateBlockstoreServerRdmaTarget(
959959
auto threadPool = CreateThreadPool("RDMA", rdmaTargetConfig->WorkerThreads);
960960
threadPool->Start();
961961

962-
// without a monitoring page there is nobody to read the connections, so
963-
// the handler is left with an observer that drops them
964-
auto mountRegistry = monitoring ? CreateMountRegistry(logging) : nullptr;
962+
// without a page there is nobody to read the connections, so they are not
963+
// tracked at all and the handler is left with an empty registry pointer
964+
auto mountRegistry =
965+
monitoring && rdmaTargetConfig->ConnectionMonitoringEnabled
966+
? CreateMountRegistry(logging)
967+
: nullptr;
965968

966969
auto target = std::make_shared<TRdmaTarget>(
967970
std::move(rdmaTargetConfig),
968971
std::move(logging),
969972
std::move(traceSerializer),
970973
std::move(server),
971974
std::move(threadPool),
972-
std::move(mountRegistry),
975+
mountRegistry,
973976
std::move(service));
974977

975-
if (monitoring) {
978+
if (mountRegistry) {
976979
auto rootPage = monitoring->RegisterIndexPage("blockstore", "BlockStore");
977980
static_cast<TIndexMonPage&>(*rootPage).Register(
978981
new TRdmaTargetMonPage(target));

cloud/blockstore/libs/service_rdma/rdma_target.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ struct TBlockstoreServerRdmaTargetConfig
2323
TString Host = "localhost";
2424
ui32 Port = 10088;
2525
ui32 WorkerThreads = 1;
26+
bool ConnectionMonitoringEnabled = false;
2627

2728
explicit TBlockstoreServerRdmaTargetConfig(
2829
const NProto::TRdmaTarget& target)
2930
{
31+
ConnectionMonitoringEnabled = target.GetConnectionMonitoringEnabled();
32+
3033
const auto& endpoint = target.GetEndpoint();
3134

3235
if (const auto& host = endpoint.GetHost()) {

cloud/blockstore/libs/service_rdma/rdma_target_ut.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,15 @@ struct TTestEnv
153153
}
154154
};
155155

156-
TTestEnv CreateTestEnv(IBlockStorePtr service)
156+
TTestEnv CreateTestEnv(
157+
IBlockStorePtr service,
158+
bool connectionMonitoringEnabled = true)
157159
{
158160
auto server = std::make_shared<TTestServer>();
159161

160162
NProto::TRdmaTarget rdmaTargetProto;
163+
rdmaTargetProto.SetConnectionMonitoringEnabled(connectionMonitoringEnabled);
164+
161165
auto config =
162166
std::make_shared<TBlockstoreServerRdmaTargetConfig>(rdmaTargetProto);
163167

@@ -181,22 +185,25 @@ TTestEnv CreateTestEnv(IBlockStorePtr service)
181185
std::move(target)};
182186
}
183187

184-
NMonitoring::TIndexMonPage* FindRootPage(const IMonitoringServicePtr& monitoring)
188+
NMonitoring::IMonPage* FindRdmaTargetPage(
189+
const IMonitoringServicePtr& monitoring)
185190
{
186191
auto rootPage = monitoring->GetMonPage("blockstore");
187-
UNIT_ASSERT(rootPage);
192+
if (!rootPage) {
193+
return nullptr;
194+
}
188195

189196
auto* indexPage =
190197
dynamic_cast<NMonitoring::TIndexMonPage*>(rootPage.Get());
191198
UNIT_ASSERT(indexPage);
192199

193-
return indexPage;
200+
return indexPage->FindPage("RdmaTarget");
194201
}
195202

196203
TString RenderMonPage(const IMonitoringServicePtr& monitoring)
197204
{
198205
auto* page = dynamic_cast<NMonitoring::THtmlMonPage*>(
199-
FindRootPage(monitoring)->FindPage("RdmaTarget"));
206+
FindRdmaTargetPage(monitoring));
200207
UNIT_ASSERT(page);
201208

202209
TStringStream out;
@@ -506,7 +513,23 @@ Y_UNIT_TEST_SUITE(TRequestHandlerTest)
506513
auto service = std::make_shared<TTestService>();
507514
auto env = CreateTestEnv(service);
508515

509-
UNIT_ASSERT(FindRootPage(env.Monitoring)->FindPage("RdmaTarget"));
516+
UNIT_ASSERT(FindRdmaTargetPage(env.Monitoring));
517+
518+
env.Target->Stop();
519+
}
520+
521+
Y_UNIT_TEST(ShouldNotTrackConnectionsWhenMonitoringIsDisabled)
522+
{
523+
auto service = std::make_shared<TTestService>();
524+
auto env = CreateTestEnv(service, false);
525+
auto handler = env.GetHandler();
526+
527+
UNIT_ASSERT(!FindRdmaTargetPage(env.Monitoring));
528+
529+
// the handler still has to survive the connection events
530+
TTestSession session(4242);
531+
handler->OnSessionCreated(session);
532+
handler->OnSessionClosed(session.GetId());
510533

511534
env.Target->Stop();
512535
}

0 commit comments

Comments
 (0)