Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(standalone): hide etcd password in logs #13034

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/cmd_all/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ mod test {
// Test parsing into standalone-level opts.
let raw_opts = "
--compute-opts=--listen-addr 127.0.0.1:8000 --total-memory-bytes 34359738368 --parallelism 10
--meta-opts=--advertise-addr 127.0.0.1:9999 --data-directory \"some path with spaces\" --listen-addr 127.0.0.1:8001
--meta-opts=--advertise-addr 127.0.0.1:9999 --data-directory \"some path with spaces\" --listen-addr 127.0.0.1:8001 --etcd-password 1234
--frontend-opts=--config-path=src/config/original.toml
--prometheus-listener-addr=127.0.0.1:1234
--config-path=src/config/test.toml
";
let actual = StandaloneOpts::parse_from(raw_opts.lines());
let opts = StandaloneOpts {
compute_opts: Some("--listen-addr 127.0.0.1:8000 --total-memory-bytes 34359738368 --parallelism 10".into()),
meta_opts: Some("--advertise-addr 127.0.0.1:9999 --data-directory \"some path with spaces\" --listen-addr 127.0.0.1:8001".into()),
meta_opts: Some("--advertise-addr 127.0.0.1:9999 --data-directory \"some path with spaces\" --listen-addr 127.0.0.1:8001 --etcd-password 1234".into()),
frontend_opts: Some("--config-path=src/config/original.toml".into()),
compactor_opts: None,
prometheus_listener_addr: Some("127.0.0.1:1234".into()),
Expand All @@ -228,7 +228,7 @@ mod test {
etcd_endpoints: "",
etcd_auth: false,
etcd_username: "",
etcd_password: "",
etcd_password: [REDACTED alloc::string::String],
sql_endpoint: None,
dashboard_ui_path: None,
prometheus_endpoint: None,
Expand Down
1 change: 1 addition & 0 deletions src/meta/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ futures = { version = "0.3", default-features = false, features = ["alloc"] }
itertools = "0.11"
model_migration = { path = "../src/model_v2/migration" }
prometheus-http-query = "0.7"
redact = "0.1.5"
regex = "1"
risingwave_common = { workspace = true }
risingwave_common_heap_profiling = { workspace = true }
Expand Down
9 changes: 7 additions & 2 deletions src/meta/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
#![cfg_attr(coverage, feature(no_coverage))]

mod server;

use std::time::Duration;

use clap::Parser;
pub use error::{MetaError, MetaResult};
use redact::Secret;
use risingwave_common::config::OverrideConfig;
use risingwave_common::util::resource_util;
use risingwave_common::{GIT_SHA, RW_VERSION};
Expand Down Expand Up @@ -71,7 +73,7 @@ pub struct MetaNodeOpts {

/// Password of etcd, required when --etcd-auth is enabled.
#[clap(long, env = "RW_ETCD_PASSWORD", default_value = "")]
etcd_password: String,
etcd_password: Secret<String>,

/// Endpoint of the SQL service, make it non-option when SQL service is required.
#[clap(long, env = "RW_SQL_ENDPOINT")]
Expand Down Expand Up @@ -196,7 +198,10 @@ pub fn start(opts: MetaNodeOpts) -> Pin<Box<dyn Future<Output = ()> + Send>> {
.map(|x| x.to_string())
.collect(),
credentials: match opts.etcd_auth {
true => Some((opts.etcd_username, opts.etcd_password)),
true => Some((
opts.etcd_username,
opts.etcd_password.expose_secret().to_string(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I feel ideally we should make all the intermediate stuff Secret, and reveal secret until we have to. Just checked MetaStoreBackend also #[derive(Debug)]. 🤣

Just raise this point. Not a hard requirement for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)),
false => None,
},
},
Expand Down