From 9c35c06c58d42f97b80d979688d19d9efbf56f0c Mon Sep 17 00:00:00 2001 From: Alek Westover Date: Thu, 22 Jun 2023 14:24:59 -0400 Subject: [PATCH] small refactor --- compute_tools/src/bin/compute_ctl.rs | 6 +- compute_tools/src/compute.rs | 4 +- compute_tools/src/http/api.rs | 55 +------------------ control_plane/src/endpoint.rs | 1 - .../regress/test_download_extensions.py | 4 ++ 5 files changed, 10 insertions(+), 60 deletions(-) diff --git a/compute_tools/src/bin/compute_ctl.rs b/compute_tools/src/bin/compute_ctl.rs index 1206b6e007..708aab4a56 100644 --- a/compute_tools/src/bin/compute_ctl.rs +++ b/compute_tools/src/bin/compute_ctl.rs @@ -71,13 +71,13 @@ fn main() -> Result<()> { let pgbin = matches.get_one::("pgbin").unwrap_or(&pgbin_default); let remote_ext_config = matches.get_one::("remote-ext-config"); - let remote_storage = match remote_ext_config { + let ext_remote_storage = match remote_ext_config { Some(x) => Some(init_remote_storage(x)?), None => None, }; let rt = Runtime::new().unwrap(); - let copy_remote_storage = remote_storage.clone(); + let copy_remote_storage = ext_remote_storage.clone(); rt.block_on(async move { download_extension(©_remote_storage, ExtensionType::Shared, pgbin) .await @@ -198,7 +198,7 @@ fn main() -> Result<()> { live_config_allowed, state: Mutex::new(new_state), state_changed: Condvar::new(), - remote_storage, + ext_remote_storage, }; let compute = Arc::new(compute_node); diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index 63fafa510d..8cf030f722 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -47,8 +47,8 @@ pub struct ComputeNode { pub state: Mutex, /// `Condvar` to allow notifying waiters about state changes. pub state_changed: Condvar, - /// S3 extensions configuration variables (JSON) - pub remote_storage: Option, + /// S3 extensions configuration variables + pub ext_remote_storage: Option, } #[derive(Clone, Debug)] diff --git a/compute_tools/src/http/api.rs b/compute_tools/src/http/api.rs index 0f8a95af42..053d39b5cd 100644 --- a/compute_tools/src/http/api.rs +++ b/compute_tools/src/http/api.rs @@ -135,7 +135,7 @@ async fn routes(req: Request, compute: &Arc) -> Response, compute: &Arc) -> Response anyhow::Result<()> { -// info!("requested file {}", filename); - -// let from_prefix: &str = "/tmp"; //debug only -// let to_prefix = "/home/anastasia/work/neon/pg_install/v15/"; - -// if filename.ends_with(".so") { -// info!("requested file is a shared object file {}", filename); - -// let from_path = Path::new(from_prefix).join("lib").join(filename); -// let to_path = Path::new(to_prefix).join("lib/postgresql/").join(filename); - -// info!( -// "copying file {} from {} to {}", -// filename, -// from_path.display(), -// to_path.display() -// ); - -// fs::copy(from_path, to_path)?; -// } else { -// info!("requested all extension files with prefix {}", filename); - -// let from_path = Path::new(from_prefix).join("share/extension/"); -// let to_path = Path::new(to_prefix).join("share/postgresql/extension/"); - -// info!( -// "copying files from {} to {}", -// from_path.display(), -// to_path.display() -// ); - -// for file in fs::read_dir(from_path.clone()).unwrap().flatten() { -// let fname = file.file_name().into_string().unwrap(); - -// if fname.starts_with(filename) && fname.ends_with(".sql") { -// info!( -// "copying file {} from {} to {}", -// fname, -// from_path.display(), -// to_path.display() -// ); - -// fs::copy(file.path(), to_path.join(fname))?; -// } -// } -// } - -// Ok(()) -// } - async fn handle_configure_request( req: Request, compute: &Arc, diff --git a/control_plane/src/endpoint.rs b/control_plane/src/endpoint.rs index 71014984df..dbecc05360 100644 --- a/control_plane/src/endpoint.rs +++ b/control_plane/src/endpoint.rs @@ -493,7 +493,6 @@ impl Endpoint { // Launch compute_ctl println!("Starting postgres node at '{}'", self.connstr()); - let mut cmd = Command::new(self.env.neon_distrib_dir.join("compute_ctl")); cmd.args(["--http-port", &self.http_address.port().to_string()]) .args(["--pgdata", self.pgdata().to_str().unwrap()]) diff --git a/test_runner/regress/test_download_extensions.py b/test_runner/regress/test_download_extensions.py index b1b4621404..8764e16fc9 100644 --- a/test_runner/regress/test_download_extensions.py +++ b/test_runner/regress/test_download_extensions.py @@ -87,3 +87,7 @@ relocatable = true all_extensions = [x[0] for x in cur.fetchall()] log.info(all_extensions) assert "test_ext" in all_extensions + + # TODO: we shouldn't need these... + endpoint.stop() + env.pageserver.http_client().tenant_detach(tenant)