From 365172f55afd2e795630feed2ba7f92f6005368e Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Fri, 2 Aug 2024 16:47:14 +0800 Subject: [PATCH] feat: support initializing license key from env var Signed-off-by: Bugen Zhao --- src/cmd_all/src/standalone.rs | 1 + src/meta/node/src/lib.rs | 8 +++++++- src/meta/src/controller/system_param.rs | 3 +-- src/meta/src/manager/system_param/mod.rs | 3 +-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cmd_all/src/standalone.rs b/src/cmd_all/src/standalone.rs index ceb890f4cb3a..27c8c4020339 100644 --- a/src/cmd_all/src/standalone.rs +++ b/src/cmd_all/src/standalone.rs @@ -467,6 +467,7 @@ mod test { heap_profiling_dir: None, dangerous_max_idle_secs: None, connector_rpc_endpoint: None, + license_key: None, temp_secret_file_dir: "./meta/secrets/", }, ), diff --git a/src/meta/node/src/lib.rs b/src/meta/node/src/lib.rs index 65e730166aed..825d40b5172d 100644 --- a/src/meta/node/src/lib.rs +++ b/src/meta/node/src/lib.rs @@ -25,6 +25,7 @@ use educe::Educe; pub use error::{MetaError, MetaResult}; use redact::Secret; use risingwave_common::config::OverrideConfig; +use risingwave_common::license::LicenseKey; use risingwave_common::util::meta_addr::MetaAddressStrategy; use risingwave_common::util::resource_util; use risingwave_common::util::tokio_util::sync::CancellationToken; @@ -187,8 +188,13 @@ pub struct MetaNodeOpts { #[clap(long, hide = true, env = "RW_CONNECTOR_RPC_ENDPOINT")] pub connector_rpc_endpoint: Option, + /// The license key to activate enterprise features. + #[clap(long, hide = true, env = "RW_LICENSE_KEY")] + #[override_opts(path = system.license_key)] + pub license_key: Option, + /// 128-bit AES key for secret store in HEX format. - #[educe(Debug(ignore))] + #[educe(Debug(ignore))] // TODO: use newtype to redact debug impl #[clap(long, hide = true, env = "RW_SECRET_STORE_PRIVATE_KEY_HEX")] pub secret_store_private_key_hex: Option, diff --git a/src/meta/src/controller/system_param.rs b/src/meta/src/controller/system_param.rs index a4b5ff239c07..e9d3c25be89f 100644 --- a/src/meta/src/controller/system_param.rs +++ b/src/meta/src/controller/system_param.rs @@ -31,7 +31,6 @@ use sea_orm::{ActiveModelTrait, DatabaseConnection, EntityTrait, TransactionTrai use tokio::sync::oneshot::Sender; use tokio::sync::RwLock; use tokio::task::JoinHandle; -use tracing::info; use crate::controller::SqlMetaStore; use crate::manager::{LocalNotification, NotificationManagerRef}; @@ -143,7 +142,7 @@ impl SystemParamsController { let params = SystemParameter::find().all(&db).await?; let params = merge_params(system_params_from_db(params)?, init_params); - info!(initial_params = ?SystemParamsReader::new(¶ms), "initialize system parameters"); + tracing::info!(initial_params = ?SystemParamsReader::new(¶ms), "initialize system parameters"); check_missing_params(¶ms).map_err(|e| anyhow!(e))?; let ctl = Self { diff --git a/src/meta/src/manager/system_param/mod.rs b/src/meta/src/manager/system_param/mod.rs index d77be8e5d03d..8776746c5471 100644 --- a/src/meta/src/manager/system_param/mod.rs +++ b/src/meta/src/manager/system_param/mod.rs @@ -30,7 +30,6 @@ use risingwave_pb::meta::SystemParams; use tokio::sync::oneshot::Sender; use tokio::sync::RwLock; use tokio::task::JoinHandle; -use tracing::info; use self::model::SystemParamsModel; use super::NotificationManagerRef; @@ -77,7 +76,7 @@ impl SystemParamsManager { return Err(require_sql_meta_store_err().into()); } - info!(initial_params = ?SystemParamsReader::new(¶ms), "initialize system parameters"); + tracing::info!(initial_params = ?SystemParamsReader::new(¶ms), "initialize system parameters"); check_missing_params(¶ms).map_err(|e| anyhow!(e))?; Ok(Self {