Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions rust/cubestore/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ pub enum FileStoreProvider {
},
S3 {
region: String,
endpoint: Option<String>,
bucket_name: String,
path_style: bool,
sub_path: Option<String>,
},
GCS {
Expand Down Expand Up @@ -408,8 +410,10 @@ impl Config {
store_provider: {
if let Ok(bucket_name) = env::var("CUBESTORE_S3_BUCKET") {
FileStoreProvider::S3 {
bucket_name,
bucket_name: bucket_name,
region: env::var("CUBESTORE_S3_REGION").unwrap(),
endpoint: env::var("CUBESTORE_S3_ENDPOINT").ok(),
path_style: env_bool("CUBESTORE_S3_PATH_STYLE", false),
sub_path: env::var("CUBESTORE_S3_SUB_PATH").ok(),
}
} else if let Ok(bucket_name) = env::var("CUBESTORE_GCS_BUCKET") {
Expand Down Expand Up @@ -643,17 +647,28 @@ impl Config {
}
FileStoreProvider::S3 {
region,
endpoint,
bucket_name,
path_style,
sub_path,
} => {
let data_dir = self.config_obj.data_dir.clone();
let region = region.to_string();
let bucket_name = bucket_name.to_string();
let endpoint = endpoint.clone();
let path_style = path_style.clone();
let sub_path = sub_path.clone();
self.injector
.register("original_remote_fs", async move |_| {
let arc: Arc<dyn DIService> =
S3RemoteFs::new(data_dir, region, bucket_name, sub_path).unwrap();
let arc: Arc<dyn DIService> = S3RemoteFs::new(
data_dir,
region,
path_style,
endpoint,
bucket_name,
sub_path,
)
.unwrap();
arc
})
.await;
Expand Down
17 changes: 15 additions & 2 deletions rust/cubestore/src/remotefs/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use chrono::{DateTime, Utc};
use log::{debug, info};
use regex::{NoExpand, Regex};
use s3::creds::Credentials;
use s3::Bucket;
use s3::{Bucket, Region};
use std::env;
use std::io::Write;
use std::path::{Path, PathBuf};
Expand All @@ -29,6 +29,8 @@ impl S3RemoteFs {
pub fn new(
dir: PathBuf,
region: String,
path_style: bool,
endpoint: Option<String>,
bucket_name: String,
sub_path: Option<String>,
) -> Result<Arc<Self>, CubeError> {
Expand All @@ -39,7 +41,18 @@ impl S3RemoteFs {
None,
None,
)?;
let bucket = Bucket::new(&bucket_name, region.parse()?, credentials)?;
let bucket = if path_style == true {
Bucket::new_with_path_style(
&bucket_name,
Region::Custom {
endpoint: endpoint.unwrap(),
region,
},
credentials,
)?
} else {
Bucket::new(&bucket_name, region.parse()?, credentials)?
};
Ok(Arc::new(Self {
dir,
bucket,
Expand Down
8 changes: 8 additions & 0 deletions rust/cubestore/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,8 @@ mod tests {
c.compaction_chunks_count_threshold = 100;
c.store_provider = FileStoreProvider::S3 {
region: "us-west-2".to_string(),
endpoint: None,
path_style: false,
bucket_name: "cube-store-ci-test".to_string(),
sub_path: Some("high_frequency_inserts_s3".to_string()),
};
Expand All @@ -1256,6 +1258,8 @@ mod tests {
c.server_name = "127.0.0.1:4306".to_string();
c.store_provider = FileStoreProvider::S3 {
region: "us-west-2".to_string(),
endpoint: None,
path_style: false,
bucket_name: "cube-store-ci-test".to_string(),
sub_path: Some("high_frequency_inserts_s3".to_string()),
};
Expand Down Expand Up @@ -1558,6 +1562,8 @@ mod tests {
c.compaction_chunks_count_threshold = 100;
c.store_provider = FileStoreProvider::S3 {
region: "us-west-2".to_string(),
path_style:false,
endpoint:None,
bucket_name: "cube-store-ci-test".to_string(),
sub_path: Some("create_table_with_location_cluster".to_string()),
};
Expand All @@ -1574,6 +1580,8 @@ mod tests {
c.server_name = "127.0.0.1:24306".to_string();
c.store_provider = FileStoreProvider::S3 {
region: "us-west-2".to_string(),
endpoint:None,
path_style:false,
bucket_name: "cube-store-ci-test".to_string(),
sub_path: Some("create_table_with_location_cluster".to_string()),
};
Expand Down