Skip to content

Commit 5773c65

Browse files
committed
CUBESTORE_S3_ENDPOINT
1 parent df8161c commit 5773c65

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

rust/cubestore/cubestore/src/config/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ pub enum FileStoreProvider {
343343
region: String,
344344
bucket_name: String,
345345
sub_path: Option<String>,
346+
endpoint: Option<String>,
346347
},
347348
GCS {
348349
bucket_name: String,
@@ -1303,6 +1304,7 @@ impl Config {
13031304
"CUBESTORE_S3_REGION required when CUBESTORE_S3_BUCKET is set",
13041305
),
13051306
sub_path: env::var("CUBESTORE_S3_SUB_PATH").ok(),
1307+
endpoint: env::var("CUBESTORE_S3_ENDPOINT").ok(),
13061308
}
13071309
} else if let Ok(bucket_name) = env::var("CUBESTORE_MINIO_BUCKET") {
13081310
FileStoreProvider::MINIO {
@@ -1946,15 +1948,18 @@ impl Config {
19461948
region,
19471949
bucket_name,
19481950
sub_path,
1951+
endpoint,
19491952
} => {
19501953
let data_dir = self.config_obj.data_dir.clone();
19511954
let region = region.to_string();
19521955
let bucket_name = bucket_name.to_string();
19531956
let sub_path = sub_path.clone();
1957+
let endpoint = endpoint.clone();
19541958
self.injector
19551959
.register("original_remote_fs", async move |_| {
19561960
let arc: Arc<dyn DIService> =
1957-
S3RemoteFs::new(data_dir, region, bucket_name, sub_path).unwrap();
1961+
S3RemoteFs::new(data_dir, region, bucket_name, sub_path, endpoint)
1962+
.unwrap();
19581963
arc
19591964
})
19601965
.await;

rust/cubestore/cubestore/src/remotefs/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ mod tests {
687687
region.clone(),
688688
bucket_name.clone(),
689689
None,
690+
None,
690691
)?;
691692

692693
let name_maker = NameMaker::new(Uuid::new_v4().to_string());
@@ -699,6 +700,7 @@ mod tests {
699700
region.clone(),
700701
bucket_name.clone(),
701702
Some("remotefs_test_subpathdir".to_string()),
703+
None,
702704
)
703705
.unwrap();
704706

rust/cubestore/cubestore/src/remotefs/s3.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl S3RemoteFs {
4949
region: String,
5050
bucket_name: String,
5151
sub_path: Option<String>,
52+
endpoint: Option<String>,
5253
) -> Result<Arc<Self>, CubeError> {
5354
// Incorrect naming for ENV variables...
5455
let access_key = env::var("CUBESTORE_AWS_ACCESS_KEY_ID").ok();
@@ -67,13 +68,21 @@ impl S3RemoteFs {
6768
err.to_string()
6869
))
6970
})?;
70-
let region = region.parse::<Region>().map_err(|err| {
71-
CubeError::internal(format!(
72-
"Failed to parse Region '{}': {}",
73-
region,
74-
err.to_string()
75-
))
76-
})?;
71+
// If endpoint is provided, create a Custom region to support GovCloud and other non-standard regions
72+
let region = if let Some(ep) = &endpoint {
73+
Region::Custom {
74+
region: region.clone(),
75+
endpoint: ep.clone(),
76+
}
77+
} else {
78+
region.parse::<Region>().map_err(|err| {
79+
CubeError::internal(format!(
80+
"Failed to parse Region '{}': {}",
81+
region,
82+
err.to_string()
83+
))
84+
})?
85+
};
7786
let bucket = Bucket::new(&bucket_name, region.clone(), credentials)?;
7887
let fs = Arc::new(Self {
7988
dir,

rust/cubestore/cubestore/src/sql/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,6 +3501,7 @@ mod tests {
35013501
region: "us-west-2".to_string(),
35023502
bucket_name: "cube-store-ci-test".to_string(),
35033503
sub_path: Some("high_frequency_inserts_s3".to_string()),
3504+
endpoint: None,
35043505
};
35053506
c.select_workers = vec!["127.0.0.1:4306".to_string()];
35063507
c
@@ -3516,6 +3517,7 @@ mod tests {
35163517
region: "us-west-2".to_string(),
35173518
bucket_name: "cube-store-ci-test".to_string(),
35183519
sub_path: Some("high_frequency_inserts_s3".to_string()),
3520+
endpoint: None,
35193521
};
35203522
c
35213523
})
@@ -3989,6 +3991,7 @@ mod tests {
39893991
region: "us-west-2".to_string(),
39903992
bucket_name: "cube-store-ci-test".to_string(),
39913993
sub_path: Some("create_table_with_location_cluster".to_string()),
3994+
endpoint: None,
39923995
};
39933996
c.select_workers = vec!["127.0.0.1:24306".to_string()];
39943997
c.metastore_bind_address = Some("127.0.0.1:25312".to_string());
@@ -4005,6 +4008,7 @@ mod tests {
40054008
region: "us-west-2".to_string(),
40064009
bucket_name: "cube-store-ci-test".to_string(),
40074010
sub_path: Some("create_table_with_location_cluster".to_string()),
4011+
endpoint: None,
40084012
};
40094013
c.metastore_remote_address = Some("127.0.0.1:25312".to_string());
40104014
c

0 commit comments

Comments
 (0)