-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxim Deb Natkh
committed
Nov 28, 2024
1 parent
0c825cc
commit 5423cba
Showing
20 changed files
with
381 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
cloud/filestore/libs/storage/service/service_actor_actions_restart_local_filestores.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
#include "service_actor.h" | ||
|
||
#include "util/string/join.h" | ||
|
||
#include <cloud/filestore/libs/storage/api/service.h> | ||
#include <cloud/filestore/libs/storage/api/tablet.h> | ||
#include <cloud/filestore/libs/storage/api/tablet_proxy.h> | ||
#include <cloud/filestore/libs/storage/core/public.h> | ||
#include <cloud/filestore/private/api/protos/tablet.pb.h> | ||
|
||
#include <contrib/ydb/library/actors/core/actor_bootstrapped.h> | ||
|
||
#include <library/cpp/random_provider/random_provider.h> | ||
|
||
#include <google/protobuf/util/json_util.h> | ||
|
||
namespace NCloud::NFileStore::NStorage { | ||
|
||
using namespace NActors; | ||
|
||
using namespace NKikimr; | ||
|
||
namespace { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
class TRestartLocalFileStoresActionActor final | ||
: public TActorBootstrapped<TRestartLocalFileStoresActionActor> | ||
{ | ||
private: | ||
const TRequestInfoPtr RequestInfo; | ||
const TString Input; | ||
const TVector<TString> FileSystemIds; | ||
ui32 RemainingRestarts = 0; | ||
|
||
public: | ||
TRestartLocalFileStoresActionActor( | ||
TRequestInfoPtr requestInfo, | ||
TString input, | ||
TVector<TString> fileSystemIds) | ||
: RequestInfo(std::move(requestInfo)) | ||
, Input(std::move(input)) | ||
, FileSystemIds(std::move(fileSystemIds)) | ||
{} | ||
|
||
void Bootstrap(const TActorContext& ctx) | ||
{ | ||
Y_UNUSED(ctx); | ||
NProtoPrivate::TRestartLocalFileStoresRequest request; | ||
if (!google::protobuf::util::JsonStringToMessage(Input, &request).ok()) | ||
{ | ||
ReplyAndDie( | ||
ctx, | ||
TErrorResponse(E_ARGUMENT, "Failed to parse input")); | ||
return; | ||
} | ||
|
||
auto rng = CreateDeterministicRandomProvider(request.GetSeed()); | ||
|
||
LOG_INFO( | ||
ctx, | ||
TFileStoreComponents::SERVICE_WORKER, | ||
"Restarting local file stores: seed: %lu", | ||
request.GetSeed()); | ||
|
||
ui32 cookie = 0; | ||
|
||
for (const auto& fileSystemId: FileSystemIds) { | ||
if (rng->GenRand() % 2 == 0) { | ||
auto requestToTablet = | ||
std::make_unique<TEvIndexTablet::TEvWaitReadyRequest>(); | ||
requestToTablet->Record.SetFileSystemId(fileSystemId); | ||
|
||
LOG_INFO( | ||
ctx, | ||
TFileStoreComponents::SERVICE_WORKER, | ||
"Sending WaitReady to %s", | ||
fileSystemId.c_str()); | ||
|
||
NCloud::Send( | ||
ctx, | ||
MakeIndexTabletProxyServiceId(), | ||
std::move(requestToTablet), | ||
cookie); | ||
++RemainingRestarts; | ||
} | ||
++cookie; | ||
} | ||
|
||
if (RemainingRestarts == 0) { | ||
return ReplyAndDie(ctx, {}); | ||
} | ||
|
||
Become(&TThis::StateWork); | ||
} | ||
|
||
private: | ||
void ReplyAndDie( | ||
const TActorContext& ctx, | ||
const NProtoPrivate::TRestartLocalFileStoresResponse& response) | ||
{ | ||
auto msg = std::make_unique<TEvService::TEvExecuteActionResponse>( | ||
response.GetError()); | ||
|
||
google::protobuf::util::MessageToJsonString( | ||
response, | ||
msg->Record.MutableOutput()); | ||
|
||
NCloud::Reply(ctx, *RequestInfo, std::move(msg)); | ||
Die(ctx); | ||
} | ||
|
||
STFUNC(StateWork) | ||
{ | ||
switch (ev->GetTypeRewrite()) { | ||
HFunc( | ||
TEvIndexTablet::TEvWaitReadyResponse, | ||
HandleWaitReadyResponse); | ||
|
||
default: | ||
HandleUnexpectedEvent(ev, TFileStoreComponents::SERVICE); | ||
break; | ||
} | ||
} | ||
|
||
void HandleWaitReadyResponse( | ||
const TEvIndexTablet::TEvWaitReadyResponse::TPtr& ev, | ||
const TActorContext& ctx) | ||
{ | ||
--RemainingRestarts; | ||
Y_UNUSED(ev); | ||
|
||
LOG_INFO( | ||
ctx, | ||
TFileStoreComponents::SERVICE_WORKER, | ||
"Sending poison pill to %s", | ||
FileSystemIds.at(ev->Cookie).c_str()); | ||
NCloud::Send( | ||
ctx, | ||
ev->Sender, | ||
std::make_unique<TEvents::TEvPoisonPill>()); | ||
|
||
if (RemainingRestarts == 0) { | ||
ReplyAndDie(ctx, {}); | ||
} | ||
} | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
} // namespace | ||
|
||
IActorPtr TStorageServiceActor::CreateRestartLocalFileStoresActionActor( | ||
TRequestInfoPtr requestInfo, | ||
TString input) | ||
{ | ||
TVector<TString> fileSystemIds; | ||
for (const auto& [fs, _]: State->GetLocalFileStores()) { | ||
fileSystemIds.push_back(fs); | ||
} | ||
|
||
return std::make_unique<TRestartLocalFileStoresActionActor>( | ||
std::move(requestInfo), | ||
std::move(input), | ||
std::move(fileSystemIds)); | ||
} | ||
|
||
} // namespace NCloud::NFileStore::NStorage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
cloud/filestore/tests/fio_index/qemu-kikimr-multishard-tablets-restart-test/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
import cloud.storage.core.tools.testing.fio.lib as fio | ||
|
||
from cloud.filestore.tests.python.lib.common import get_filestore_mount_path | ||
|
||
|
||
TESTS = fio.generate_index_tests() | ||
|
||
|
||
@pytest.mark.parametrize("name", TESTS.keys()) | ||
def test_fio(name): | ||
mount_dir = get_filestore_mount_path() | ||
dir_name = fio.get_dir_name(mount_dir, name) | ||
|
||
fio.run_index_test(dir_name, TESTS[name], fail_on_errors=True) |
33 changes: 33 additions & 0 deletions
33
cloud/filestore/tests/fio_index/qemu-kikimr-multishard-tablets-restart-test/ya.make
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
PY3TEST() | ||
|
||
INCLUDE(${ARCADIA_ROOT}/cloud/filestore/tests/recipes/medium.inc) | ||
|
||
DEPENDS( | ||
cloud/storage/core/tools/testing/fio/bin | ||
) | ||
|
||
PEERDIR( | ||
cloud/filestore/tests/python/lib | ||
cloud/storage/core/tools/testing/fio/lib | ||
) | ||
|
||
TEST_SRCS( | ||
test.py | ||
) | ||
|
||
SET(QEMU_VIRTIO fs) | ||
SET(FILESTORE_SHARD_COUNT 5) | ||
SET( | ||
NFS_STORAGE_CONFIG_PATCH | ||
cloud/filestore/tests/loadtest/service-kikimr-newfeatures-test/nfs-storage.txt | ||
) | ||
|
||
INCLUDE(${ARCADIA_ROOT}/cloud/filestore/tests/recipes/service-kikimr.inc) | ||
INCLUDE(${ARCADIA_ROOT}/cloud/filestore/tests/recipes/vhost-kikimr.inc) | ||
INCLUDE(${ARCADIA_ROOT}/cloud/filestore/tests/recipes/vhost-endpoint.inc) | ||
INCLUDE(${ARCADIA_ROOT}/cloud/storage/core/tests/recipes/qemu.inc) | ||
|
||
SET(FILESTORE_TABLETS_RESTART_INTERVAL 5) | ||
INCLUDE(${ARCADIA_ROOT}/cloud/filestore/tests/recipes/tablets-restarter.inc) | ||
|
||
END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
DEPENDS( | ||
cloud/filestore/tests/recipes/tablets-restarter | ||
) | ||
|
||
|
||
IF (FILESTORE_TABLETS_RESTART_INTERVAL) | ||
SET(RECIPE_ARGS --restart-interval $FILESTORE_TABLETS_RESTART_INTERVAL) | ||
ELSE() | ||
MESSAGE(FATAL_ERROR FILESTORE_TABLETS_RESTART_INTERVAL should be set for tablets-restarter recipe to work) | ||
ENDIF() | ||
|
||
USE_RECIPE( | ||
cloud/filestore/tests/recipes/tablets-restarter/filestore-tablets-restarter | ||
${RECIPE_ARGS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### tablets-restarter | ||
|
||
Include this recipe to get a process that regularly restarts random tablets of a filestore using a private `restartlocalfilestores` action. |
Oops, something went wrong.