diff --git a/control_plane/src/pageserver.rs b/control_plane/src/pageserver.rs index bbafc287f5..06ec942895 100644 --- a/control_plane/src/pageserver.rs +++ b/control_plane/src/pageserver.rs @@ -51,24 +51,17 @@ pub struct PageServerNode { impl PageServerNode { pub fn from_env(env: &LocalEnv, conf: &PageServerConf) -> PageServerNode { - let PageServerConf { - id: _, - listen_pg_addr, - listen_http_addr, - pg_auth_type: _, - http_auth_type, - } = conf; let (host, port) = - parse_host_port(&listen_pg_addr).expect("Unable to parse listen_pg_addr"); + parse_host_port(&conf.listen_pg_addr).expect("Unable to parse listen_pg_addr"); let port = port.unwrap_or(5432); Self { pg_connection_config: PgConnectionConfig::new_host_port(host, port), conf: conf.clone(), env: env.clone(), http_client: mgmt_api::Client::new( - format!("http://{}", listen_http_addr), + format!("http://{}", conf.listen_http_addr), { - match http_auth_type { + match conf.http_auth_type { AuthType::Trust => None, AuthType::NeonJWT => Some( env.generate_auth_token(&Claims::new(None, Scope::PageServerApi)) @@ -85,27 +78,18 @@ impl PageServerNode { /// /// These all end up on the command line of the `pageserver` binary. fn neon_local_overrides(&self, cli_overrides: &[&str]) -> Vec { + let id = format!("id={}", self.conf.id); // FIXME: the paths should be shell-escaped to handle paths with spaces, quotas etc. let pg_distrib_dir_param = format!( "pg_distrib_dir='{}'", self.env.pg_distrib_dir_raw().display() ); - let PageServerConf { - id, - listen_pg_addr, - listen_http_addr, - pg_auth_type, - http_auth_type, - } = &self.conf; + let http_auth_type_param = format!("http_auth_type='{}'", self.conf.http_auth_type); + let listen_http_addr_param = format!("listen_http_addr='{}'", self.conf.listen_http_addr); - let id = format!("id={}", id); - - let http_auth_type_param = format!("http_auth_type='{}'", http_auth_type); - let listen_http_addr_param = format!("listen_http_addr='{}'", listen_http_addr); - - let pg_auth_type_param = format!("pg_auth_type='{}'", pg_auth_type); - let listen_pg_addr_param = format!("listen_pg_addr='{}'", listen_pg_addr); + let pg_auth_type_param = format!("pg_auth_type='{}'", self.conf.pg_auth_type); + let listen_pg_addr_param = format!("listen_pg_addr='{}'", self.conf.listen_pg_addr); let broker_endpoint_param = format!("broker_endpoint='{}'", self.env.broker.client_url()); @@ -127,7 +111,7 @@ impl PageServerNode { // Storage controller uses the same auth as pageserver: if JWT is enabled // for us, we will also need it to talk to them. - if matches!(http_auth_type, AuthType::NeonJWT) { + if matches!(self.conf.http_auth_type, AuthType::NeonJWT) { let jwt_token = self .env .generate_auth_token(&Claims::new(None, Scope::GenerationsApi)) @@ -145,7 +129,8 @@ impl PageServerNode { )); } - if *http_auth_type != AuthType::Trust || *pg_auth_type != AuthType::Trust { + if self.conf.http_auth_type != AuthType::Trust || self.conf.pg_auth_type != AuthType::Trust + { // Keys are generated in the toplevel repo dir, pageservers' workdirs // are one level below that, so refer to keys with ../ overrides.push("auth_validation_public_key_path='../auth_public_key.pem'".to_owned()); diff --git a/control_plane/src/storage_controller.rs b/control_plane/src/storage_controller.rs index 0f61d8b406..c505e67770 100644 --- a/control_plane/src/storage_controller.rs +++ b/control_plane/src/storage_controller.rs @@ -1,7 +1,4 @@ -use crate::{ - background_process, - local_env::{LocalEnv, PageServerConf}, -}; +use crate::{background_process, local_env::LocalEnv}; use camino::{Utf8Path, Utf8PathBuf}; use hyper::Method; use pageserver_api::{