From a80f61182f2d64d55ffad9cd37b0d8971b071c55 Mon Sep 17 00:00:00 2001 From: Yuhao Su Date: Fri, 26 Jul 2024 16:23:42 +0800 Subject: [PATCH 1/3] init --- e2e_test/ddl/secret.slt | 30 +++++++++++++++++++++++ src/frontend/src/handler/create_secret.rs | 5 ++++ src/frontend/src/handler/drop_secret.rs | 5 ++++ src/license/src/feature.rs | 1 + 4 files changed, 41 insertions(+) diff --git a/e2e_test/ddl/secret.slt b/e2e_test/ddl/secret.slt index 7c11e2e6245a3..62a5a09add668 100644 --- a/e2e_test/ddl/secret.slt +++ b/e2e_test/ddl/secret.slt @@ -1,3 +1,33 @@ +statement ok +ALTER SYSTEM SET license_key TO ''; + +statement error +create secret secret_1 with ( + backend = 'fake-backend' +) as 'demo_secret'; +---- +db error: ERROR: Failed to run the query + +Caused by: + feature SecretManagement is only available for tier Paid and above, while the current tier is Free + +Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. + + +statement error +drop secret secret_1; +---- +db error: ERROR: Failed to run the query + +Caused by: + feature SecretManagement is only available for tier Paid and above, while the current tier is Free + +Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. + + +statement ok +ALTER SYSTEM SET license_key TO DEFAULT; + statement error secret backend "fake-backend" is not supported create secret secret_1 with ( backend = 'fake-backend' diff --git a/src/frontend/src/handler/create_secret.rs b/src/frontend/src/handler/create_secret.rs index 8e3e56f324b44..9810751361be3 100644 --- a/src/frontend/src/handler/create_secret.rs +++ b/src/frontend/src/handler/create_secret.rs @@ -15,6 +15,7 @@ use pgwire::pg_response::{PgResponse, StatementType}; use prost::Message; use risingwave_common::bail_not_implemented; +use risingwave_common::license::Feature; use risingwave_sqlparser::ast::{CreateSecretStatement, SqlOption, Value}; use crate::error::{ErrorCode, Result}; @@ -30,6 +31,10 @@ pub async fn handle_create_secret( handler_args: HandlerArgs, stmt: CreateSecretStatement, ) -> Result { + Feature::SecretManagement + .check_available() + .map_err(|e| anyhow::anyhow!(e))?; + let session = handler_args.session.clone(); let db_name = session.database(); let (schema_name, connection_name) = diff --git a/src/frontend/src/handler/drop_secret.rs b/src/frontend/src/handler/drop_secret.rs index 4001cc99cfd8f..eff4b35224b8b 100644 --- a/src/frontend/src/handler/drop_secret.rs +++ b/src/frontend/src/handler/drop_secret.rs @@ -13,6 +13,7 @@ // limitations under the License. use pgwire::pg_response::StatementType; +use risingwave_common::license::Feature; use risingwave_sqlparser::ast::ObjectName; use crate::catalog::root_catalog::SchemaPath; @@ -25,6 +26,10 @@ pub async fn handle_drop_secret( secret_name: ObjectName, if_exists: bool, ) -> Result { + Feature::SecretManagement + .check_available() + .map_err(|e| anyhow::anyhow!(e))?; + let session = handler_args.session; let db_name = session.database(); let (schema_name, secret_name) = Binder::resolve_schema_qualified_name(db_name, secret_name)?; diff --git a/src/license/src/feature.rs b/src/license/src/feature.rs index ecfa9199f78d9..70d17336d8b67 100644 --- a/src/license/src/feature.rs +++ b/src/license/src/feature.rs @@ -46,6 +46,7 @@ macro_rules! for_all_features { { TestPaid, Paid, "A dummy feature that's only available on paid tier for testing purposes." }, { TimeTravel, Paid, "Query historical data within the retention period."}, { GlueSchemaRegistry, Paid, "Use Schema Registry from AWS Glue rather than Confluent." }, + { SecretManagement, Paid, "Use secret management" }, } }; } From 6f8365a0f042f48606860db506aba008bf9dff57 Mon Sep 17 00:00:00 2001 From: Yuhao Su Date: Fri, 26 Jul 2024 16:59:37 +0800 Subject: [PATCH 2/3] improve --- src/license/src/feature.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/license/src/feature.rs b/src/license/src/feature.rs index 70d17336d8b67..db99ef264bcd9 100644 --- a/src/license/src/feature.rs +++ b/src/license/src/feature.rs @@ -46,7 +46,7 @@ macro_rules! for_all_features { { TestPaid, Paid, "A dummy feature that's only available on paid tier for testing purposes." }, { TimeTravel, Paid, "Query historical data within the retention period."}, { GlueSchemaRegistry, Paid, "Use Schema Registry from AWS Glue rather than Confluent." }, - { SecretManagement, Paid, "Use secret management" }, + { SecretManagement, Paid, "Secret management" }, } }; } From 0b77be3c4a8bf323ed3fdd03df632138febb8594 Mon Sep 17 00:00:00 2001 From: Yuhao Su <31772373+yuhao-su@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:17:30 +0800 Subject: [PATCH 3/3] Update src/license/src/feature.rs Co-authored-by: Bugen Zhao --- src/license/src/feature.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/license/src/feature.rs b/src/license/src/feature.rs index db99ef264bcd9..186e15c998ae4 100644 --- a/src/license/src/feature.rs +++ b/src/license/src/feature.rs @@ -46,7 +46,7 @@ macro_rules! for_all_features { { TestPaid, Paid, "A dummy feature that's only available on paid tier for testing purposes." }, { TimeTravel, Paid, "Query historical data within the retention period."}, { GlueSchemaRegistry, Paid, "Use Schema Registry from AWS Glue rather than Confluent." }, - { SecretManagement, Paid, "Secret management" }, + { SecretManagement, Paid, "Secret management." }, } }; }