Skip to content

Commit

Permalink
Renamed future flag
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoriyPA committed Jun 15, 2024
1 parent 240142a commit e2958c3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
16 changes: 12 additions & 4 deletions ydb/core/kqp/gateway/behaviour/resource_pool/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ void CheckFeatureFlag(TResourcePoolManager::TInternalModificationContext& contex
ythrow yexception() << "This place needs an actor system. Please contact internal support";
}

if (!AppData(actorSystem)->FeatureFlags.GetEnableDynamicResourcePools()) {
throw std::runtime_error("Dynamic resource pools are disabled. Please contact your system administrator to enable it");
if (!AppData(actorSystem)->FeatureFlags.GetEnableResourcePools()) {
throw std::runtime_error("Resource pools are disabled. Please contact your system administrator to enable it");
}
}

void ValidateObjectId(const TString& objectId) {
if (objectId.find('/') != TString::npos) {
throw std::runtime_error("Resource pool id should not contain '/' symbol");
}
}

Expand All @@ -28,10 +34,10 @@ TResourcePoolManager::TYqlConclusionStatus StatusFromActivityType(TResourcePoolM
return TYqlConclusionStatus::Fail("Undefined operation for RESOURCE_POOL object");
case EActivityType::Upsert:
return TYqlConclusionStatus::Fail("Upsert operation for RESOURCE_POOL objects is not implemented");
case EActivityType::Alter:
return TYqlConclusionStatus::Fail("Alter operation for RESOURCE_POOL objects is not implemented");
case EActivityType::Create:
return TYqlConclusionStatus::Fail("Create operation for RESOURCE_POOL objects is not implemented");
case EActivityType::Alter:
return TYqlConclusionStatus::Fail("Alter operation for RESOURCE_POOL objects is not implemented");
case EActivityType::Drop:
return TYqlConclusionStatus::Fail("Drop operation for RESOURCE_POOL objects is not implemented");
}
Expand All @@ -44,6 +50,7 @@ NThreading::TFuture<TResourcePoolManager::TYqlConclusionStatus> TResourcePoolMan

try {
CheckFeatureFlag(context);
ValidateObjectId(settings.GetObjectId());

return NThreading::MakeFuture<TYqlConclusionStatus>(StatusFromActivityType(context.GetActivityType()));
} catch (...) {
Expand All @@ -56,6 +63,7 @@ TResourcePoolManager::TYqlConclusionStatus TResourcePoolManager::DoPrepare(NKqpP

try {
CheckFeatureFlag(context);
ValidateObjectId(settings.GetObjectId());

return StatusFromActivityType(context.GetActivityType());
} catch (...) {
Expand Down
19 changes: 16 additions & 3 deletions ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5989,16 +5989,16 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
}
}

Y_UNIT_TEST(DisableDynamicResourcePools) {
TKikimrRunner kikimr(TKikimrSettings().SetEnableDynamicResourcePools(false));
Y_UNIT_TEST(DisableResourcePools) {
TKikimrRunner kikimr(TKikimrSettings().SetEnableResourcePools(false));
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();

auto checkDisabled = [&session](const TString& query) {
Cerr << "Check query:\n" << query << "\n";
auto result = session.ExecuteSchemeQuery(query).GetValueSync();
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::GENERIC_ERROR);
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Dynamic resource pools are disabled. Please contact your system administrator to enable it");
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Resource pools are disabled. Please contact your system administrator to enable it");
};

// CREATE RESOURCE POOL
Expand All @@ -6020,6 +6020,19 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
// DROP RESOURCE POOL
checkDisabled("DROP RESOURCE POOL `MyResourcePool`;");
}

Y_UNIT_TEST(ResourcePoolsValidation) {
TKikimrRunner kikimr(TKikimrSettings().SetEnableResourcePools(true));
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();

auto result = session.ExecuteSchemeQuery(R"(
CREATE RESOURCE POOL `MyFolder/MyResourcePool` WITH (
CONCURRENT_QUERY_LIMIT=20
);)").GetValueSync();
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::GENERIC_ERROR);
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "Resource pool id should not contain '/' symbol");
}
}

Y_UNIT_TEST_SUITE(KqpOlapScheme) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ message TFeatureFlags {
optional bool EnableExternalSourceSchemaInference = 126 [default = false];
optional bool EnableDbMetadataCache = 127 [default = false];
optional bool EnableTableDatetime64 = 128 [default = false];
optional bool EnableDynamicResourcePools = 129 [default = false];
optional bool EnableResourcePools = 129 [default = false];
}
2 changes: 1 addition & 1 deletion ydb/core/testlib/basics/feature_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TTestFeatureFlagsHolder {
FEATURE_FLAG_SETTER(EnableReplaceIfExistsForExternalEntities)
FEATURE_FLAG_SETTER(EnableCMSRequestPriorities)
FEATURE_FLAG_SETTER(EnableTableDatetime64)
FEATURE_FLAG_SETTER(EnableDynamicResourcePools)
FEATURE_FLAG_SETTER(EnableResourcePools)

#undef FEATURE_FLAG_SETTER
};
Expand Down
2 changes: 1 addition & 1 deletion ydb/tests/tools/kqprun/configuration/app_config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FeatureFlags {
EnableExternalDataSources: true
EnableScriptExecutionOperations: true
EnableExternalSourceSchemaInference: true
EnableDynamicResourcePools: true
EnableResourcePools: true
}

KQPConfig {
Expand Down

0 comments on commit e2958c3

Please sign in to comment.