diff options
author | galaxycrab <UgnineSirdis@ydb.tech> | 2022-09-17 08:43:04 +0300 |
---|---|---|
committer | galaxycrab <UgnineSirdis@ydb.tech> | 2022-09-17 08:43:04 +0300 |
commit | 6d2819377bd78f50c415e809c9f0feae0d79fe9f (patch) | |
tree | 705caa167ba29a51442b444ea09cc9583f48f2d7 | |
parent | 6ec5a0ce79d9a08e0057f67387909d9325ccc582 (diff) | |
download | ydb-6d2819377bd78f50c415e809c9f0feae0d79fe9f.tar.gz |
Make quotas default and hard limits configurable
-rw-r--r-- | ydb/core/yq/libs/config/protos/quotas_manager.proto | 14 | ||||
-rw-r--r-- | ydb/core/yq/libs/quota_manager/quota_manager.cpp | 19 |
2 files changed, 28 insertions, 5 deletions
diff --git a/ydb/core/yq/libs/config/protos/quotas_manager.proto b/ydb/core/yq/libs/config/protos/quotas_manager.proto index 8defdaee6d..df6568f7d9 100644 --- a/ydb/core/yq/libs/config/protos/quotas_manager.proto +++ b/ydb/core/yq/libs/config/protos/quotas_manager.proto @@ -17,10 +17,18 @@ message TQuotaList { repeated TQuotaLimit Limit = 3; } +message TQuotaDescriptionConfig { + string SubjectType = 1; + string MetricName = 2; + uint64 DefaultLimit = 3; + uint64 HardLimit = 4; +}; + message TQuotasManagerConfig { bool Enabled = 1; repeated TQuotaList Quotas = 2; - string LimitRefreshPeriod = 3; - string UsageRefreshPeriod = 4; - bool EnablePermissions = 5; + repeated TQuotaDescriptionConfig QuotaDescriptions = 3; + string LimitRefreshPeriod = 4; + string UsageRefreshPeriod = 5; + bool EnablePermissions = 6; } diff --git a/ydb/core/yq/libs/quota_manager/quota_manager.cpp b/ydb/core/yq/libs/quota_manager/quota_manager.cpp index 02717eafa5..b1a8186f70 100644 --- a/ydb/core/yq/libs/quota_manager/quota_manager.cpp +++ b/ydb/core/yq/libs/quota_manager/quota_manager.cpp @@ -153,9 +153,24 @@ public: , ServiceCounters(counters->GetSubgroup("subsystem", "quota_manager")) , Monitoring(monitoring) { - for (auto& description : quotaDescriptions) { + for (const auto& description : quotaDescriptions) { QuotaInfoMap[description.SubjectType].emplace(description.MetricName, description.Info); } + // Override static settings with config + for (const auto& config : Config.GetQuotaDescriptions()) { + Y_VERIFY(config.GetSubjectType()); + Y_VERIFY(config.GetMetricName()); + auto& metricsMap = QuotaInfoMap[config.GetSubjectType()]; + auto infoIt = metricsMap.find(config.GetMetricName()); + Y_VERIFY(infoIt != metricsMap.end()); + auto& info = infoIt->second; + if (config.GetDefaultLimit()) { + info.DefaultLimit = config.GetDefaultLimit(); + } + if (config.GetHardLimit()) { + info.HardLimit = config.GetHardLimit(); + } + } LimitRefreshPeriod = GetDuration(Config.GetLimitRefreshPeriod(), LIMIT_REFRESH_PERIOD); UsageRefreshPeriod = GetDuration(Config.GetUsageRefreshPeriod(), USAGE_REFRESH_PERIOD); } @@ -164,7 +179,7 @@ public: void Bootstrap() { if (Monitoring) { - Monitoring->RegisterActorPage(Monitoring->RegisterIndexPage("fq_diag", "Federated Query diagnostics"), + Monitoring->RegisterActorPage(Monitoring->RegisterIndexPage("fq_diag", "Federated Query diagnostics"), "quotas", "Quota Manager", false, TActivationContext::ActorSystem(), SelfId()); } |