From 44e7d5132fe483c4c0ed1cdfcdfdfef5dfe92eba Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Thu, 29 Jun 2023 15:53:16 +0300 Subject: [PATCH] fix: hide token from logs (#4584) fixes #4583 and also changes all needlessly arg listing places to use `skip_all`. --- compute_tools/src/compute.rs | 16 ++++++++-------- compute_tools/src/configurator.rs | 2 +- compute_tools/src/pg_helpers.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index 6b549e198b..87acefc1bb 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -235,7 +235,7 @@ impl ComputeNode { // Get basebackup from the libpq connection to pageserver using `connstr` and // unarchive it to `pgdata` directory overriding all its previous content. - #[instrument(skip(self, compute_state))] + #[instrument(skip_all, fields(%lsn))] fn get_basebackup(&self, compute_state: &ComputeState, lsn: Lsn) -> Result<()> { let spec = compute_state.pspec.as_ref().expect("spec must be set"); let start_time = Utc::now(); @@ -277,7 +277,7 @@ impl ComputeNode { // Run `postgres` in a special mode with `--sync-safekeepers` argument // and return the reported LSN back to the caller. - #[instrument(skip(self, storage_auth_token))] + #[instrument(skip_all)] fn sync_safekeepers(&self, storage_auth_token: Option) -> Result { let start_time = Utc::now(); @@ -322,7 +322,7 @@ impl ComputeNode { /// Do all the preparations like PGDATA directory creation, configuration, /// safekeepers sync, basebackup, etc. - #[instrument(skip(self, compute_state))] + #[instrument(skip_all)] pub fn prepare_pgdata(&self, compute_state: &ComputeState) -> Result<()> { let pspec = compute_state.pspec.as_ref().expect("spec must be set"); let spec = &pspec.spec; @@ -380,7 +380,7 @@ impl ComputeNode { /// Start Postgres as a child process and manage DBs/roles. /// After that this will hang waiting on the postmaster process to exit. - #[instrument(skip(self))] + #[instrument(skip_all)] pub fn start_postgres( &self, storage_auth_token: Option, @@ -404,7 +404,7 @@ impl ComputeNode { } /// Do initial configuration of the already started Postgres. - #[instrument(skip(self, compute_state))] + #[instrument(skip_all)] pub fn apply_config(&self, compute_state: &ComputeState) -> Result<()> { // If connection fails, // it may be the old node with `zenith_admin` superuser. @@ -458,7 +458,7 @@ impl ComputeNode { // We could've wrapped this around `pg_ctl reload`, but right now we don't use // `pg_ctl` for start / stop, so this just seems much easier to do as we already // have opened connection to Postgres and superuser access. - #[instrument(skip(self, client))] + #[instrument(skip_all)] fn pg_reload_conf(&self, client: &mut Client) -> Result<()> { client.simple_query("SELECT pg_reload_conf()")?; Ok(()) @@ -466,7 +466,7 @@ impl ComputeNode { /// Similar to `apply_config()`, but does a bit different sequence of operations, /// as it's used to reconfigure a previously started and configured Postgres node. - #[instrument(skip(self))] + #[instrument(skip_all)] pub fn reconfigure(&self) -> Result<()> { let spec = self.state.lock().unwrap().pspec.clone().unwrap().spec; @@ -501,7 +501,7 @@ impl ComputeNode { Ok(()) } - #[instrument(skip(self))] + #[instrument(skip_all)] pub fn start_compute(&self) -> Result { let compute_state = self.state.lock().unwrap().clone(); let pspec = compute_state.pspec.as_ref().expect("spec must be set"); diff --git a/compute_tools/src/configurator.rs b/compute_tools/src/configurator.rs index a07fd0b8cd..13550e0176 100644 --- a/compute_tools/src/configurator.rs +++ b/compute_tools/src/configurator.rs @@ -8,7 +8,7 @@ use compute_api::responses::ComputeStatus; use crate::compute::ComputeNode; -#[instrument(skip(compute))] +#[instrument(skip_all)] fn configurator_main_loop(compute: &Arc) { info!("waiting for reconfiguration requests"); loop { diff --git a/compute_tools/src/pg_helpers.rs b/compute_tools/src/pg_helpers.rs index b76ed1fd85..6a78bffd1b 100644 --- a/compute_tools/src/pg_helpers.rs +++ b/compute_tools/src/pg_helpers.rs @@ -215,7 +215,7 @@ pub fn get_existing_dbs(client: &mut Client) -> Result> { /// Wait for Postgres to become ready to accept connections. It's ready to /// accept connections when the state-field in `pgdata/postmaster.pid` says /// 'ready'. -#[instrument(skip(pg))] +#[instrument(skip_all, fields(pgdata = %pgdata.display()))] pub fn wait_for_postgres(pg: &mut Child, pgdata: &Path) -> Result<()> { let pid_path = pgdata.join("postmaster.pid");