diff options
author | savnik <savnik@yandex-team.com> | 2023-06-06 14:29:50 +0300 |
---|---|---|
committer | savnik <savnik@yandex-team.com> | 2023-06-06 14:29:50 +0300 |
commit | cb163fee0ba3ee7d1b165c48df3b34732f807c27 (patch) | |
tree | 134c0a1f2de021b39611452d0c8473dbe68b292d | |
parent | 158fd4c99f92da521814681c90072d02efb92be3 (diff) | |
download | ydb-cb163fee0ba3ee7d1b165c48df3b34732f807c27.tar.gz |
switch to new folder_service
fix TEvFolderService events
switch to a new folder_service
39 files changed, 674 insertions, 335 deletions
diff --git a/ydb/apps/ydbd/main.cpp b/ydb/apps/ydbd/main.cpp index 9f4de1a66ca..e6c6002f16a 100644 --- a/ydb/apps/ydbd/main.cpp +++ b/ydb/apps/ydbd/main.cpp @@ -3,7 +3,7 @@ #include <ydb/core/driver_lib/run/main.h> #include <ydb/core/security/ticket_parser.h> #include <ydb/core/ymq/actor/auth_factory.h> -#include <ydb/library/folder_service/mock/mock_folder_service.h> +#include <ydb/library/folder_service/mock/mock_folder_service_adapter.h> #include <ydb/library/pdisk_io/aio.h> #include <ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h> #include <ydb/core/http_proxy/auth_factory.h> @@ -15,7 +15,7 @@ int main(int argc, char **argv) { auto factories = std::make_shared<NKikimr::TModuleFactories>(); factories->DataShardExportFactory = std::make_shared<TDataShardExportFactory>(); factories->CreateTicketParser = NKikimr::CreateTicketParser; - factories->FolderServiceFactory = NKikimr::NFolderService::CreateMockFolderServiceActor; + factories->FolderServiceFactory = NKikimr::NFolderService::CreateMockFolderServiceAdapterActor; factories->IoContextFactory = std::make_shared<NKikimr::NPDisk::TIoContextFactoryOSS>(); factories->SqsAuthFactory = std::make_shared<NKikimr::NSQS::TAuthFactory>(); factories->DataStreamsAuthFactory = std::make_shared<NKikimr::NHttpProxy::TIamAuthFactory>(); diff --git a/ydb/core/fq/libs/cloud_audit/yq_cloud_audit_service.cpp b/ydb/core/fq/libs/cloud_audit/yq_cloud_audit_service.cpp index 41bdee8fc28..5b34cfd43b7 100644 --- a/ydb/core/fq/libs/cloud_audit/yq_cloud_audit_service.cpp +++ b/ydb/core/fq/libs/cloud_audit/yq_cloud_audit_service.cpp @@ -187,7 +187,7 @@ namespace NFq { template<class TEvent, class TRequest, class TAuditDetailsObj> class TAuditEventSenderActor : public NActors::TActorBootstrapped<TAuditEventSenderActor<TEvent, TRequest, TAuditDetailsObj>> { using Base = NActors::TActorBootstrapped<TAuditEventSenderActor<TEvent, TRequest, TAuditDetailsObj>>; - using IRetryPolicy = IRetryPolicy<NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse::TPtr&>; + using IRetryPolicy = IRetryPolicy<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse::TPtr&>; public: TAuditEventSenderActor( @@ -249,22 +249,21 @@ public: Base::Send(NKikimr::NFolderService::FolderServiceActorId(), CreateRequest().release(), 0, 0); } - std::unique_ptr<NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest> CreateRequest() { - auto request = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest>(); - request->Request.set_folder_id(ExtraInfo.FolderId); + std::unique_ptr<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest> CreateRequest() { + auto request = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest>(); + request->FolderId = ExtraInfo.FolderId; request->Token = ExtraInfo.Token; return request; } private: STRICT_STFUNC(StateFunc, - hFunc(NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse, Handle); + hFunc(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse, Handle); ) - void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse::TPtr& ev) { - const auto& response = ev->Get()->Response; + void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse::TPtr& ev) { const auto& status = ev->Get()->Status; - if (!status.Ok() || !response.has_folder()) { + if (!status.Ok() || ev->Get()->CloudId.empty()) { auto& status = ev->Get()->Status; auto delay = RetryState->GetNextRetryDelay(ev); if (delay) { @@ -286,7 +285,7 @@ private: AuditServiceSensors->ReportCloudIdResolvedSuccess(); LOG_YQ_AUDIT_SERVICE_TRACE("EventId: " << *EventId << " cloud id resolved"); - const auto cloudId = ev->Get()->Response.folder().cloud_id(); + const auto cloudId = ev->Get()->CloudId; CloudEvent.mutable_event_metadata()->set_cloud_id(cloudId); SendAndComplete(); } @@ -330,10 +329,9 @@ private: } static const IRetryPolicy::TPtr& GetRetryPolicy() { - static IRetryPolicy::TPtr policy = IRetryPolicy::GetExponentialBackoffPolicy([](NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse::TPtr& ev) { - const auto& response = ev->Get()->Response; + static IRetryPolicy::TPtr policy = IRetryPolicy::GetExponentialBackoffPolicy([](NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse::TPtr& ev) { const auto& status = ev->Get()->Status; - return !status.Ok() || !response.has_folder() ? ERetryErrorClass::ShortRetry : ERetryErrorClass::NoRetry; + return !status.Ok() || ev->Get()->CloudId.empty() ? ERetryErrorClass::ShortRetry : ERetryErrorClass::NoRetry; }, TDuration::MilliSeconds(10), TDuration::MilliSeconds(200), TDuration::Seconds(30), 5); return policy; } diff --git a/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp b/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp index d071c748058..088fc97da9e 100644 --- a/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp +++ b/ydb/core/fq/libs/control_plane_proxy/control_plane_proxy.cpp @@ -372,7 +372,7 @@ class TResolveFolderActor : public NActors::TActorBootstrapped<TResolveFolderAct using TBase::PassAway; using TBase::Become; using TBase::Register; - using IRetryPolicy = IRetryPolicy<NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse::TPtr&>; + using IRetryPolicy = IRetryPolicy<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse::TPtr&>; ::NFq::TControlPlaneProxyConfig Config; TActorId Sender; @@ -416,16 +416,16 @@ public: Send(NKikimr::NFolderService::FolderServiceActorId(), CreateRequest().release(), 0, 0); } - std::unique_ptr<NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest> CreateRequest() { - auto request = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest>(); - request->Request.set_folder_id(FolderId); + std::unique_ptr<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest> CreateRequest() { + auto request = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest>(); + request->FolderId = FolderId; request->Token = Token; return request; } STRICT_STFUNC(StateFunc, cFunc(NActors::TEvents::TSystem::Wakeup, HandleTimeout); - hFunc(NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse, Handle); + hFunc(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse, Handle); ) void HandleTimeout() { @@ -441,12 +441,11 @@ public: PassAway(); } - void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse::TPtr& ev) { + void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse::TPtr& ev) { Counters->InFly->Dec(); Counters->LatencyMs->Collect((TInstant::Now() - StartTime).MilliSeconds()); - const auto& response = ev->Get()->Response; const auto& status = ev->Get()->Status; - if (!status.Ok() || !response.has_folder()) { + if (!status.Ok() || ev->Get()->CloudId.empty()) { TString errorMessage = "Msg: " + status.Msg + " Details: " + status.Details + " Code: " + ToString(status.GRpcStatusCode) + " InternalError: " + ToString(status.InternalError); auto delay = RetryState->GetNextRetryDelay(ev); if (delay) { @@ -469,7 +468,7 @@ public: } Counters->Ok->Inc(); - TString cloudId = response.folder().cloud_id(); + TString cloudId = ev->Get()->CloudId; Event->Get()->CloudId = cloudId; CPP_LOG_T("Cloud id: " << cloudId << " Folder id: " << FolderId); @@ -483,10 +482,9 @@ public: private: static const IRetryPolicy::TPtr& GetRetryPolicy() { - static IRetryPolicy::TPtr policy = IRetryPolicy::GetExponentialBackoffPolicy([](NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse::TPtr& ev) { - const auto& response = ev->Get()->Response; + static IRetryPolicy::TPtr policy = IRetryPolicy::GetExponentialBackoffPolicy([](NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse::TPtr& ev) { const auto& status = ev->Get()->Status; - return !status.Ok() || !response.has_folder() ? ERetryErrorClass::ShortRetry : ERetryErrorClass::NoRetry; + return !status.Ok() || ev->Get()->CloudId.empty() ? ERetryErrorClass::ShortRetry : ERetryErrorClass::NoRetry; }, TDuration::MilliSeconds(10), TDuration::MilliSeconds(200), TDuration::Seconds(30), 5); return policy; } diff --git a/ydb/core/fq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp b/ydb/core/fq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp index 9aa6f5c1ec8..225f1f73f07 100644 --- a/ydb/core/fq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp +++ b/ydb/core/fq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp @@ -24,7 +24,7 @@ #include <ydb/core/base/path.h> #include <ydb/library/folder_service/folder_service.h> -#include <ydb/library/folder_service/mock/mock_folder_service.h> +#include <ydb/library/folder_service/mock/mock_folder_service_adapter.h> #include <util/system/env.h> @@ -384,7 +384,7 @@ private: ControlPlaneProxyActorId(), TActorSetupCmd(controlPlaneProxy, TMailboxType::Simple, 0)); - auto folderService = NKikimr::NFolderService::CreateMockFolderServiceActor(NKikimrProto::NFolderService::TFolderServiceConfig{}); + auto folderService = NKikimr::NFolderService::CreateMockFolderServiceAdapterActor(NKikimrProto::NFolderService::TFolderServiceConfig{}); runtime->AddLocalService( NKikimr::NFolderService::FolderServiceActorId(), TActorSetupCmd(folderService, TMailboxType::Simple, 0), diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto index 65118fc7ff7..3f67dcfc6f1 100644 --- a/ydb/core/protos/config.proto +++ b/ydb/core/protos/config.proto @@ -864,6 +864,7 @@ message TSqsConfig { optional uint32 YandexCloudServiceId = 16; // only 15 lesser bits should be used! optional string YandexCloudAccessServiceAddress = 29; // host:port optional string YandexCloudFolderServiceAddress = 30; // host:port + optional string YandexCloudResourceManagerServiceAddress = 72; // host:port optional string YandexCloudServiceRegion = 39 [default = "ru-central1"]; optional uint32 MeteringFlushingIntervalMs = 51 [default = 5000]; diff --git a/ydb/core/testlib/test_client.cpp b/ydb/core/testlib/test_client.cpp index 3bcecec7be8..046413257ea 100644 --- a/ydb/core/testlib/test_client.cpp +++ b/ydb/core/testlib/test_client.cpp @@ -98,7 +98,7 @@ #include <ydb/services/ext_index/service/executor.h> #include <ydb/core/tx/conveyor/service/service.h> #include <ydb/core/tx/conveyor/usage/service.h> -#include <ydb/library/folder_service/mock/mock_folder_service.h> +#include <ydb/library/folder_service/mock/mock_folder_service_adapter.h> #include <ydb/core/client/server/msgbus_server_tracer.h> @@ -997,7 +997,7 @@ namespace Tests { "TestTenant", nullptr, // MakeIntrusive<NPq::NConfigurationManager::TConnections>(), YqSharedResources, - NKikimr::NFolderService::CreateMockFolderServiceActor, + NKikimr::NFolderService::CreateMockFolderServiceAdapterActor, /*IcPort = */0, {} ); diff --git a/ydb/library/folder_service/events.h b/ydb/library/folder_service/events.h index 71329b1d4fe..a85102bbe61 100644 --- a/ydb/library/folder_service/events.h +++ b/ydb/library/folder_service/events.h @@ -1,6 +1,5 @@ #pragma once -#include <ydb/library/folder_service/proto/folder_service.pb.h> #include <ydb/core/base/events.h> #include <library/cpp/grpc/client/grpc_client_low.h> @@ -10,24 +9,25 @@ namespace NKikimr::NFolderService { struct TEvFolderService { enum EEv { // requests - EvGetFolderRequest = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE_ADAPTER), + EvGetCloudByFolderRequest = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE_ADAPTER), // replies - EvGetFolderResponse = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE_ADAPTER) + 512, + EvGetCloudByFolderResponse = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE_ADAPTER) + 512, EvEnd }; static_assert(EvEnd < EventSpaceEnd(TKikimrEvents::ES_FOLDER_SERVICE_ADAPTER), "expect EvEnd < EventSpaceEnd(TKikimrEvents::ES_FOLDER_SERVICE_ADAPTER)"); - struct TEvGetFolderRequest : TEventLocal<TEvGetFolderRequest, EvGetFolderRequest> { - NKikimrProto::NFolderService::GetFolderRequest Request; + struct TEvGetCloudByFolderRequest : TEventLocal<TEvGetCloudByFolderRequest, EvGetCloudByFolderRequest> { + TString FolderId; TString Token; TString RequestId; }; - struct TEvGetFolderResponse : TEventLocal<TEvGetFolderResponse, EvGetFolderResponse> { - NKikimrProto::NFolderService::GetFolderResponse Response; + struct TEvGetCloudByFolderResponse : TEventLocal<TEvGetCloudByFolderResponse, EvGetCloudByFolderResponse> { + TString FolderId; + TString CloudId; NGrpc::TGrpcStatus Status; }; }; diff --git a/ydb/library/folder_service/mock/CMakeLists.darwin-x86_64.txt b/ydb/library/folder_service/mock/CMakeLists.darwin-x86_64.txt index 427fe81796f..19749a1a0f6 100644 --- a/ydb/library/folder_service/mock/CMakeLists.darwin-x86_64.txt +++ b/ydb/library/folder_service/mock/CMakeLists.darwin-x86_64.txt @@ -19,5 +19,5 @@ target_link_libraries(library-folder_service-mock PUBLIC library-folder_service-proto ) target_sources(library-folder_service-mock PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp ) diff --git a/ydb/library/folder_service/mock/CMakeLists.linux-aarch64.txt b/ydb/library/folder_service/mock/CMakeLists.linux-aarch64.txt index bfbb6d839e8..d79d0a353fa 100644 --- a/ydb/library/folder_service/mock/CMakeLists.linux-aarch64.txt +++ b/ydb/library/folder_service/mock/CMakeLists.linux-aarch64.txt @@ -20,5 +20,5 @@ target_link_libraries(library-folder_service-mock PUBLIC library-folder_service-proto ) target_sources(library-folder_service-mock PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp ) diff --git a/ydb/library/folder_service/mock/CMakeLists.linux-x86_64.txt b/ydb/library/folder_service/mock/CMakeLists.linux-x86_64.txt index bfbb6d839e8..d79d0a353fa 100644 --- a/ydb/library/folder_service/mock/CMakeLists.linux-x86_64.txt +++ b/ydb/library/folder_service/mock/CMakeLists.linux-x86_64.txt @@ -20,5 +20,5 @@ target_link_libraries(library-folder_service-mock PUBLIC library-folder_service-proto ) target_sources(library-folder_service-mock PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp ) diff --git a/ydb/library/folder_service/mock/CMakeLists.windows-x86_64.txt b/ydb/library/folder_service/mock/CMakeLists.windows-x86_64.txt index 427fe81796f..19749a1a0f6 100644 --- a/ydb/library/folder_service/mock/CMakeLists.windows-x86_64.txt +++ b/ydb/library/folder_service/mock/CMakeLists.windows-x86_64.txt @@ -19,5 +19,5 @@ target_link_libraries(library-folder_service-mock PUBLIC library-folder_service-proto ) target_sources(library-folder_service-mock PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp ) diff --git a/ydb/library/folder_service/mock/mock_folder_service.cpp b/ydb/library/folder_service/mock/mock_folder_service.cpp deleted file mode 100644 index 12e825fed81..00000000000 --- a/ydb/library/folder_service/mock/mock_folder_service.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include <ydb/library/folder_service/mock/mock_folder_service.h> -#include <ydb/library/folder_service/events.h> -#include <library/cpp/actors/core/hfunc.h> - -namespace NKikimr::NFolderService { - -class TFolderServiceMock - : public NActors::TActor<TFolderServiceMock> { - using TThis = TFolderServiceMock; - using TBase = NActors::TActor<TFolderServiceMock>; - - using TEvListFolderRequest = NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest; - using TEvListFolderResponse = NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse; - -public: - TFolderServiceMock() - : TBase(&TThis::StateWork) { - } - - void Handle(TEvListFolderRequest::TPtr& ev) { - auto folderId = ev.Get()->Get()->Request.folder_id(); - auto result = std::make_unique<TEvListFolderResponse>(); - auto* fakeFolder = result->Response.mutable_folder(); - TString cloudId = "mock_cloud"; - auto p = folderId.find('@'); - if (p != folderId.npos) { - cloudId = folderId.substr(p + 1); - } - fakeFolder->set_id(folderId); - fakeFolder->set_cloud_id(cloudId); - result->Status = NGrpc::TGrpcStatus(); - Send(ev->Sender, result.release()); - } - - STATEFN(StateWork) { - switch (ev->GetTypeRewrite()) { - hFunc(TEvListFolderRequest, Handle) - cFunc(NActors::TEvents::TEvPoisonPill::EventType, PassAway) - } - } -}; - -NActors::IActor* CreateMockFolderServiceActor(const NKikimrProto::NFolderService::TFolderServiceConfig&) { - return new TFolderServiceMock(); -} -} // namespace NKikimr::NFolderService diff --git a/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp b/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp new file mode 100644 index 00000000000..1a5afaa5a12 --- /dev/null +++ b/ydb/library/folder_service/mock/mock_folder_service_adapter.cpp @@ -0,0 +1,46 @@ +#include <ydb/library/folder_service/mock/mock_folder_service_adapter.h> +#include <ydb/library/folder_service/events.h> +#include <library/cpp/actors/core/hfunc.h> + +namespace NKikimr::NFolderService { + +class TFolderServiceAdapterMock + : public NActors::TActor<TFolderServiceAdapterMock> { + using TThis = TFolderServiceAdapterMock; + using TBase = NActors::TActor<TFolderServiceAdapterMock>; + + using TEvGetCloudByFolderRequest = NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest; + using TEvGetCloudByFolderResponse = NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse; + +public: + TFolderServiceAdapterMock() + : TBase(&TThis::StateWork) { + } + + void Handle(TEvGetCloudByFolderRequest::TPtr& ev) { + auto folderId = ev->Get()->FolderId; + auto result = std::make_unique<TEvGetCloudByFolderResponse>(); + TString cloudId = "mock_cloud"; + auto p = folderId.find('@'); + if (p != folderId.npos) { + cloudId = folderId.substr(p + 1); + } + result->FolderId = folderId; + result->CloudId = cloudId; + + result->Status = NGrpc::TGrpcStatus(); + Send(ev->Sender, result.release()); + } + + STATEFN(StateWork) { + switch (ev->GetTypeRewrite()) { + hFunc(TEvGetCloudByFolderRequest, Handle) + cFunc(NActors::TEvents::TEvPoisonPill::EventType, PassAway) + } + } +}; + +NActors::IActor* CreateMockFolderServiceAdapterActor(const NKikimrProto::NFolderService::TFolderServiceConfig&) { + return new TFolderServiceAdapterMock(); +} +} // namespace NKikimr::NFolderService diff --git a/ydb/library/folder_service/mock/mock_folder_service.h b/ydb/library/folder_service/mock/mock_folder_service_adapter.h index 301ad2f5518..b8aa24e1a60 100644 --- a/ydb/library/folder_service/mock/mock_folder_service.h +++ b/ydb/library/folder_service/mock/mock_folder_service_adapter.h @@ -6,5 +6,5 @@ namespace NKikimr::NFolderService { -NActors::IActor* CreateMockFolderServiceActor(const NKikimrProto::NFolderService::TFolderServiceConfig& config); +NActors::IActor* CreateMockFolderServiceAdapterActor(const NKikimrProto::NFolderService::TFolderServiceConfig& config); } diff --git a/ydb/library/folder_service/proto/CMakeLists.darwin-x86_64.txt b/ydb/library/folder_service/proto/CMakeLists.darwin-x86_64.txt index bd40178fc1e..9d9c4e98f2b 100644 --- a/ydb/library/folder_service/proto/CMakeLists.darwin-x86_64.txt +++ b/ydb/library/folder_service/proto/CMakeLists.darwin-x86_64.txt @@ -18,18 +18,6 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) -get_built_tool_path( - TOOL_protoc_bin - TOOL_protoc_dependency - contrib/tools/protoc/bin - protoc -) -get_built_tool_path( - TOOL_cpp_styleguide_bin - TOOL_cpp_styleguide_dependency - contrib/tools/protoc/plugins/cpp_styleguide - cpp_styleguide -) add_library(library-folder_service-proto) target_link_libraries(library-folder_service-proto PUBLIC @@ -39,7 +27,6 @@ target_link_libraries(library-folder_service-proto PUBLIC ) target_proto_messages(library-folder_service-proto PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/config.proto - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/folder_service.proto ) target_proto_addincls(library-folder_service-proto ./ diff --git a/ydb/library/folder_service/proto/CMakeLists.linux-aarch64.txt b/ydb/library/folder_service/proto/CMakeLists.linux-aarch64.txt index 9b7472b986a..9698675f991 100644 --- a/ydb/library/folder_service/proto/CMakeLists.linux-aarch64.txt +++ b/ydb/library/folder_service/proto/CMakeLists.linux-aarch64.txt @@ -18,18 +18,6 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) -get_built_tool_path( - TOOL_protoc_bin - TOOL_protoc_dependency - contrib/tools/protoc/bin - protoc -) -get_built_tool_path( - TOOL_cpp_styleguide_bin - TOOL_cpp_styleguide_dependency - contrib/tools/protoc/plugins/cpp_styleguide - cpp_styleguide -) add_library(library-folder_service-proto) target_link_libraries(library-folder_service-proto PUBLIC @@ -40,7 +28,6 @@ target_link_libraries(library-folder_service-proto PUBLIC ) target_proto_messages(library-folder_service-proto PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/config.proto - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/folder_service.proto ) target_proto_addincls(library-folder_service-proto ./ diff --git a/ydb/library/folder_service/proto/CMakeLists.linux-x86_64.txt b/ydb/library/folder_service/proto/CMakeLists.linux-x86_64.txt index 9b7472b986a..9698675f991 100644 --- a/ydb/library/folder_service/proto/CMakeLists.linux-x86_64.txt +++ b/ydb/library/folder_service/proto/CMakeLists.linux-x86_64.txt @@ -18,18 +18,6 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) -get_built_tool_path( - TOOL_protoc_bin - TOOL_protoc_dependency - contrib/tools/protoc/bin - protoc -) -get_built_tool_path( - TOOL_cpp_styleguide_bin - TOOL_cpp_styleguide_dependency - contrib/tools/protoc/plugins/cpp_styleguide - cpp_styleguide -) add_library(library-folder_service-proto) target_link_libraries(library-folder_service-proto PUBLIC @@ -40,7 +28,6 @@ target_link_libraries(library-folder_service-proto PUBLIC ) target_proto_messages(library-folder_service-proto PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/config.proto - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/folder_service.proto ) target_proto_addincls(library-folder_service-proto ./ diff --git a/ydb/library/folder_service/proto/CMakeLists.windows-x86_64.txt b/ydb/library/folder_service/proto/CMakeLists.windows-x86_64.txt index bd40178fc1e..9d9c4e98f2b 100644 --- a/ydb/library/folder_service/proto/CMakeLists.windows-x86_64.txt +++ b/ydb/library/folder_service/proto/CMakeLists.windows-x86_64.txt @@ -18,18 +18,6 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) -get_built_tool_path( - TOOL_protoc_bin - TOOL_protoc_dependency - contrib/tools/protoc/bin - protoc -) -get_built_tool_path( - TOOL_cpp_styleguide_bin - TOOL_cpp_styleguide_dependency - contrib/tools/protoc/plugins/cpp_styleguide - cpp_styleguide -) add_library(library-folder_service-proto) target_link_libraries(library-folder_service-proto PUBLIC @@ -39,7 +27,6 @@ target_link_libraries(library-folder_service-proto PUBLIC ) target_proto_messages(library-folder_service-proto PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/config.proto - ${CMAKE_SOURCE_DIR}/ydb/library/folder_service/proto/folder_service.proto ) target_proto_addincls(library-folder_service-proto ./ diff --git a/ydb/library/folder_service/proto/config.proto b/ydb/library/folder_service/proto/config.proto index 06981810a39..4c5e709a800 100644 --- a/ydb/library/folder_service/proto/config.proto +++ b/ydb/library/folder_service/proto/config.proto @@ -4,6 +4,9 @@ package NKikimrProto.NFolderService; message TFolderServiceConfig { bool Enable = 1; - string Endpoint = 2; + oneof EndpointType { + string Endpoint = 2; + string ResourceManagerEndpoint = 4; + } string PathToRootCA = 3; } diff --git a/ydb/library/folder_service/proto/folder_service.proto b/ydb/library/folder_service/proto/folder_service.proto deleted file mode 100644 index bd62d751546..00000000000 --- a/ydb/library/folder_service/proto/folder_service.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; - -import "google/protobuf/timestamp.proto"; - -package NKikimrProto.NFolderService; - -message Folder { - - enum Status { - STATUS_UNSPECIFIED = 0; - ACTIVE = 1; - DELETING = 2; - DELETED = 3; - PENDING_DELETION = 4; - } - - string id = 1; - string cloud_id = 2; - - google.protobuf.Timestamp created_at = 3; - string name = 4; - string description = 5; - map<string, string> labels = 6; - - Status status = 7; -} - -message GetFolderRequest { - string folder_id = 1; -} - -message GetFolderResponse { - Folder folder = 1; -} diff --git a/ydb/library/testlib/service_mocks/folder_service_mock.h b/ydb/library/testlib/service_mocks/folder_service_mock.h index 90ba4c6fde1..0b60e79a2e9 100644 --- a/ydb/library/testlib/service_mocks/folder_service_mock.h +++ b/ydb/library/testlib/service_mocks/folder_service_mock.h @@ -2,18 +2,18 @@ #include <ydb/public/api/client/yc_private/resourcemanager/folder_service.grpc.pb.h> -class TFolderServiceMock : public yandex::cloud::priv::resourcemanager::v1::transitional::FolderService::Service { +class TFolderServiceMock : public yandex::cloud::priv::resourcemanager::v1::FolderService::Service { public: - THashMap<TString, yandex::cloud::priv::resourcemanager::v1::Folder> Folders; + THashMap<TString, yandex::cloud::priv::resourcemanager::v1::ResolvedFolder> Folders; - virtual grpc::Status List( + virtual grpc::Status Resolve( grpc::ServerContext*, - const yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersRequest* request, - yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersResponse* response) override { - TString key = request->id(); + const yandex::cloud::priv::resourcemanager::v1::ResolveFoldersRequest* request, + yandex::cloud::priv::resourcemanager::v1::ResolveFoldersResponse* response) override { + TString key = request->folder_ids(0); auto it = Folders.find(key); if (it != Folders.end()) { - response->add_result()->CopyFrom(it->second); + response->add_resolved_folders()->CopyFrom(it->second); return grpc::Status::OK; } else { return grpc::Status(grpc::StatusCode::NOT_FOUND, "Not Found"); diff --git a/ydb/library/testlib/service_mocks/folder_service_transitional_mock.h b/ydb/library/testlib/service_mocks/folder_service_transitional_mock.h new file mode 100644 index 00000000000..a541387a43d --- /dev/null +++ b/ydb/library/testlib/service_mocks/folder_service_transitional_mock.h @@ -0,0 +1,21 @@ +#pragma once + +#include <ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.grpc.pb.h> + +class TFolderServiceTransitionalMock: public yandex::cloud::priv::resourcemanager::v1::transitional::FolderService::Service { +public: + THashMap<TString, yandex::cloud::priv::resourcemanager::v1::Folder> Folders; + + virtual grpc::Status List(grpc::ServerContext*, + const yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersRequest* request, + yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersResponse* response) override { + TString key = request->id(); + auto it = Folders.find(key); + if (it != Folders.end()) { + response->add_result()->CopyFrom(it->second); + return grpc::Status::OK; + } else { + return grpc::Status(grpc::StatusCode::NOT_FOUND, "Not Found"); + } + } +}; diff --git a/ydb/library/ycloud/api/folder_service.h b/ydb/library/ycloud/api/folder_service.h index a1922103c5e..700cb39a8c8 100644 --- a/ydb/library/ycloud/api/folder_service.h +++ b/ydb/library/ycloud/api/folder_service.h @@ -10,20 +10,17 @@ namespace NCloud { struct TEvFolderService { enum EEv { // requests - EvListFolderRequest = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE), + EvResolveFoldersRequest = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE) + 1024, // replies - EvListFolderResponse = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE) + 512, + EvResolveFoldersResponse = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE) + 1024 + 512, EvEnd }; static_assert(EvEnd < EventSpaceEnd(TKikimrEvents::ES_FOLDER_SERVICE), "expect EvEnd < EventSpaceEnd(TKikimrEvents::ES_FOLDER_SERVICE)"); - // https://a.yandex-team.ru/arc/trunk/arcadia/cloud/identity/proto/resourcemanager/v1/folder.proto - // https://a.yandex-team.ru/arc/trunk/arcadia/cloud/identity/proto/resourcemanager/v1/transitional/folder_service.proto - - struct TEvListFolderRequest : TEvGrpcProtoRequest<TEvListFolderRequest, EvListFolderRequest, yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersRequest> {}; - struct TEvListFolderResponse : TEvGrpcProtoResponse<TEvListFolderResponse, EvListFolderResponse, yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersResponse> {}; + struct TEvResolveFoldersRequest : TEvGrpcProtoRequest<TEvResolveFoldersRequest, EvResolveFoldersRequest, yandex::cloud::priv::resourcemanager::v1::ResolveFoldersRequest> {}; + struct TEvResolveFoldersResponse : TEvGrpcProtoResponse<TEvResolveFoldersResponse, EvResolveFoldersResponse, yandex::cloud::priv::resourcemanager::v1::ResolveFoldersResponse> {}; }; } diff --git a/ydb/library/ycloud/api/folder_service_transitional.h b/ydb/library/ycloud/api/folder_service_transitional.h new file mode 100644 index 00000000000..95eae91893e --- /dev/null +++ b/ydb/library/ycloud/api/folder_service_transitional.h @@ -0,0 +1,26 @@ +#pragma once +#include <ydb/core/base/defs.h> +#include <ydb/core/base/events.h> +#include <ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.grpc.pb.h> +#include "events.h" + +namespace NCloud { + using namespace NKikimr; + + struct TEvFolderServiceTransitional { + enum EEv { + // requests + EvListFolderRequest = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE), + + // replies + EvListFolderResponse = EventSpaceBegin(TKikimrEvents::ES_FOLDER_SERVICE) + 512, + + EvEnd + }; + + static_assert(EvEnd < EventSpaceEnd(TKikimrEvents::ES_FOLDER_SERVICE), "expect EvEnd < EventSpaceEnd(TKikimrEvents::ES_FOLDER_SERVICE)"); + + struct TEvListFolderRequest : TEvGrpcProtoRequest<TEvListFolderRequest, EvListFolderRequest, yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersRequest> {}; + struct TEvListFolderResponse : TEvGrpcProtoResponse<TEvListFolderResponse, EvListFolderResponse, yandex::cloud::priv::resourcemanager::v1::transitional::ListFoldersResponse> {}; + }; +} diff --git a/ydb/library/ycloud/impl/CMakeLists.darwin-x86_64.txt b/ydb/library/ycloud/impl/CMakeLists.darwin-x86_64.txt index ca5612d8029..6be40961047 100644 --- a/ydb/library/ycloud/impl/CMakeLists.darwin-x86_64.txt +++ b/ydb/library/ycloud/impl/CMakeLists.darwin-x86_64.txt @@ -24,6 +24,7 @@ target_link_libraries(library-ycloud-impl PUBLIC target_sources(library-ycloud-impl PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/access_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_transitional.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_adapter.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/iam_token_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/mock_access_service.cpp diff --git a/ydb/library/ycloud/impl/CMakeLists.linux-aarch64.txt b/ydb/library/ycloud/impl/CMakeLists.linux-aarch64.txt index 51d18cfe544..5777387f5d1 100644 --- a/ydb/library/ycloud/impl/CMakeLists.linux-aarch64.txt +++ b/ydb/library/ycloud/impl/CMakeLists.linux-aarch64.txt @@ -25,6 +25,7 @@ target_link_libraries(library-ycloud-impl PUBLIC target_sources(library-ycloud-impl PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/access_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_transitional.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_adapter.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/iam_token_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/mock_access_service.cpp diff --git a/ydb/library/ycloud/impl/CMakeLists.linux-x86_64.txt b/ydb/library/ycloud/impl/CMakeLists.linux-x86_64.txt index 51d18cfe544..5777387f5d1 100644 --- a/ydb/library/ycloud/impl/CMakeLists.linux-x86_64.txt +++ b/ydb/library/ycloud/impl/CMakeLists.linux-x86_64.txt @@ -25,6 +25,7 @@ target_link_libraries(library-ycloud-impl PUBLIC target_sources(library-ycloud-impl PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/access_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_transitional.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_adapter.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/iam_token_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/mock_access_service.cpp diff --git a/ydb/library/ycloud/impl/CMakeLists.windows-x86_64.txt b/ydb/library/ycloud/impl/CMakeLists.windows-x86_64.txt index ca5612d8029..6be40961047 100644 --- a/ydb/library/ycloud/impl/CMakeLists.windows-x86_64.txt +++ b/ydb/library/ycloud/impl/CMakeLists.windows-x86_64.txt @@ -24,6 +24,7 @@ target_link_libraries(library-ycloud-impl PUBLIC target_sources(library-ycloud-impl PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/access_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service.cpp + ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_transitional.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/folder_service_adapter.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/iam_token_service.cpp ${CMAKE_SOURCE_DIR}/ydb/library/ycloud/impl/mock_access_service.cpp diff --git a/ydb/library/ycloud/impl/folder_service.cpp b/ydb/library/ycloud/impl/folder_service.cpp index 342e1757360..9a261a884ac 100644 --- a/ydb/library/ycloud/impl/folder_service.cpp +++ b/ydb/library/ycloud/impl/folder_service.cpp @@ -9,18 +9,18 @@ namespace NCloud { using namespace NKikimr; -class TFolderService : public NActors::TActor<TFolderService>, TGrpcServiceClient<yandex::cloud::priv::resourcemanager::v1::transitional::FolderService> { +class TFolderService : public NActors::TActor<TFolderService>, TGrpcServiceClient<yandex::cloud::priv::resourcemanager::v1::FolderService> { using TThis = TFolderService; using TBase = NActors::TActor<TFolderService>; - struct TListFolderRequest : TGrpcRequest { - static constexpr auto Request = &yandex::cloud::priv::resourcemanager::v1::transitional::FolderService::Stub::AsyncList; - using TRequestEventType = TEvFolderService::TEvListFolderRequest; - using TResponseEventType = TEvFolderService::TEvListFolderResponse; + struct TResolveFoldersGrpcRequest : TGrpcRequest { + static constexpr auto Request = &yandex::cloud::priv::resourcemanager::v1::FolderService::Stub::AsyncResolve; + using TRequestEventType = TEvFolderService::TEvResolveFoldersRequest; + using TResponseEventType = TEvFolderService::TEvResolveFoldersResponse; }; - void Handle(TEvFolderService::TEvListFolderRequest::TPtr& ev) { - MakeCall<TListFolderRequest>(std::move(ev)); + void Handle(TEvFolderService::TEvResolveFoldersRequest::TPtr& ev) { + MakeCall<TResolveFoldersGrpcRequest>(std::move(ev)); } public: @@ -33,7 +33,7 @@ public: void StateWork(TAutoPtr<NActors::IEventHandle>& ev) { switch (ev->GetTypeRewrite()) { - hFunc(TEvFolderService::TEvListFolderRequest, Handle); + hFunc(TEvFolderService::TEvResolveFoldersRequest, Handle); cFunc(TEvents::TSystem::PoisonPill, PassAway); } } @@ -46,8 +46,8 @@ IActor* CreateFolderService(const TFolderServiceSettings& settings) { IActor* CreateFolderServiceWithCache(const TFolderServiceSettings& settings) { IActor* folderService = CreateFolderService(settings); - folderService = CreateGrpcServiceCache<TEvFolderService::TEvListFolderRequest, TEvFolderService::TEvListFolderResponse>(folderService); + folderService = CreateGrpcServiceCache<TEvFolderService::TEvResolveFoldersRequest, TEvFolderService::TEvResolveFoldersResponse>(folderService); return folderService; } -} +} // namespace NCloud diff --git a/ydb/library/ycloud/impl/folder_service_adapter.cpp b/ydb/library/ycloud/impl/folder_service_adapter.cpp index f2a9082d93a..56189b98815 100644 --- a/ydb/library/ycloud/impl/folder_service_adapter.cpp +++ b/ydb/library/ycloud/impl/folder_service_adapter.cpp @@ -1,8 +1,12 @@ #include <ydb/library/folder_service/folder_service.h> #include <ydb/library/folder_service/events.h> -#include <ydb/library/folder_service/mock/mock_folder_service.h> +#include <ydb/library/folder_service/mock/mock_folder_service_adapter.h> #include <ydb/library/ycloud/impl/folder_service.h> +#include <ydb/library/ycloud/impl/folder_service_transitional.h> + +#include <ydb/library/ycloud/api/folder_service.h> +#include <ydb/library/ycloud/api/folder_service_transitional.h> #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/actors/core/hfunc.h> @@ -11,32 +15,55 @@ namespace { -class TFolderServiceRequestHandler : public NActors::TActor<TFolderServiceRequestHandler> { +enum EFolderServiceEndpointType { + AccessService, + ResourceManager +}; + +class TFolderServiceRequestHandler: public NActors::TActor<TFolderServiceRequestHandler> { using TThis = TFolderServiceRequestHandler; using TBase = NActors::TActor<TFolderServiceRequestHandler>; + EFolderServiceEndpointType FolderServiceEndpointType = EFolderServiceEndpointType::AccessService; + NActors::TActorId Sender; NActors::TActorId Delegatee; - void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest::TPtr& ev) { - auto request = std::make_unique<NCloud::TEvFolderService::TEvListFolderRequest>(); - request->Request.set_id(ev->Get()->Request.folder_id()); - request->Token = ev->Get()->Token; - request->RequestId = ev->Get()->RequestId; + void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest::TPtr& ev) { + std::unique_ptr<NActors::IEventBase> request; + switch (FolderServiceEndpointType) { + case EFolderServiceEndpointType::ResourceManager: + request = CreateResolveFolderRequest(ev); + break; + case EFolderServiceEndpointType::AccessService: + request = CreateListFolderRequest(ev); + break; + } Send(Delegatee, request.release()); } - void Handle(NCloud::TEvFolderService::TEvListFolderResponse::TPtr& ev) { - auto responseEvent = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetFolderResponse>(); - + void Handle(NCloud::TEvFolderServiceTransitional::TEvListFolderResponse::TPtr& ev) { + auto responseEvent = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse>(); const auto& status = ev->Get()->Status; + responseEvent->Status = status; + if (status.Ok() && ev->Get()->Response.result_size() > 0) { + responseEvent->CloudId = ev->Get()->Response.result(0).cloud_id(); + responseEvent->FolderId = ev->Get()->Response.result(0).id(); + } + Send(Sender, responseEvent.release()); + PassAway(); + } + + void Handle(NCloud::TEvFolderService::TEvResolveFoldersResponse::TPtr& ev) { + auto responseEvent = std::make_unique<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse>(); + const auto& status = ev->Get()->Status; + + responseEvent->Status = status; if (status.Ok()) { - const auto& response = ev->Get()->Response; - if (response.result_size() > 0) { - Y_VERIFY(responseEvent->Response.mutable_folder()->ParseFromString(response.result(0).SerializeAsString())); - } + responseEvent->CloudId = ev->Get()->Response.resolved_folders(0).cloud_id(); + responseEvent->FolderId = ev->Get()->Response.resolved_folders(0).id(); } Send(Sender, responseEvent.release()); @@ -47,60 +74,101 @@ class TFolderServiceRequestHandler : public NActors::TActor<TFolderServiceReques Y_FAIL("Can't deliver local message"); } + std::unique_ptr<NActors::IEventBase> CreateListFolderRequest(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest::TPtr& ev) { + auto request = std::make_unique<NCloud::TEvFolderServiceTransitional::TEvListFolderRequest>(); + request->Request.set_id(ev->Get()->FolderId); + request->Token = ev->Get()->Token; + request->RequestId = ev->Get()->RequestId; + return request; + } + + std::unique_ptr<NActors::IEventBase> CreateResolveFolderRequest(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest::TPtr& ev) { + auto request = std::make_unique<NCloud::TEvFolderService::TEvResolveFoldersRequest>(); + request->Request.add_folder_ids(ev->Get()->FolderId); + request->Token = ev->Get()->Token; + request->RequestId = ev->Get()->RequestId; + return request; + } + void StateWork(TAutoPtr<NActors::IEventHandle>& ev) { switch (ev->GetTypeRewrite()) { - hFunc(NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest, Handle); - hFunc(NCloud::TEvFolderService::TEvListFolderResponse, Handle); + hFunc(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest, Handle); + hFunc(NCloud::TEvFolderService::TEvResolveFoldersResponse, Handle); + hFunc(NCloud::TEvFolderServiceTransitional::TEvListFolderResponse, Handle); hFunc(NActors::TEvents::TEvUndelivered, Handle); cFunc(NActors::TEvents::TSystem::PoisonPill, PassAway); } } public: - TFolderServiceRequestHandler(NActors::TActorId sender, NActors::TActorId delegatee) + TFolderServiceRequestHandler(EFolderServiceEndpointType folderServiceEndpoint, NActors::TActorId sender, NActors::TActorId delegatee) : TBase(&TThis::StateWork) + , FolderServiceEndpointType(folderServiceEndpoint) , Sender(sender) - , Delegatee(delegatee) { + , Delegatee(delegatee) + { } }; -}; // namespace +}; namespace NKikimr::NFolderService { -class TFolderServiceAdapter : public NActors::TActorBootstrapped<TFolderServiceAdapter> { +class TFolderServiceAdapter: public NActors::TActorBootstrapped<TFolderServiceAdapter> { using TThis = TFolderServiceAdapter; using TBase = NActors::TActor<TFolderServiceAdapter>; NKikimrProto::NFolderService::TFolderServiceConfig Config; NActors::TActorId Delegatee; + EFolderServiceEndpointType FolderServiceEndpointType = EFolderServiceEndpointType::AccessService; - void Handle(::NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest::TPtr& ev) { - auto actor = Register(new TFolderServiceRequestHandler(ev->Sender, Delegatee)); + void Handle(NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest::TPtr& ev) { + auto actor = Register(new TFolderServiceRequestHandler(FolderServiceEndpointType, ev->Sender, Delegatee)); Send(actor, ev->Release().Release()); } void StateWork(TAutoPtr<NActors::IEventHandle>& ev) { switch (ev->GetTypeRewrite()) { - hFunc(::NKikimr::NFolderService::TEvFolderService::TEvGetFolderRequest, Handle) - cFunc(NActors::TEvents::TSystem::PoisonPill, PassAway) + hFunc(::NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest, Handle); + cFunc(NActors::TEvents::TSystem::PoisonPill, PassAway); } } + void RegisterFolderService() { + NCloud::TFolderServiceSettings settings; + if (!Config.GetPathToRootCA().empty()) + settings.CertificateRootCA = TUnbufferedFileInput(Config.GetPathToRootCA()).ReadAll(); + settings.Endpoint = Config.GetResourceManagerEndpoint(); + Delegatee = Register(NCloud::CreateFolderServiceWithCache(settings)); + FolderServiceEndpointType = EFolderServiceEndpointType::ResourceManager; + } + + void RegisterTransitionalFolderService() { + NCloud::TFolderServiceTransitionalSettings settings; + if (!Config.GetPathToRootCA().empty()) + settings.CertificateRootCA = TUnbufferedFileInput(Config.GetPathToRootCA()).ReadAll(); + settings.Endpoint = Config.GetEndpoint(); + Delegatee = Register(NCloud::CreateFolderServiceTransitionalWithCache(settings)); + FolderServiceEndpointType = EFolderServiceEndpointType::AccessService; + } + public: static constexpr NKikimrServices::TActivity::EType ActorActivityType() { return NKikimrServices::TActivity::FOLDER_SERVICE_ACTOR; } void Bootstrap() { - NCloud::TFolderServiceSettings settings; - settings.Endpoint = Config.GetEndpoint(); - settings.CertificateRootCA = TUnbufferedFileInput(Config.GetPathToRootCA()).ReadAll(); - Delegatee = Register(NCloud::CreateFolderServiceWithCache(settings)); + if (Config.HasResourceManagerEndpoint() && !Config.GetResourceManagerEndpoint().empty()) { + RegisterFolderService(); + } + else { + RegisterTransitionalFolderService(); + } Become(&TThis::StateWork); } explicit TFolderServiceAdapter(const NKikimrProto::NFolderService::TFolderServiceConfig& config) - : Config(config) { + : Config(config) + { } }; @@ -108,7 +176,7 @@ NActors::IActor* CreateFolderServiceActor(const NKikimrProto::NFolderService::TF if (config.GetEnable()) { return new NKikimr::NFolderService::TFolderServiceAdapter(config); } else { - return NKikimr::NFolderService::CreateMockFolderServiceActor(config); + return NKikimr::NFolderService::CreateMockFolderServiceAdapterActor(config); } } } // namespace NKikimr::NFolderService diff --git a/ydb/library/ycloud/impl/folder_service_transitional.cpp b/ydb/library/ycloud/impl/folder_service_transitional.cpp new file mode 100644 index 00000000000..0808b5b99d7 --- /dev/null +++ b/ydb/library/ycloud/impl/folder_service_transitional.cpp @@ -0,0 +1,53 @@ +#include <library/cpp/actors/core/actorsystem.h> +#include <library/cpp/actors/core/actor.h> +#include <ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.grpc.pb.h> +#include "folder_service_transitional.h" +#include "grpc_service_client.h" +#include "grpc_service_cache.h" + +namespace NCloud { + +using namespace NKikimr; + +class TFolderServiceTransitional : public NActors::TActor<TFolderServiceTransitional>, TGrpcServiceClient<yandex::cloud::priv::resourcemanager::v1::transitional::FolderService> { + using TThis = TFolderServiceTransitional; + using TBase = NActors::TActor<TFolderServiceTransitional>; + + struct TListFolderRequest : TGrpcRequest { + static constexpr auto Request = &yandex::cloud::priv::resourcemanager::v1::transitional::FolderService::Stub::AsyncList; + using TRequestEventType = TEvFolderServiceTransitional::TEvListFolderRequest; + using TResponseEventType = TEvFolderServiceTransitional::TEvListFolderResponse; + }; + + void Handle(TEvFolderServiceTransitional::TEvListFolderRequest::TPtr& ev) { + MakeCall<TListFolderRequest>(std::move(ev)); + } + +public: + static constexpr NKikimrServices::TActivity::EType ActorActivityType() { return NKikimrServices::TActivity::FOLDER_SERVICE_ACTOR; } + + TFolderServiceTransitional(const TFolderServiceTransitionalSettings& settings) + : TBase(&TThis::StateWork) + , TGrpcServiceClient(settings) + {} + + void StateWork(TAutoPtr<NActors::IEventHandle>& ev) { + switch (ev->GetTypeRewrite()) { + hFunc(TEvFolderServiceTransitional::TEvListFolderRequest, Handle); + cFunc(TEvents::TSystem::PoisonPill, PassAway); + } + } +}; + + +IActor* CreateFolderServiceTransitional(const TFolderServiceTransitionalSettings& settings) { + return new TFolderServiceTransitional(settings); +} + +IActor* CreateFolderServiceTransitionalWithCache(const TFolderServiceTransitionalSettings& settings) { + IActor* folderServiceTransitional = CreateFolderServiceTransitional(settings); + folderServiceTransitional = CreateGrpcServiceCache<TEvFolderServiceTransitional::TEvListFolderRequest, TEvFolderServiceTransitional::TEvListFolderResponse>(folderServiceTransitional); + return folderServiceTransitional; +} + +} // namespace NCloud diff --git a/ydb/library/ycloud/impl/folder_service_transitional.h b/ydb/library/ycloud/impl/folder_service_transitional.h new file mode 100644 index 00000000000..36cc578addc --- /dev/null +++ b/ydb/library/ycloud/impl/folder_service_transitional.h @@ -0,0 +1,21 @@ +#pragma once +#include <ydb/library/ycloud/api/folder_service_transitional.h> +#include "grpc_service_settings.h" + +namespace NCloud { + +using namespace NKikimr; + +struct TFolderServiceTransitionalSettings : TGrpcClientSettings {}; + +IActor* CreateFolderServiceTransitional(const TFolderServiceTransitionalSettings& settings); + +inline IActor* CreateFolderServiceTransitional(const TString& endpoint) { + TFolderServiceTransitionalSettings settings; + settings.Endpoint = endpoint; + return CreateFolderServiceTransitional(settings); +} + +IActor* CreateFolderServiceTransitionalWithCache(const TFolderServiceTransitionalSettings& settings); // for compatibility with older code + +} diff --git a/ydb/library/ycloud/impl/folder_service_ut.cpp b/ydb/library/ycloud/impl/folder_service_ut.cpp index 23f1e30c794..5a630dea64d 100644 --- a/ydb/library/ycloud/impl/folder_service_ut.cpp +++ b/ydb/library/ycloud/impl/folder_service_ut.cpp @@ -1,81 +1,242 @@ #include <library/cpp/actors/core/event.h> #include <library/cpp/actors/core/event_local.h> -#include <ydb/core/testlib/test_client.h> -#include <ydb/library/testlib/service_mocks/folder_service_mock.h> #include <library/cpp/grpc/server/grpc_server.h> -#include <ydb/public/lib/deprecated/kicli/kicli.h> #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/testing/unittest/tests_data.h> #include <library/cpp/retry/retry.h> +#include <ydb/core/testlib/test_client.h> +#include <ydb/library/testlib/service_mocks/folder_service_transitional_mock.h> +#include <ydb/library/testlib/service_mocks/folder_service_mock.h> +#include "ydb/library/folder_service/folder_service.h" +#include <ydb/library/folder_service/events.h> +#include <ydb/public/lib/deprecated/kicli/kicli.h> #include <util/string/builder.h> +#include "folder_service_transitional.h" #include "folder_service.h" -Y_UNIT_TEST_SUITE(TFolderServiceTest) { - Y_UNIT_TEST(ListFolder) { - using namespace NKikimr; - using namespace Tests; - TPortManager tp; - // Kikimr - ui16 kikimrPort = tp.GetPort(2134); +using namespace NKikimr; +using namespace Tests; + +struct TFolderServiceTestSetup { + TPortManager PortManager; + ui16 KikimrPort; + + THolder<TServer> Server; + THolder<TClient> Client; + THolder<NClient::TKikimr> Kikimr; + TActorId EdgeActor; + IActor* AccessServiceActor = nullptr; + + TFolderServiceTestSetup() + : KikimrPort(PortManager.GetPort(2134)) + { + StartKikimr(); + } + + TTestActorRuntime* GetRuntime() { + return Server->GetRuntime(); + } + + void StartKikimr() { NKikimrProto::TAuthConfig authConfig; - auto settings = TServerSettings(kikimrPort, authConfig); + auto settings = TServerSettings(KikimrPort, authConfig); settings.SetDomainName("Root"); - TServer server(settings); - TClient client(settings); - NClient::TKikimr kikimr(client.GetClientConfig()); - client.InitRootScheme(); + Server = MakeHolder<TServer>(settings); + Server->GetRuntime()->SetLogPriority(NKikimrServices::GRPC_CLIENT, NLog::PRI_DEBUG); + Client = MakeHolder<TClient>(settings); + Kikimr = MakeHolder<NClient::TKikimr>(Client->GetClientConfig()); + Client->InitRootScheme(); + EdgeActor = GetRuntime()->AllocateEdgeActor(); + } - TTestActorRuntime* runtime = server.GetRuntime(); - TActorId sender = runtime->AllocateEdgeActor(); - TAutoPtr<IEventHandle> handle; - TString badFolderId = "yrm4564"; - TString goodFolderId = "yrm4566"; - TString cloudId = "cloud9999"; - - // Folder Service - ui16 servicePort = tp.GetPort(4284); - IActor* folderService = NCloud::CreateFolderService("localhost:" + ToString(servicePort)); - runtime->Register(folderService); - auto request = MakeHolder<NCloud::TEvFolderService::TEvListFolderRequest>(); - request->Request.set_id("xxx"); - runtime->Send(new IEventHandle(folderService->SelfId(), sender, request.Release())); - auto result = runtime->GrabEdgeEvent<NCloud::TEvFolderService::TEvListFolderResponse>(handle); - UNIT_ASSERT(result); // error because no service is listening - // grpc core code prints full information about error code, - // but let's check only the fact that we received error. - UNIT_ASSERT_STRING_CONTAINS(result->Status.Msg, "failed to connect to all addresses; last error:"); - - // Folder Service Mock - TFolderServiceMock folderServiceMock; + std::unique_ptr<grpc::Server> StartGrpcService(const ui16 port, grpc::Service* service) { grpc::ServerBuilder builder; - folderServiceMock.Folders[goodFolderId].set_cloud_id(cloudId); - builder.AddListeningPort("[::]:" + ToString(servicePort), grpc::InsecureServerCredentials()).RegisterService(&folderServiceMock); - std::unique_ptr<grpc::Server> folderServer(builder.BuildAndStart()); + builder.AddListeningPort("[::]:" + ToString(port), grpc::InsecureServerCredentials()).RegisterService(service); + std::unique_ptr<grpc::Server> grpcServer(builder.BuildAndStart()); + return grpcServer; + } + + IActor* RegisterFolderServiceAdapter(NKikimrProto::NFolderService::TFolderServiceConfig& config) { + IActor* folderServiceAdapter = NKikimr::NFolderService::CreateFolderServiceActor(config); + GetRuntime()->Register(folderServiceAdapter); + return folderServiceAdapter; + } - // check for not found - // retry if there is TRANSIENT_FAILURE + IActor* RegisterFolderTransitionalServiceActor(const ui16 port) { + IActor* folderServiceTransitional = NCloud::CreateFolderServiceTransitional("localhost:" + ToString(port)); + GetRuntime()->Register(folderServiceTransitional); + return folderServiceTransitional; + } + + IActor* RegisterFolderServiceActor(const ui16 port) { + IActor* folderService = NCloud::CreateFolderService("localhost:" + ToString(port)); + GetRuntime()->Register(folderService); + return folderService; + } + + void SendListFolderRequest(IActor* to, TString folderId) { + auto request = MakeHolder<NCloud::TEvFolderServiceTransitional::TEvListFolderRequest>(); + request->Request.set_id(folderId); + GetRuntime()->Send(new IEventHandle(to->SelfId(), EdgeActor, request.Release())); + } + + void SendResolveFoldersRequest(IActor* to, TString folderId) { + auto request = MakeHolder<NCloud::TEvFolderService::TEvResolveFoldersRequest>(); + request->Request.add_folder_ids(folderId); + GetRuntime()->Send(new IEventHandle(to->SelfId(), EdgeActor, request.Release())); + } + + void SendGetCloudByFolderRequest(IActor* to, TString folderId) { + auto request = MakeHolder<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderRequest>(); + request->FolderId = folderId; + GetRuntime()->Send(new IEventHandle(to->SelfId(), EdgeActor, request.Release())); + } +}; + +Y_UNIT_TEST_SUITE(FolderServiceTest) { + Y_UNIT_TEST(TFolderServiceTransitional) { + TFolderServiceTestSetup setup; + TAutoPtr<IEventHandle> handle; + + TString existsFolderId = "i_am_exists"; + TString notExistsFolderId = "i_am_not_exists"; + TString cloudId = "response_cloud_id"; + + ui16 servicePort = setup.PortManager.GetPort(4284); + auto folderServiceTransitional = setup.RegisterFolderTransitionalServiceActor(servicePort); + + // check failure because there is no listening gRPC service + setup.SendListFolderRequest(folderServiceTransitional, notExistsFolderId); + auto result = setup.GetRuntime() -> GrabEdgeEvent<NCloud::TEvFolderServiceTransitional::TEvListFolderResponse>(handle); + UNIT_ASSERT(result); + UNIT_ASSERT_STRING_CONTAINS(result->Status.Msg, "failed to connect to all addresses"); + + TFolderServiceTransitionalMock folderServiceTransitionalMock; + folderServiceTransitionalMock.Folders[existsFolderId].set_cloud_id(cloudId); + auto grpcServer = setup.StartGrpcService(servicePort, &folderServiceTransitionalMock); + + // check not found auto sendEvent = [&] { - auto request = MakeHolder<NCloud::TEvFolderService::TEvListFolderRequest>(); - request->Request.set_id(badFolderId); - runtime->Send(new IEventHandle(folderService->SelfId(), sender, request.Release())); - result = runtime->GrabEdgeEvent<NCloud::TEvFolderService::TEvListFolderResponse>(handle); + setup.SendListFolderRequest(folderServiceTransitional, notExistsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NCloud::TEvFolderServiceTransitional::TEvListFolderResponse>(handle); return result->Status.GRpcStatusCode != 14; }; DoWithRetryOnRetCode(sendEvent, TRetryOptions{}); - Cerr << result->Status.Msg << " " << result->Status.GRpcStatusCode << "\n"; - UNIT_ASSERT(result); UNIT_ASSERT(result->Status.Msg == "Not Found"); - // || "channel is in state TRANSIENT_FAILURE" - // check for found - request = MakeHolder<NCloud::TEvFolderService::TEvListFolderRequest>(); - request->Request.set_id(goodFolderId); - runtime->Send(new IEventHandle(folderService->SelfId(), sender, request.Release())); - result = runtime->GrabEdgeEvent<NCloud::TEvFolderService::TEvListFolderResponse>(handle); + // check found + setup.SendListFolderRequest(folderServiceTransitional, existsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NCloud::TEvFolderServiceTransitional::TEvListFolderResponse>(handle); UNIT_ASSERT(result); UNIT_ASSERT(result->Status.Ok()); UNIT_ASSERT_EQUAL(result->Response.result(0).cloud_id(), cloudId); } + + Y_UNIT_TEST(TFolderService) { + TFolderServiceTestSetup setup; + TAutoPtr<IEventHandle> handle; + + TString existsFolderId = "i_am_exists"; + TString notExistsFolderId = "i_am_not_exists"; + TString cloudId = "response_cloud_id"; + + ui16 servicePort = setup.PortManager.GetPort(4284); + auto folderService = setup.RegisterFolderServiceActor(servicePort); + + // check failure because there is no listening gRPC service + setup.SendResolveFoldersRequest(folderService, notExistsFolderId); + auto result = setup.GetRuntime() -> GrabEdgeEvent<NCloud::TEvFolderService::TEvResolveFoldersResponse>(handle); + UNIT_ASSERT(result); + UNIT_ASSERT_STRING_CONTAINS(result->Status.Msg, "failed to connect to all addresses"); + + TFolderServiceMock folderServiceMock; + folderServiceMock.Folders[existsFolderId].set_cloud_id(cloudId); + auto grpcServer = setup.StartGrpcService(servicePort, &folderServiceMock); + + // check not found + auto sendEvent = [&] { + setup.SendResolveFoldersRequest(folderService, notExistsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NCloud::TEvFolderService::TEvResolveFoldersResponse>(handle); + return result->Status.GRpcStatusCode != grpc::StatusCode::UNAVAILABLE; + }; + DoWithRetryOnRetCode(sendEvent, TRetryOptions{}); + UNIT_ASSERT(result); + UNIT_ASSERT(result->Status.GRpcStatusCode == grpc::StatusCode::NOT_FOUND); + + // check found + setup.SendResolveFoldersRequest(folderService, existsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NCloud::TEvFolderService::TEvResolveFoldersResponse>(handle); + UNIT_ASSERT(result); + UNIT_ASSERT(result->Status.Ok()); + UNIT_ASSERT_EQUAL(result->Response.resolved_folders(0).cloud_id(), cloudId); + } + + Y_UNIT_TEST(TFolderServiceAdapter) { + TFolderServiceTestSetup setup; + TAutoPtr<IEventHandle> handle; + + TString existsFolderId = "i_am_exists"; + TString notExistsFolderId = "i_am_not_exists"; + TString cloudFromTransitionalService = "cloud_from_old_service"; + TString cloudFromNewService = "cloud_from_new_service"; + + ui16 transitionalServicePort = setup.PortManager.GetPort(4284); + ui16 newServicePort = setup.PortManager.GetPort(4285); + + TFolderServiceTransitionalMock folderServiceTransitionalMock; + folderServiceTransitionalMock.Folders[existsFolderId].set_cloud_id(cloudFromTransitionalService); + auto grpcServerTransitional = setup.StartGrpcService(transitionalServicePort, &folderServiceTransitionalMock); + + TFolderServiceMock folderServiceMock; + folderServiceMock.Folders[existsFolderId].set_cloud_id(cloudFromNewService); + auto grpcServer = setup.StartGrpcService(newServicePort, &folderServiceMock); + + NKikimrProto::NFolderService::TFolderServiceConfig oldConfig; + oldConfig.SetEnable(true); + oldConfig.SetEndpoint("localhost:" + ToString(transitionalServicePort)); + + NKikimrProto::NFolderService::TFolderServiceConfig newConfig; + newConfig.SetEnable(true); + newConfig.SetEndpoint("localhost:" + ToString(transitionalServicePort)); + newConfig.SetResourceManagerEndpoint("localhost:" + ToString(newServicePort)); + + auto folderServiceAdapterWithOldConfig = setup.RegisterFolderServiceAdapter(oldConfig); + auto folderServiceAdapterWithNewConfig = setup.RegisterFolderServiceAdapter(newConfig); + + NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse* result; + // checking that with the old config, the request goes to the transitional service + auto sendToOld = [&] { + setup.SendGetCloudByFolderRequest(folderServiceAdapterWithOldConfig, existsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse>(handle); + return result->Status.GRpcStatusCode != grpc::StatusCode::UNAVAILABLE; + }; + DoWithRetryOnRetCode(sendToOld, TRetryOptions{}); + UNIT_ASSERT(result); + UNIT_ASSERT_EQUAL(result->CloudId, cloudFromTransitionalService); + + // checking that with the new config, the request goes to the new service + auto sendToNew = [&] { + setup.SendGetCloudByFolderRequest(folderServiceAdapterWithNewConfig, existsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse>(handle); + return result->Status.GRpcStatusCode != grpc::StatusCode::UNAVAILABLE; + }; + DoWithRetryOnRetCode(sendToNew, TRetryOptions{}); + UNIT_ASSERT(result); + UNIT_ASSERT_EQUAL(result->CloudId, cloudFromNewService); + + // check not found from the new service + setup.SendGetCloudByFolderRequest(folderServiceAdapterWithNewConfig, notExistsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse>(handle); + UNIT_ASSERT(result); + UNIT_ASSERT(result->Status.GRpcStatusCode == grpc::StatusCode::NOT_FOUND); + + // check not found from the transitional service + setup.SendGetCloudByFolderRequest(folderServiceAdapterWithOldConfig, notExistsFolderId); + result = setup.GetRuntime()->GrabEdgeEvent<NKikimr::NFolderService::TEvFolderService::TEvGetCloudByFolderResponse>(handle); + UNIT_ASSERT(result); + UNIT_ASSERT(result->Status.GRpcStatusCode == grpc::StatusCode::NOT_FOUND); + } + } diff --git a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.darwin-x86_64.txt b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.darwin-x86_64.txt index fb8d9ca06d6..672feee6250 100644 --- a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.darwin-x86_64.txt +++ b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.darwin-x86_64.txt @@ -36,6 +36,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(client-yc_private-resourcemanager) set_property(TARGET client-yc_private-resourcemanager PROPERTY @@ -51,8 +63,9 @@ target_link_libraries(client-yc_private-resourcemanager PUBLIC contrib-libs-protobuf ) target_proto_messages(client-yc_private-resourcemanager PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ) target_proto_addincls(client-yc_private-resourcemanager ./ diff --git a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-aarch64.txt b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-aarch64.txt index 0a0304062bf..91be0439819 100644 --- a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-aarch64.txt +++ b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-aarch64.txt @@ -36,6 +36,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(client-yc_private-resourcemanager) set_property(TARGET client-yc_private-resourcemanager PROPERTY @@ -52,8 +64,9 @@ target_link_libraries(client-yc_private-resourcemanager PUBLIC contrib-libs-protobuf ) target_proto_messages(client-yc_private-resourcemanager PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ) target_proto_addincls(client-yc_private-resourcemanager ./ diff --git a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-x86_64.txt b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-x86_64.txt index 0a0304062bf..91be0439819 100644 --- a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-x86_64.txt +++ b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.linux-x86_64.txt @@ -36,6 +36,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(client-yc_private-resourcemanager) set_property(TARGET client-yc_private-resourcemanager PROPERTY @@ -52,8 +64,9 @@ target_link_libraries(client-yc_private-resourcemanager PUBLIC contrib-libs-protobuf ) target_proto_messages(client-yc_private-resourcemanager PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ) target_proto_addincls(client-yc_private-resourcemanager ./ diff --git a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.windows-x86_64.txt b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.windows-x86_64.txt index fb8d9ca06d6..672feee6250 100644 --- a/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.windows-x86_64.txt +++ b/ydb/public/api/client/yc_private/resourcemanager/CMakeLists.windows-x86_64.txt @@ -36,6 +36,18 @@ get_built_tool_path( contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide ) +get_built_tool_path( + TOOL_protoc_bin + TOOL_protoc_dependency + contrib/tools/protoc/bin + protoc +) +get_built_tool_path( + TOOL_cpp_styleguide_bin + TOOL_cpp_styleguide_dependency + contrib/tools/protoc/plugins/cpp_styleguide + cpp_styleguide +) add_library(client-yc_private-resourcemanager) set_property(TARGET client-yc_private-resourcemanager PROPERTY @@ -51,8 +63,9 @@ target_link_libraries(client-yc_private-resourcemanager PUBLIC contrib-libs-protobuf ) target_proto_messages(client-yc_private-resourcemanager PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto + ${CMAKE_SOURCE_DIR}/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto ) target_proto_addincls(client-yc_private-resourcemanager ./ diff --git a/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto b/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto index eda82e1ea16..eb8ab1c6b4b 100644 --- a/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto +++ b/ydb/public/api/client/yc_private/resourcemanager/folder_service.proto @@ -1,61 +1,22 @@ syntax = "proto3"; -package yandex.cloud.priv.resourcemanager.v1.transitional; +package yandex.cloud.priv.resourcemanager.v1; -import "google/api/annotations.proto"; -import "ydb/public/api/client/yc_private/operation/operation.proto"; +import "google/protobuf/field_mask.proto"; import "ydb/public/api/client/yc_private/resourcemanager/folder.proto"; service FolderService { - // TODO no pagination - rpc List (ListFoldersRequest) returns (ListFoldersResponse) { - option (google.api.http) = { get: "/yrm/v1/folders" }; - } - rpc GetStatus (GetFolderStatusRequest) returns (GetFolderStatusResponse) { - option (google.api.http) = { get: "/yrm/v1/folder/{folder_id}/status" }; - } + rpc Resolve (ResolveFoldersRequest) returns (ResolveFoldersResponse); - rpc SetStatus (SetFolderStatusRequest) returns (SetFolderStatusResponse) { - option (google.api.http) = { post: "/yrm/v1/folder/{folder_id}/status" body: "*" }; - } - - rpc Delete (DeleteFolderRequest) returns (ydb.yc.priv.operation.Operation) { - option (google.api.http) = { delete: "/yrm/v1/folders/{folder_id}" }; - } -} - -message ListFoldersRequest { - string id = 1; // TODO repeated ids - string name = 2; - string cloud_id = 3; -} - -message ListFoldersResponse { - repeated yandex.cloud.priv.resourcemanager.v1.Folder result = 1; -} - -message GetFolderStatusRequest { - string folder_id = 1; -} - -message GetFolderStatusResponse { - string status = 1; -} - -message SetFolderStatusRequest { - string folder_id = 1; - string status = 2; -} - -message SetFolderStatusResponse { - string result = 1; } -message DeleteFolderRequest { - string folder_id = 1; +message ResolveFoldersRequest { + repeated string folder_ids = 1; + google.protobuf.FieldMask response_mask = 2; + bool resolve_existing_only = 3; } -message DeleteFolderMetadata { - string folder_id = 1; +message ResolveFoldersResponse { + repeated yandex.cloud.priv.resourcemanager.v1.ResolvedFolder resolved_folders = 1; } diff --git a/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto b/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto new file mode 100644 index 00000000000..eda82e1ea16 --- /dev/null +++ b/ydb/public/api/client/yc_private/resourcemanager/transitional/folder_service.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; + +package yandex.cloud.priv.resourcemanager.v1.transitional; + +import "google/api/annotations.proto"; +import "ydb/public/api/client/yc_private/operation/operation.proto"; +import "ydb/public/api/client/yc_private/resourcemanager/folder.proto"; + +service FolderService { + // TODO no pagination + rpc List (ListFoldersRequest) returns (ListFoldersResponse) { + option (google.api.http) = { get: "/yrm/v1/folders" }; + } + + rpc GetStatus (GetFolderStatusRequest) returns (GetFolderStatusResponse) { + option (google.api.http) = { get: "/yrm/v1/folder/{folder_id}/status" }; + } + + rpc SetStatus (SetFolderStatusRequest) returns (SetFolderStatusResponse) { + option (google.api.http) = { post: "/yrm/v1/folder/{folder_id}/status" body: "*" }; + } + + rpc Delete (DeleteFolderRequest) returns (ydb.yc.priv.operation.Operation) { + option (google.api.http) = { delete: "/yrm/v1/folders/{folder_id}" }; + } +} + +message ListFoldersRequest { + string id = 1; // TODO repeated ids + string name = 2; + string cloud_id = 3; +} + +message ListFoldersResponse { + repeated yandex.cloud.priv.resourcemanager.v1.Folder result = 1; +} + +message GetFolderStatusRequest { + string folder_id = 1; +} + +message GetFolderStatusResponse { + string status = 1; +} + +message SetFolderStatusRequest { + string folder_id = 1; + string status = 2; +} + +message SetFolderStatusResponse { + string result = 1; +} + +message DeleteFolderRequest { + string folder_id = 1; +} + +message DeleteFolderMetadata { + string folder_id = 1; +} |