diff --git a/cloud/filestore/libs/storage/service/service_actor_createsession.cpp b/cloud/filestore/libs/storage/service/service_actor_createsession.cpp index eb7781e1b3..18dd7efd2f 100644 --- a/cloud/filestore/libs/storage/service/service_actor_createsession.cpp +++ b/cloud/filestore/libs/storage/service/service_actor_createsession.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace NCloud::NFileStore::NStorage { @@ -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; @@ -692,6 +693,10 @@ void TStorageServiceActor::HandleCreateSession( sessionId = CreateGuidAsString(); } + if (!originFqdn) { + originFqdn = GetFQDNHostName(); + } + auto requestInfo = CreateRequestInfo( SelfId(), cookie, @@ -704,7 +709,7 @@ void TStorageServiceActor::HandleCreateSession( fileSystemId, sessionId, checkpointId, - originFqdn, + std::move(originFqdn), msg->Record.GetMountSeqNumber(), msg->Record.GetReadOnly(), msg->Record.GetRestoreClientSession(), diff --git a/cloud/filestore/libs/storage/service/service_ut.cpp b/cloud/filestore/libs/storage/service/service_ut.cpp index 29185afc69..f304fc7c65 100644 --- a/cloud/filestore/libs/storage/service/service_ut.cpp +++ b/cloud/filestore/libs/storage/service/service_ut.cpp @@ -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& event) mutable { + switch (event->GetTypeRewrite()) { + case TEvIndexTablet::EvCreateSessionRequest: { + const auto* msg = + event->Get(); + UNIT_ASSERT_VALUES_UNEQUAL("", GetOriginFqdn(msg->Record)); + break; + } + } + + return TTestActorRuntime::DefaultObserverFunc(event); + }); + + THeaders headers = {"test", "client", "", 0}; + service.CreateSession(headers); + } } } // namespace NCloud::NFileStore::NStorage