Skip to content

Commit

Permalink
tablet history entries should contain fqdn (#325)
Browse files Browse the repository at this point in the history
* tablet history entries should contain fqdn

* add ut

* removed useless code

* fix test
  • Loading branch information
yegorskii committed Feb 5, 2024
1 parent a3b0687 commit 917f11e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <util/generic/deque.h>
#include <util/generic/guid.h>
#include <util/generic/string.h>
#include <util/system/hostname.h>

namespace NCloud::NFileStore::NStorage {

Expand Down Expand Up @@ -615,7 +616,7 @@ void TStorageServiceActor::HandleCreateSession(
const auto& clientId = GetClientId(msg->Record);
const auto& fileSystemId = msg->Record.GetFileSystemId();
const auto& checkpointId = msg->Record.GetCheckpointId();
const auto& originFqdn = GetOriginFqdn(msg->Record);
auto originFqdn = GetOriginFqdn(msg->Record);

ui64 cookie;
TInFlightRequest* inflight;
Expand Down Expand Up @@ -692,6 +693,10 @@ void TStorageServiceActor::HandleCreateSession(
sessionId = CreateGuidAsString();
}

if (!originFqdn) {
originFqdn = GetFQDNHostName();
}

auto requestInfo = CreateRequestInfo(
SelfId(),
cookie,
Expand All @@ -704,7 +709,7 @@ void TStorageServiceActor::HandleCreateSession(
fileSystemId,
sessionId,
checkpointId,
originFqdn,
std::move(originFqdn),
msg->Record.GetMountSeqNumber(),
msg->Record.GetReadOnly(),
msg->Record.GetRestoreClientSession(),
Expand Down
28 changes: 28 additions & 0 deletions cloud/filestore/libs/storage/service/service_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,34 @@ Y_UNIT_TEST_SUITE(TStorageServiceTest)

service.DestroySession(headers);
}

Y_UNIT_TEST(ShouldFillOriginFqdnWhenCreatingSession)
{
TTestEnv env;
env.CreateSubDomain("nfs");

ui32 nodeIdx = env.CreateNode("nfs");

TServiceClient service(env.GetRuntime(), nodeIdx);
service.CreateFileStore("test", 1000);

auto& runtime = env.GetRuntime();
runtime.SetObserverFunc([&] (TAutoPtr<IEventHandle>& event) mutable {
switch (event->GetTypeRewrite()) {
case TEvIndexTablet::EvCreateSessionRequest: {
const auto* msg =
event->Get<TEvIndexTablet::TEvCreateSessionRequest>();
UNIT_ASSERT_VALUES_UNEQUAL("", GetOriginFqdn(msg->Record));
break;
}
}

return TTestActorRuntime::DefaultObserverFunc(event);
});

THeaders headers = {"test", "client", "", 0};
service.CreateSession(headers);
}
}

} // namespace NCloud::NFileStore::NStorage

0 comments on commit 917f11e

Please sign in to comment.