aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <ilnaz@ydb.tech>2022-09-23 20:37:12 +0300
committerilnaz <ilnaz@ydb.tech>2022-09-23 20:37:12 +0300
commitd26d4b6e3328e60cbe341875f0d9508ff3590e5d (patch)
tree06b0cdc9643550cac44d32dfa2f94a273436714f
parent8d89d23cb935648b05b3528f8083f55b30e2c1be (diff)
downloadydb-d26d4b6e3328e60cbe341875f0d9508ff3590e5d.tar.gz
Update pool config
-rw-r--r--ydb/core/client/server/msgbus_server_console.cpp4
-rw-r--r--ydb/core/cms/console/CMakeLists.txt1
-rw-r--r--ydb/core/cms/console/console.h3
-rw-r--r--ydb/core/cms/console/console__update_tenant_pool_config.cpp98
-rw-r--r--ydb/core/cms/console/console_impl.h1
-rw-r--r--ydb/core/cms/console/console_tenants_manager.cpp5
-rw-r--r--ydb/core/cms/console/console_tenants_manager.h4
-rw-r--r--ydb/core/protos/console_tenant.proto10
-rw-r--r--ydb/core/protos/msgbus.proto1
9 files changed, 127 insertions, 0 deletions
diff --git a/ydb/core/client/server/msgbus_server_console.cpp b/ydb/core/client/server/msgbus_server_console.cpp
index 66bc0b02eb..a7c1effc2c 100644
--- a/ydb/core/client/server/msgbus_server_console.cpp
+++ b/ydb/core/client/server/msgbus_server_console.cpp
@@ -138,6 +138,10 @@ public:
auto request = MakeHolder<TEvConsole::TEvToggleConfigValidatorRequest>();
request->Record.CopyFrom(Request.GetToggleConfigValidatorRequest());
NTabletPipe::SendData(ctx, ConsolePipe, request.Release());
+ } else if (Request.HasUpdateTenantPoolConfig()) {
+ auto request = MakeHolder<TEvConsole::TEvUpdateTenantPoolConfig>();
+ request->Record.CopyFrom(Request.GetUpdateTenantPoolConfig());
+ NTabletPipe::SendData(ctx, ConsolePipe, request.Release());
} else {
ReplyWithErrorAndDie("Unknown console request", ctx);
}
diff --git a/ydb/core/cms/console/CMakeLists.txt b/ydb/core/cms/console/CMakeLists.txt
index cf2fb75d54..feec894070 100644
--- a/ydb/core/cms/console/CMakeLists.txt
+++ b/ydb/core/cms/console/CMakeLists.txt
@@ -66,6 +66,7 @@ target_sources(core-cms-console PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/cms/console/console__update_pool_state.cpp
${CMAKE_SOURCE_DIR}/ydb/core/cms/console/console__update_subdomain_key.cpp
${CMAKE_SOURCE_DIR}/ydb/core/cms/console/console__update_tenant_state.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/cms/console/console__update_tenant_pool_config.cpp
${CMAKE_SOURCE_DIR}/ydb/core/cms/console/http.cpp
${CMAKE_SOURCE_DIR}/ydb/core/cms/console/immediate_controls_configurator.cpp
${CMAKE_SOURCE_DIR}/ydb/core/cms/console/log_settings_configurator.cpp
diff --git a/ydb/core/cms/console/console.h b/ydb/core/cms/console/console.h
index 934d4e97e4..d0fa7724b5 100644
--- a/ydb/core/cms/console/console.h
+++ b/ydb/core/cms/console/console.h
@@ -40,6 +40,7 @@ struct TEvConsole {
EvConfigSubscriptionRequest,
EvConfigSubscriptionCanceled,
EvConfigSubscriptionNotification,
+ EvUpdateTenantPoolConfig,
// responses
EvCreateTenantResponse = EvCreateTenantRequest + 1024,
@@ -107,6 +108,8 @@ struct TEvConsole {
struct TEvDescribeTenantOptionsResponse : public TEventShortDebugPB<TEvDescribeTenantOptionsResponse, NKikimrConsole::TDescribeTenantOptionsResponse, EvDescribeTenantOptionsResponse> {};
+ struct TEvUpdateTenantPoolConfig : public TEventShortDebugPB<TEvUpdateTenantPoolConfig, NKikimrConsole::TUpdateTenantPoolConfig, EvUpdateTenantPoolConfig> {};
+
//////////////////////////////////////////////////
// CONFIGS MANAGEMENT
//////////////////////////////////////////////////
diff --git a/ydb/core/cms/console/console__update_tenant_pool_config.cpp b/ydb/core/cms/console/console__update_tenant_pool_config.cpp
new file mode 100644
index 0000000000..334e473a57
--- /dev/null
+++ b/ydb/core/cms/console/console__update_tenant_pool_config.cpp
@@ -0,0 +1,98 @@
+#include "console_tenants_manager.h"
+#include "console_impl.h"
+
+namespace NKikimr {
+namespace NConsole {
+
+class TTenantsManager::TTxUpdateTenantPoolConfig : public TTransactionBase<TTenantsManager> {
+public:
+ TTxUpdateTenantPoolConfig(TEvConsole::TEvUpdateTenantPoolConfig::TPtr ev, TTenantsManager *self)
+ : TBase(self)
+ , Request(std::move(ev))
+ {
+ }
+
+ bool Error(Ydb::StatusIds::StatusCode code, const TString &error, const TActorContext &ctx)
+ {
+ LOG_DEBUG_S(ctx, NKikimrServices::CMS_TENANTS, "Cannot update tenant pool config: " << error);
+
+ auto &operation = *Response->Record.MutableResponse()->mutable_operation();
+ operation.set_status(code);
+ auto issue = operation.add_issues();
+ issue->set_severity(NYql::TSeverityIds::S_ERROR);
+ issue->set_message(error);
+
+ return true;
+ }
+
+ bool Execute(TTransactionContext &txc, const TActorContext &executorCtx) override
+ {
+ auto ctx = executorCtx.MakeFor(Self->SelfId());
+ Ydb::StatusIds::StatusCode code;
+ TString error;
+
+ auto &rec = Request->Get()->Record;
+ auto &token = rec.GetUserToken();
+ LOG_DEBUG_S(ctx, NKikimrServices::CMS_TENANTS, "TTxUpdateTenantPoolConfig: "
+ << rec.ShortDebugString());
+
+ Response.Reset(new TEvConsole::TEvGetTenantStatusResponse);
+ auto &operation = *Response->Record.MutableResponse()->mutable_operation();
+ operation.set_ready(true);
+
+ if (!Self->CheckAccess(token, code, error, ctx))
+ return Error(code, error, ctx);
+
+ auto path = CanonizePath(rec.GetTenant());
+ auto tenant = Self->GetTenant(path);
+ if (!tenant)
+ return Error(Ydb::StatusIds::NOT_FOUND,
+ Sprintf("Database '%s' doesn't exist", path.data()), ctx);
+
+ if (!tenant->IsRunning() && !tenant->IsConfiguring())
+ return Error(Ydb::StatusIds::UNAVAILABLE,
+ Sprintf("Database '%s' is busy", path.data()), ctx);
+
+ auto kind = rec.GetPoolType();
+ auto pool = tenant->StoragePools.find(kind);
+ if (pool == tenant->StoragePools.end())
+ return Error(Ydb::StatusIds::NOT_FOUND,
+ Sprintf("Pool of kind '%s' doesn't exist", kind.data()), ctx);
+
+ auto &config = *rec.MutableConfig();
+ pool->second->AllocatedNumGroups = config.GetNumGroups();
+ pool->second->Config.Swap(&config);
+ Self->DbUpdatePoolConfig(tenant, pool->second, pool->second->Config, txc, ctx);
+
+ Ydb::Cms::GetDatabaseStatusResult result;
+ Self->FillTenantStatus(tenant, result);
+ operation.set_status(Ydb::StatusIds::SUCCESS);
+ operation.mutable_result()->PackFrom(result);
+
+ return true;
+ }
+
+ void Complete(const TActorContext &executorCtx) override
+ {
+ auto ctx = executorCtx.MakeFor(Self->SelfId());
+ LOG_DEBUG(ctx, NKikimrServices::CMS_TENANTS, "TTxUpdateTenantPoolConfig Complete");
+
+ Y_VERIFY(Response);
+ LOG_TRACE_S(ctx, NKikimrServices::CMS_TENANTS, "Send: " << Response->ToString());
+ ctx.Send(Request->Sender, Response.Release(), 0, Request->Cookie);
+
+ Self->TxProcessor->TxCompleted(this, ctx);
+ }
+
+private:
+ TEvConsole::TEvUpdateTenantPoolConfig::TPtr Request;
+ THolder<TEvConsole::TEvGetTenantStatusResponse> Response;
+};
+
+ITransaction *TTenantsManager::CreateTxUpdateTenantPoolConfig(TEvConsole::TEvUpdateTenantPoolConfig::TPtr &ev)
+{
+ return new TTxUpdateTenantPoolConfig(ev, this);
+}
+
+} // namespace NConsole
+} // namespace NKikimr
diff --git a/ydb/core/cms/console/console_impl.h b/ydb/core/cms/console/console_impl.h
index e9683c2249..59b02a24b7 100644
--- a/ydb/core/cms/console/console_impl.h
+++ b/ydb/core/cms/console/console_impl.h
@@ -109,6 +109,7 @@ private:
FFunc(TEvConsole::EvReplaceConfigSubscriptionsRequest, ForwardToConfigsManager);
HFuncTraced(TEvConsole::TEvSetConfigRequest, Handle);
FFunc(TEvConsole::EvToggleConfigValidatorRequest, ForwardToConfigsManager);
+ FFunc(TEvConsole::EvUpdateTenantPoolConfig, ForwardToTenantsManager);
HFuncTraced(TEvents::TEvPoisonPill, Handle);
IgnoreFunc(TEvTabletPipe::TEvServerConnected);
IgnoreFunc(TEvTabletPipe::TEvServerDisconnected);
diff --git a/ydb/core/cms/console/console_tenants_manager.cpp b/ydb/core/cms/console/console_tenants_manager.cpp
index 1853394eb8..5d84cd9dda 100644
--- a/ydb/core/cms/console/console_tenants_manager.cpp
+++ b/ydb/core/cms/console/console_tenants_manager.cpp
@@ -3101,6 +3101,11 @@ void TTenantsManager::Handle(TEvConsole::TEvRemoveTenantRequest::TPtr &ev, const
TxProcessor->ProcessTx(CreateTxRemoveTenant(ev), ctx);
}
+void TTenantsManager::Handle(TEvConsole::TEvUpdateTenantPoolConfig::TPtr &ev, const TActorContext &ctx)
+{
+ TxProcessor->ProcessTx(CreateTxUpdateTenantPoolConfig(ev), ctx);
+}
+
void TTenantsManager::Handle(TEvPrivate::TEvPoolAllocated::TPtr &ev, const TActorContext &ctx)
{
auto tenant = ev->Get()->Tenant;
diff --git a/ydb/core/cms/console/console_tenants_manager.h b/ydb/core/cms/console/console_tenants_manager.h
index 0d35f760d6..17e09c1496 100644
--- a/ydb/core/cms/console/console_tenants_manager.h
+++ b/ydb/core/cms/console/console_tenants_manager.h
@@ -713,6 +713,7 @@ public:
class TTxRevertPoolState;
class TTxUpdateSubDomainKey;
class TTxUpdateTenantState;
+ class TTxUpdateTenantPoolConfig;
ITransaction *CreateTxAlterTenant(TEvConsole::TEvAlterTenantRequest::TPtr &ev);
ITransaction *CreateTxCreateTenant(TEvConsole::TEvCreateTenantRequest::TPtr &ev);
@@ -738,6 +739,7 @@ public:
ITransaction *CreateTxRevertPoolState(TTenant::TPtr tenant,
TStoragePool::TPtr pool,
TActorId worker);
+ ITransaction *CreateTxUpdateTenantPoolConfig(TEvConsole::TEvUpdateTenantPoolConfig::TPtr &ev);
void ClearState();
void SetConfig(const NKikimrConsole::TTenantsConfig &config);
@@ -917,6 +919,7 @@ public:
void Handle(TEvConsole::TEvListTenantsRequest::TPtr &ev, const TActorContext &ctx);
void Handle(TEvConsole::TEvNotifyOperationCompletionRequest::TPtr &ev, const TActorContext &ctx);
void Handle(TEvConsole::TEvRemoveTenantRequest::TPtr &ev, const TActorContext &ctx);
+ void Handle(TEvConsole::TEvUpdateTenantPoolConfig::TPtr &ev, const TActorContext &ctx);
void Handle(TEvPrivate::TEvPoolAllocated::TPtr &ev, const TActorContext &ctx);
void Handle(TEvPrivate::TEvPoolDeleted::TPtr &ev, const TActorContext &ctx);
void Handle(TEvPrivate::TEvPoolFailed::TPtr &ev, const TActorContext &ctx);
@@ -944,6 +947,7 @@ public:
HFuncTraced(TEvConsole::TEvListTenantsRequest, Handle);
HFuncTraced(TEvConsole::TEvNotifyOperationCompletionRequest, Handle);
HFuncTraced(TEvConsole::TEvRemoveTenantRequest, Handle);
+ HFuncTraced(TEvConsole::TEvUpdateTenantPoolConfig, Handle);
HFuncTraced(TEvPrivate::TEvStateLoaded, Handle);
HFuncTraced(TEvPrivate::TEvPoolAllocated, Handle);
HFuncTraced(TEvPrivate::TEvPoolDeleted, Handle);
diff --git a/ydb/core/protos/console_tenant.proto b/ydb/core/protos/console_tenant.proto
index 7d3c687f5b..e683626e89 100644
--- a/ydb/core/protos/console_tenant.proto
+++ b/ydb/core/protos/console_tenant.proto
@@ -1,3 +1,5 @@
+import "ydb/core/protos/blobstorage_config.proto";
+
import "ydb/public/api/protos/ydb_cms.proto";
import "ydb/public/api/protos/ydb_operation.proto";
@@ -68,6 +70,14 @@ message TDescribeTenantOptionsResponse {
optional Ydb.Cms.DescribeDatabaseOptionsResponse Response = 1;
}
+// For internal use only. Commonly used for borrowed storage pools
+message TUpdateTenantPoolConfig {
+ optional string Tenant = 1;
+ optional string PoolType = 2;
+ optional NKikimrBlobStorage.TDefineStoragePool Config = 3;
+ optional bytes UserToken = 4;
+}
+
message TSlotLocation {
optional string DataCenter = 1;
optional bool ForceLocation = 2 [default = true];
diff --git a/ydb/core/protos/msgbus.proto b/ydb/core/protos/msgbus.proto
index 02e7fa02bd..f3af1a4b8d 100644
--- a/ydb/core/protos/msgbus.proto
+++ b/ydb/core/protos/msgbus.proto
@@ -732,6 +732,7 @@ message TConsoleRequest {
NKikimrConsole.TCheckConfigUpdatesRequest CheckConfigUpdatesRequest = 13;
NKikimrConsole.TListConfigValidatorsRequest ListConfigValidatorsRequest = 14;
NKikimrConsole.TToggleConfigValidatorRequest ToggleConfigValidatorRequest = 15;
+ NKikimrConsole.TUpdateTenantPoolConfig UpdateTenantPoolConfig = 16;
}
optional string DomainName = 100;
optional string SecurityToken = 101;