From 8d783299919ac4c8d86fb5c5187450cc49c0108a Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Sat, 25 Mar 2023 13:43:04 +0200 Subject: [PATCH] Remove some dead code. whoami() was never called, 'is_test' was never set. 'restart()' might be useful, but it wasn't hooked up the CLI so it was dead code. It's not clear what kind of a restart it should perform, anyway: just restart Postgres, or re-initialize the data directory from a fresh basebackup like "stop"+"start" does. --- control_plane/src/compute.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/control_plane/src/compute.rs b/control_plane/src/compute.rs index 730cacf40b..46f0ad8d4f 100644 --- a/control_plane/src/compute.rs +++ b/control_plane/src/compute.rs @@ -87,7 +87,6 @@ impl ComputeControlPlane { address: SocketAddr::new("127.0.0.1".parse().unwrap(), port), env: self.env.clone(), pageserver: Arc::clone(&self.pageserver), - is_test: false, timeline_id, lsn, tenant_id, @@ -113,7 +112,6 @@ pub struct PostgresNode { name: String, pub env: LocalEnv, pageserver: Arc, - is_test: bool, pub timeline_id: TimelineId, pub lsn: Option, // if it's a read-only node. None for primary pub tenant_id: TenantId, @@ -171,7 +169,6 @@ impl PostgresNode { name, env: env.clone(), pageserver: Arc::clone(pageserver), - is_test: false, timeline_id, lsn: recovery_target_lsn, tenant_id, @@ -480,10 +477,6 @@ impl PostgresNode { self.pg_ctl(&["start"], auth_token) } - pub fn restart(&self, auth_token: &Option) -> Result<()> { - self.pg_ctl(&["restart"], auth_token) - } - pub fn stop(&self, destroy: bool) -> Result<()> { // If we are going to destroy data directory, // use immediate shutdown mode, otherwise, @@ -514,26 +507,4 @@ impl PostgresNode { "postgres" ) } - - // XXX: cache that in control plane - pub fn whoami(&self) -> String { - let output = Command::new("whoami") - .output() - .expect("failed to execute whoami"); - - assert!(output.status.success(), "whoami failed"); - - String::from_utf8(output.stdout).unwrap().trim().to_string() - } -} - -impl Drop for PostgresNode { - // destructor to clean up state after test is done - // XXX: we may detect failed test by setting some flag in catch_unwind() - // and checking it here. But let just clean datadirs on start. - fn drop(&mut self) { - if self.is_test { - let _ = self.stop(true); - } - } }