Skip to content
Open
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 cloud/blockstore/libs/storage/service/service_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ class TServiceActor final
TRequestInfoPtr requestInfo,
TString input);

TResultOrError<NActors::IActorPtr> CreateDiskRegistryEnsureStateIntegrityActor(
TRequestInfoPtr requestInfo,
TString input);

TResultOrError<NActors::IActorPtr> CreateReplaceDeviceActionActor(
TRequestInfoPtr requestInfo,
TString input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void TServiceActor::HandleExecuteAction(
{"describevolume", &TServiceActor::CreateDescribeVolumeActionActor },
{"diskregistrychangestate", &TServiceActor::CreateDiskRegistryChangeStateActor },
{"drainnode", &TServiceActor::CreateDrainNodeActionActor },
{"ensurediskregistrystateintegrity", &TServiceActor::CreateDiskRegistryEnsureStateIntegrityActor },
{"finishfilldisk", &TServiceActor::CreateFinishFillDiskActionActor },
{"getcompactionstatus", &TServiceActor::CreateGetCompactionStatusActionActor },
{"getdependentdisks", &TServiceActor::CreateGetDependentDisksActionActor },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#include "service_actor.h"

#include <cloud/blockstore/libs/storage/api/disk_registry.h>
#include <cloud/blockstore/libs/storage/api/disk_registry_proxy.h>
#include <cloud/blockstore/libs/storage/core/probes.h>

#include <contrib/ydb/library/actors/core/actor_bootstrapped.h>
#include <contrib/ydb/library/actors/core/events.h>
#include <contrib/ydb/library/actors/core/hfunc.h>
#include <contrib/ydb/library/actors/core/log.h>

#include <google/protobuf/util/json_util.h>

namespace NCloud::NBlockStore::NStorage {

using namespace NActors;

using namespace NKikimr;

LWTRACE_USING(BLOCKSTORE_STORAGE_PROVIDER)

namespace {

////////////////////////////////////////////////////////////////////////////////

class TEnsureDiskRegistryStateIntegrityActor final
: public TActorBootstrapped<TEnsureDiskRegistryStateIntegrityActor>
{
private:
const TRequestInfoPtr RequestInfo;
const TString Input;

NProto::TError Error;

public:
TEnsureDiskRegistryStateIntegrityActor(
TRequestInfoPtr requestInfo,
TString input);

void Bootstrap(const TActorContext& ctx);

private:
void ReplyAndDie(
const TActorContext& ctx,
std::unique_ptr<TEvService::TEvExecuteActionResponse> response);

private:
STFUNC(StateEnsureDiskRegistryStateIntegrity);

void HandleEnsureDiskRegistryStateIntegrityResponse(
const TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityResponse::
TPtr& ev,
const TActorContext& ctx);
};

////////////////////////////////////////////////////////////////////////////////

TEnsureDiskRegistryStateIntegrityActor::TEnsureDiskRegistryStateIntegrityActor(
TRequestInfoPtr requestInfo,
TString input)
: RequestInfo(std::move(requestInfo))
, Input(std::move(input))
{}

void TEnsureDiskRegistryStateIntegrityActor::Bootstrap(const TActorContext& ctx)
{
auto request = std::make_unique<
TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityRequest>();

if (!google::protobuf::util::JsonStringToMessage(Input, &request->Record)
.ok())
{
Error = MakeError(E_ARGUMENT, "Failed to parse input");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эта ошибка где используется?

ReplyAndDie(
ctx,
std::make_unique<TEvService::TEvExecuteActionResponse>());
return;
}

Become(&TThis::StateEnsureDiskRegistryStateIntegrity);

NCloud::Send(ctx, MakeDiskRegistryProxyServiceId(), std::move(request));
}

void TEnsureDiskRegistryStateIntegrityActor::ReplyAndDie(
const TActorContext& ctx,
std::unique_ptr<TEvService::TEvExecuteActionResponse> response)
{
LWTRACK(
ResponseSent_Service,
RequestInfo->CallContext->LWOrbit,
"ExecuteAction_ensurediskregistrystateintegrity",
RequestInfo->CallContext->RequestId);

NCloud::Reply(ctx, *RequestInfo, std::move(response));
Die(ctx);
}

////////////////////////////////////////////////////////////////////////////////

void TEnsureDiskRegistryStateIntegrityActor::
HandleEnsureDiskRegistryStateIntegrityResponse(
const TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityResponse::
TPtr& ev,
const TActorContext& ctx)
{
const auto* msg = ev->Get();

TString output;
google::protobuf::util::MessageToJsonString(msg->Record, &output);
auto response = std::make_unique<TEvService::TEvExecuteActionResponse>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если пришла ошибка, то правильно её в ответ и завернуть

response->Record.SetOutput(output);
ReplyAndDie(ctx, std::move(response));
}

////////////////////////////////////////////////////////////////////////////////

STFUNC(
TEnsureDiskRegistryStateIntegrityActor::
StateEnsureDiskRegistryStateIntegrity)
{
switch (ev->GetTypeRewrite()) {
HFunc(
TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityResponse,
HandleEnsureDiskRegistryStateIntegrityResponse);

default:
HandleUnexpectedEvent(
ev,
TBlockStoreComponents::SERVICE,
__PRETTY_FUNCTION__);
break;
}
}

} // namespace

////////////////////////////////////////////////////////////////////////////////

TResultOrError<IActorPtr>
TServiceActor::CreateDiskRegistryEnsureStateIntegrityActor(
TRequestInfoPtr requestInfo,
TString input)
{
return {std::make_unique<TEnsureDiskRegistryStateIntegrityActor>(
std::move(requestInfo),
std::move(input))};
}

} // namespace NCloud::NBlockStore::NStorage
1 change: 1 addition & 0 deletions cloud/blockstore/libs/storage/service/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SRCS(
service_actor_actions_describe_blocks.cpp
service_actor_actions_describe.cpp
service_actor_actions_disk_registry_change_state.cpp
service_actor_actions_disk_registry_ensure_state_integrity.cpp
service_actor_actions_drain_node.cpp
service_actor_actions_finish_fill_disk.cpp
service_actor_actions_flush_profile_log.cpp
Expand Down
14 changes: 14 additions & 0 deletions cloud/blockstore/libs/storage/testlib/disk_registry_proxy_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ class TDiskRegistryProxyMock final
TEvDiskRegistry::TEvGetClusterCapacityRequest,
HandleGetClusterCapacity);

HFunc(
TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityRequest,
HandleEnsureDiskRegistryStateIntegrity);

IgnoreFunc(NKikimr::TEvLocal::TEvTabletMetrics);

default:
Expand Down Expand Up @@ -1100,6 +1104,16 @@ class TDiskRegistryProxyMock final
*response->Record.AddCapacity() = std::move(capacityInfo);
NCloud::Reply(ctx, *ev, std::move(response));
}

void HandleEnsureDiskRegistryStateIntegrity(
const TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityRequest::TPtr& ev,
const NActors::TActorContext& ctx)
{
NCloud::Reply(
ctx,
*ev,
std::make_unique<TEvDiskRegistry::TEvEnsureDiskRegistryStateIntegrityResponse>());
}
};

} // namespace NCloud::NBlockStore::NStorage
Loading
Loading