mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-27 01:50:38 +00:00
made remote_ext_config an optional parameter
This commit is contained in:
@@ -65,10 +65,11 @@ fn main() -> Result<()> {
|
||||
let pgbin_default = String::from("postgres");
|
||||
let pgbin = matches.get_one::<String>("pgbin").unwrap_or(&pgbin_default);
|
||||
|
||||
let remote_ext_config = matches
|
||||
.get_one::<String>("remote-ext-config")
|
||||
.expect("remote-extension-config is required");
|
||||
let remote_storage = init_remote_storage(remote_ext_config)?;
|
||||
let remote_ext_config = matches.get_one::<String>("remote-ext-config");
|
||||
let 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();
|
||||
|
||||
@@ -48,7 +48,7 @@ pub struct ComputeNode {
|
||||
/// `Condvar` to allow notifying waiters about state changes.
|
||||
pub state_changed: Condvar,
|
||||
/// S3 extensions configuration variables (JSON)
|
||||
pub remote_storage: GenericRemoteStorage,
|
||||
pub remote_storage: Option<GenericRemoteStorage>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -65,10 +65,15 @@ pub enum ExtensionType {
|
||||
}
|
||||
|
||||
pub async fn download_extension(
|
||||
remote_storage: &GenericRemoteStorage,
|
||||
remote_storage: &Option<GenericRemoteStorage>,
|
||||
ext_type: ExtensionType,
|
||||
pgbin: &str,
|
||||
) -> anyhow::Result<()> {
|
||||
let remote_storage = match remote_storage {
|
||||
Some(remote_storage) => remote_storage,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
let mut remote_sharedir = get_pg_config("--sharedir", pgbin);
|
||||
remote_sharedir.push_str("/extension");
|
||||
// let remote_sharedir = get_pg_config("--libdir", pgbin);
|
||||
|
||||
@@ -657,9 +657,7 @@ fn handle_endpoint(ep_match: &ArgMatches, env: &local_env::LocalEnv) -> Result<(
|
||||
.get_one::<String>("endpoint_id")
|
||||
.ok_or_else(|| anyhow!("No endpoint ID was provided to start"))?;
|
||||
|
||||
let remote_ext_config = sub_args
|
||||
.get_one::<String>("remote-ext-config")
|
||||
.context("remote_ext_config is not an optional parameter")?;
|
||||
let remote_ext_config = sub_args.get_one::<String>("remote-ext-config");
|
||||
|
||||
// If --safekeepers argument is given, use only the listed safekeeper nodes.
|
||||
let safekeepers =
|
||||
@@ -1010,7 +1008,7 @@ fn cli() -> Command {
|
||||
.long("remote-ext-config")
|
||||
.num_args(1)
|
||||
.help("Configure the S3 bucket that we search for extensions in.")
|
||||
.required(true);
|
||||
.required(false);
|
||||
|
||||
let lsn_arg = Arg::new("lsn")
|
||||
.long("lsn")
|
||||
|
||||
@@ -412,7 +412,7 @@ impl Endpoint {
|
||||
&self,
|
||||
auth_token: &Option<String>,
|
||||
safekeepers: Vec<NodeId>,
|
||||
remote_ext_config: &str,
|
||||
remote_ext_config: Option<&String>,
|
||||
) -> Result<()> {
|
||||
if self.status() == "running" {
|
||||
anyhow::bail!("The endpoint is already running");
|
||||
@@ -496,7 +496,6 @@ impl Endpoint {
|
||||
|
||||
let mut cmd = Command::new(self.env.neon_distrib_dir.join("compute_ctl"));
|
||||
cmd.args(["--http-port", &self.http_address.port().to_string()])
|
||||
.args(["--remote-ext-config", remote_ext_config])
|
||||
.args(["--pgdata", self.pgdata().to_str().unwrap()])
|
||||
.args(["--connstr", &self.connstr()])
|
||||
.args([
|
||||
@@ -514,6 +513,9 @@ impl Endpoint {
|
||||
.stdin(std::process::Stdio::null())
|
||||
.stderr(logfile.try_clone()?)
|
||||
.stdout(logfile);
|
||||
if let Some(remote_ext_config) = remote_ext_config {
|
||||
cmd.args(["--remote-ext-config", remote_ext_config]);
|
||||
}
|
||||
let _child = cmd.spawn()?;
|
||||
|
||||
// Wait for it to start
|
||||
|
||||
@@ -2353,7 +2353,6 @@ class Endpoint(PgProtocol):
|
||||
hot_standby: bool = False,
|
||||
lsn: Optional[Lsn] = None,
|
||||
config_lines: Optional[List[str]] = None,
|
||||
remote_ext_config: Optional[str] = None,
|
||||
) -> "Endpoint":
|
||||
"""
|
||||
Create a new Postgres endpoint.
|
||||
@@ -2406,7 +2405,6 @@ class Endpoint(PgProtocol):
|
||||
http_port=self.http_port,
|
||||
tenant_id=self.tenant_id,
|
||||
safekeepers=self.active_safekeepers,
|
||||
# TODO it's either start or create, not both that starts compute_ctl
|
||||
remote_ext_config=remote_ext_config,
|
||||
)
|
||||
self.running = True
|
||||
@@ -2512,7 +2510,6 @@ class Endpoint(PgProtocol):
|
||||
config_lines=config_lines,
|
||||
hot_standby=hot_standby,
|
||||
lsn=lsn,
|
||||
remote_ext_config=remote_ext_config,
|
||||
).start(remote_ext_config=remote_ext_config)
|
||||
|
||||
log.info(f"Postgres startup took {time.time() - started_at} seconds")
|
||||
|
||||
Reference in New Issue
Block a user