@@ -201,6 +201,41 @@ class TTenantsManager::TTxAlterTenant : public TTransactionBase<TTenantsManager>
201
201
return Error (Ydb::StatusIds::BAD_REQUEST, " Data size soft quota cannot be larger than hard quota" , ctx);
202
202
}
203
203
}
204
+
205
+ // Check scale recommender policies.
206
+ if (rec.has_scale_recommender_policies ()) {
207
+ const auto & policies = rec.scale_recommender_policies ();
208
+ if (policies.policies ().size () > 1 ) {
209
+ return Error (Ydb::StatusIds::BAD_REQUEST, " Currently, no more than one policy is supported at a time" , ctx);
210
+ }
211
+
212
+ if (!policies.policies ().empty ()) {
213
+ const auto & policy = policies.policies ()[0 ];
214
+ switch (policy.GetPolicyCase ()) {
215
+ case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy::kTargetTrackingPolicy : {
216
+ const auto & targetTracking = policy.target_tracking_policy ();
217
+ switch (targetTracking.GetTargetCase ()) {
218
+ case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy::kAverageCpuUtilizationPercent : {
219
+ auto cpuUtilization = targetTracking.average_cpu_utilization_percent ();
220
+ if (cpuUtilization < 10 || cpuUtilization > 90 ) {
221
+ return Error (Ydb::StatusIds::BAD_REQUEST, " Average CPU utilization target must be from 10% to 90%" , ctx);
222
+ }
223
+ break ;
224
+ }
225
+ case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy_TargetTrackingPolicy::TARGET_NOT_SET:
226
+ return Error (Ydb::StatusIds::BAD_REQUEST, " Target type for target tracking policy is not set" , ctx);
227
+ default :
228
+ return Error (Ydb::StatusIds::BAD_REQUEST, " Unsupported target type for target tracking policy" , ctx);
229
+ }
230
+ break ;
231
+ }
232
+ case Ydb::Cms::ScaleRecommenderPolicies_ScaleRecommenderPolicy::POLICY_NOT_SET:
233
+ return Error (Ydb::StatusIds::BAD_REQUEST, " Policy type is not set" , ctx);
234
+ default :
235
+ return Error (Ydb::StatusIds::BAD_REQUEST, " Unsupported policy type" , ctx);
236
+ }
237
+ }
238
+ }
204
239
205
240
// Check attributes.
206
241
THashSet<TString> attrNames;
@@ -274,6 +309,11 @@ class TTenantsManager::TTxAlterTenant : public TTransactionBase<TTenantsManager>
274
309
updateSubdomainVersion = true ;
275
310
}
276
311
312
+ if (rec.has_scale_recommender_policies ()) {
313
+ ScaleRecommenderPolicies.ConstructInPlace (rec.scale_recommender_policies ());
314
+ Self->DbUpdateScaleRecommenderPolicies (Tenant, *ScaleRecommenderPolicies, txc, ctx);
315
+ }
316
+
277
317
if (rec.idempotency_key () || Tenant->AlterIdempotencyKey ) {
278
318
Tenant->AlterIdempotencyKey = rec.idempotency_key ();
279
319
Self->DbUpdateTenantAlterIdempotencyKey (Tenant, Tenant->AlterIdempotencyKey , txc, ctx);
@@ -367,6 +407,9 @@ class TTenantsManager::TTxAlterTenant : public TTransactionBase<TTenantsManager>
367
407
if (DatabaseQuotas) {
368
408
Tenant->DatabaseQuotas .ConstructInPlace (*DatabaseQuotas);
369
409
}
410
+ if (ScaleRecommenderPolicies) {
411
+ Tenant->ScaleRecommenderPolicies .ConstructInPlace (*ScaleRecommenderPolicies);
412
+ }
370
413
if (SubdomainVersion) {
371
414
Tenant->SubdomainVersion = *SubdomainVersion;
372
415
}
@@ -389,6 +432,7 @@ class TTenantsManager::TTxAlterTenant : public TTransactionBase<TTenantsManager>
389
432
THashMap<TString, ui64> PoolsToAdd;
390
433
TMaybe<Ydb::Cms::SchemaOperationQuotas> SchemaOperationQuotas;
391
434
TMaybe<Ydb::Cms::DatabaseQuotas> DatabaseQuotas;
435
+ TMaybe<Ydb::Cms::ScaleRecommenderPolicies> ScaleRecommenderPolicies;
392
436
TMaybe<ui64> SubdomainVersion;
393
437
bool ComputationalUnitsModified;
394
438
TTenant::TPtr Tenant;
0 commit comments