From 0726b590765e3325fbeb07dde4065579f852b87a Mon Sep 17 00:00:00 2001 From: zwang28 <70626450+zwang28@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:26:40 +0800 Subject: [PATCH] fix(config): make metrics_level opt backward compatible (#12541) --- ci/scripts/standalone-utils.sh | 2 -- docker/docker-compose-with-hdfs.yml | 6 ------ docker/docker-compose.yml | 6 ------ src/cmd_all/scripts/standalone-demo-dev.sh | 2 -- src/cmd_all/scripts/standalone-demo-full.sh | 2 -- src/common/src/config.rs | 17 ++++++++++++++++- src/risedevtool/src/task/compactor_service.rs | 4 +--- .../src/task/compute_node_service.rs | 2 -- src/risedevtool/src/task/frontend_service.rs | 4 +--- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/ci/scripts/standalone-utils.sh b/ci/scripts/standalone-utils.sh index 4461331c28bf..ca2f8c788f65 100755 --- a/ci/scripts/standalone-utils.sh +++ b/ci/scripts/standalone-utils.sh @@ -24,7 +24,6 @@ start_standalone() { --listen-addr 127.0.0.1:5688 \ --prometheus-listener-addr 127.0.0.1:1222 \ --advertise-addr 127.0.0.1:5688 \ - --metrics-level info \ --async-stack-trace verbose \ --connector-rpc-endpoint 127.0.0.1:50051 \ --parallelism 4 \ @@ -36,7 +35,6 @@ start_standalone() { --advertise-addr 127.0.0.1:4566 \ --prometheus-listener-addr 127.0.0.1:2222 \ --health-check-listener-addr 127.0.0.1:6786 \ - --metrics-level info \ --meta-addr http://127.0.0.1:5690" >"$1" 2>&1 } diff --git a/docker/docker-compose-with-hdfs.yml b/docker/docker-compose-with-hdfs.yml index 5b411174370c..4467b03a7c03 100644 --- a/docker/docker-compose-with-hdfs.yml +++ b/docker/docker-compose-with-hdfs.yml @@ -11,8 +11,6 @@ services: - "compactor-0:6660" - "--prometheus-listener-addr" - "0.0.0.0:1260" - - "--metrics-level" - - "info" - "--meta-address" - "http://meta-node-0:5690" - "--config-path" @@ -46,8 +44,6 @@ services: - "compute-node-0:5688" - "--prometheus-listener-addr" - "0.0.0.0:1222" - - "--metrics-level" - - "info" - "--meta-address" - "http://meta-node-0:5690" - "--connector-rpc-endpoint" @@ -136,8 +132,6 @@ services: - /risingwave.toml - "--prometheus-listener-addr" - "0.0.0.0:2222" - - "--metrics-level" - - "info" expose: - "4566" ports: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 328ebe9b7bac..89aa99a1c8b5 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -11,8 +11,6 @@ services: - "compactor-0:6660" - "--prometheus-listener-addr" - "0.0.0.0:1260" - - "--metrics-level" - - "info" - "--meta-address" - "http://meta-node-0:5690" - "--config-path" @@ -48,8 +46,6 @@ services: - "compute-node-0:5688" - "--prometheus-listener-addr" - "0.0.0.0:1222" - - "--metrics-level" - - "info" - "--meta-address" - "http://meta-node-0:5690" - "--connector-rpc-endpoint" @@ -139,8 +135,6 @@ services: - /risingwave.toml - "--prometheus-listener-addr" - "0.0.0.0:2222" - - "--metrics-level" - - "info" expose: - "4566" ports: diff --git a/src/cmd_all/scripts/standalone-demo-dev.sh b/src/cmd_all/scripts/standalone-demo-dev.sh index 6a4c124ae74e..1819f4065da5 100755 --- a/src/cmd_all/scripts/standalone-demo-dev.sh +++ b/src/cmd_all/scripts/standalone-demo-dev.sh @@ -22,7 +22,6 @@ cargo run -p risingwave_cmd_all \ --listen-addr 127.0.0.1:5688 \ --prometheus-listener-addr 127.0.0.1:1222 \ --advertise-addr 127.0.0.1:5688 \ - --metrics-level info \ --async-stack-trace verbose \ --connector-rpc-endpoint 127.0.0.1:50051 \ --parallelism 4 \ @@ -35,5 +34,4 @@ cargo run -p risingwave_cmd_all \ --advertise-addr 127.0.0.1:4566 \ --prometheus-listener-addr 127.0.0.1:2222 \ --health-check-listener-addr 127.0.0.1:6786 \ - --metrics-level info \ --meta-addr http://127.0.0.1:5690" \ No newline at end of file diff --git a/src/cmd_all/scripts/standalone-demo-full.sh b/src/cmd_all/scripts/standalone-demo-full.sh index 83358fd9f370..4fa3fe183251 100755 --- a/src/cmd_all/scripts/standalone-demo-full.sh +++ b/src/cmd_all/scripts/standalone-demo-full.sh @@ -29,7 +29,6 @@ start_standalone() { --listen-addr 127.0.0.1:5688 \ --prometheus-listener-addr 127.0.0.1:1222 \ --advertise-addr 127.0.0.1:5688 \ - --metrics-level info \ --async-stack-trace verbose \ --connector-rpc-endpoint 127.0.0.1:50051 \ --parallelism 4 \ @@ -42,7 +41,6 @@ start_standalone() { --advertise-addr 127.0.0.1:4566 \ --prometheus-listener-addr 127.0.0.1:2222 \ --health-check-listener-addr 127.0.0.1:6786 \ - --metrics-level info \ --meta-addr http://127.0.0.1:5690" } diff --git a/src/common/src/config.rs b/src/common/src/config.rs index c1a81e9d5fe7..8590e193b93e 100644 --- a/src/common/src/config.rs +++ b/src/common/src/config.rs @@ -422,7 +422,7 @@ pub struct StreamingConfig { pub unrecognized: Unrecognized, } -#[derive(Debug, Default, Clone, Copy, ValueEnum, Serialize, Deserialize)] +#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)] pub enum MetricLevel { #[default] Disabled = 0, @@ -431,6 +431,21 @@ pub enum MetricLevel { Debug = 3, } +impl clap::ValueEnum for MetricLevel { + fn value_variants<'a>() -> &'a [Self] { + &[Self::Disabled, Self::Critical, Self::Info, Self::Debug] + } + + fn to_possible_value<'a>(&self) -> ::std::option::Option { + match self { + Self::Disabled => Some(clap::builder::PossibleValue::new("disabled").alias("0")), + Self::Critical => Some(clap::builder::PossibleValue::new("critical")), + Self::Info => Some(clap::builder::PossibleValue::new("info").alias("1")), + Self::Debug => Some(clap::builder::PossibleValue::new("debug")), + } + } +} + impl PartialEq for MetricLevel { fn eq(&self, other: &Self) -> bool { (*self as u8).eq(&(*other as u8)) diff --git a/src/risedevtool/src/task/compactor_service.rs b/src/risedevtool/src/task/compactor_service.rs index c1d9dc4bc5b4..9305fea7ff53 100644 --- a/src/risedevtool/src/task/compactor_service.rs +++ b/src/risedevtool/src/task/compactor_service.rs @@ -53,9 +53,7 @@ impl CompactorService { config.listen_address, config.exporter_port )) .arg("--advertise-addr") - .arg(format!("{}:{}", config.address, config.port)) - .arg("--metrics-level") - .arg("info"); + .arg(format!("{}:{}", config.address, config.port)); if let Some(compaction_worker_threads_number) = config.compaction_worker_threads_number.as_ref() { diff --git a/src/risedevtool/src/task/compute_node_service.rs b/src/risedevtool/src/task/compute_node_service.rs index 4d6ef7351b20..d048d5b9e620 100644 --- a/src/risedevtool/src/task/compute_node_service.rs +++ b/src/risedevtool/src/task/compute_node_service.rs @@ -56,8 +56,6 @@ impl ComputeNodeService { )) .arg("--advertise-addr") .arg(format!("{}:{}", config.address, config.port)) - .arg("--metrics-level") - .arg("info") .arg("--async-stack-trace") .arg(&config.async_stack_trace) .arg("--connector-rpc-endpoint") diff --git a/src/risedevtool/src/task/frontend_service.rs b/src/risedevtool/src/task/frontend_service.rs index c7573e0a52d8..cf0213028e46 100644 --- a/src/risedevtool/src/task/frontend_service.rs +++ b/src/risedevtool/src/task/frontend_service.rs @@ -61,9 +61,7 @@ impl FrontendService { .arg(format!( "{}:{}", config.listen_address, config.health_check_port - )) - .arg("--metrics-level") - .arg("info"); + )); let provide_meta_node = config.provide_meta_node.as_ref().unwrap(); if provide_meta_node.is_empty() {