Fix shared_preload_libraries parsing.

Don't try to download already existing shared_preload_libraries files
This commit is contained in:
Anastasia Lubennikova
2023-06-28 18:15:56 +03:00
parent 2089d02f94
commit 0875c2284c
2 changed files with 49 additions and 12 deletions

View File

@@ -688,24 +688,48 @@ LIMIT 100",
// 2. parse shared_preload_libraries from spec
let mut libs_vec = Vec::new();
info!("shared_preload_libraries is set to {:?}", libs_vec);
if let Some(libs) = spec.cluster.settings.find("shared_preload_libraries") {
libs_vec = libs
.split(',')
.filter(|s| *s != "neon")
.split(&[',', '\'', ' '])
.filter(|s| *s != "neon" && !s.is_empty())
.map(str::to_string)
.collect();
}
// TODO write a proper test for this
// Currently pytest doesn't pass cluster settings to compute_ctl
// We need to add this to pytest.
// and neon_local pass to spec
// info!(
// "shared_preload_libraries extra settings set to {:?}",
// libs_vec
// );
info!(
"shared_preload_libraries parsed from spec.cluster.settings: {:?}",
libs_vec
);
// also parse shared_preload_libraries from provided postgresql.conf
// that is used in neon_local and python tests
if let Some(conf) = &spec.cluster.postgresql_conf {
let conf_lines = conf.split('\n').collect::<Vec<&str>>();
let mut shared_preload_libraries_line = "";
for line in conf_lines {
if line.starts_with("shared_preload_libraries") {
shared_preload_libraries_line = line;
}
}
let mut preload_libs_vec = Vec::new();
if let Some(libs) = shared_preload_libraries_line.split("='").nth(1) {
preload_libs_vec = libs
.split(&[',', '\'', ' '])
.filter(|s| *s != "neon" && !s.is_empty())
.map(str::to_string)
.collect();
}
info!(
"shared_preload_libraries parsed from spec.cluster.postgresql_conf: {:?}",
preload_libs_vec
);
libs_vec.extend(preload_libs_vec.clone());
}
// download extension control files & shared_preload_libraries

View File

@@ -66,6 +66,11 @@ async fn download_helper(
None => download_location.join(remote_from_path.object_name().expect("bad object")),
};
if local_path.exists() {
info!("File {:?} already exists. Skipping download", &local_path);
return Ok(());
}
info!(
"Downloading {:?} to location {:?}",
&remote_from_path, &local_path
@@ -171,11 +176,19 @@ pub async fn get_available_libraries(
// add file extension if it isn't in the filename
let lib_name_with_ext = enforce_so_end(&lib_name);
info!("looking for library {:?}", &lib_name_with_ext);
match all_available_libraries.get(&*lib_name_with_ext) {
Some(remote_path) => {
download_helper(remote_storage, remote_path, None, &local_libdir).await?
}
None => bail!("Shared library file {lib_name} is not found in the extension store"),
None => {
let file_path = local_libdir.join(&lib_name_with_ext);
if file_path.exists() {
info!("File {:?} already exists. Skipping download", &file_path);
} else {
bail!("Shared library file {lib_name} is not found in the extension store")
}
}
}
}