Skip to content

Commit 714dc40

Browse files
committed
feat: Handle s3 region
1 parent 3717ec3 commit 714dc40

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

rust/operator-binary/src/crd/logdir.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl S3LogDir {
182182
pub fn history_server_spark_config(&self) -> Result<BTreeMap<String, String>, Error> {
183183
let connection = &self.bucket.connection;
184184

185-
Ok(BTreeMap::from([
185+
let mut config = BTreeMap::from([
186186
("spark.history.fs.logDirectory".to_string(), self.url()),
187187
(
188188
"spark.hadoop.fs.s3a.endpoint".to_string(),
@@ -192,7 +192,16 @@ impl S3LogDir {
192192
"spark.hadoop.fs.s3a.path.style.access".to_string(),
193193
(connection.access_style == S3AccessStyle::Path).to_string(),
194194
),
195-
]))
195+
]);
196+
197+
if let Some(region_name) = connection.region.name() {
198+
config.insert(
199+
"spark.hadoop.fs.s3a.endpoint.region".to_string(),
200+
region_name.to_string(),
201+
);
202+
};
203+
204+
Ok(config)
196205
}
197206

198207
pub fn application_spark_config(&self) -> Result<BTreeMap<String, String>, Error> {
@@ -211,6 +220,12 @@ impl S3LogDir {
211220
format!("spark.hadoop.fs.s3a.bucket.{bucket_name}.path.style.access"),
212221
(connection.access_style == S3AccessStyle::Path).to_string(),
213222
);
223+
if let Some(region_name) = connection.region.name() {
224+
result.insert(
225+
format!("spark.hadoop.fs.s3a.bucket.{bucket_name}.region"),
226+
region_name.to_string(),
227+
);
228+
};
214229
if let Some(secret_dir) = self.credentials_mount_path() {
215230
// We don't use the credentials at all here but assume they are available
216231
result.insert(

rust/operator-binary/src/crd/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,11 @@ impl v1alpha1::SparkApplication {
565565
"--conf spark.hadoop.fs.s3a.path.style.access={}",
566566
s3conn.access_style == S3AccessStyle::Path
567567
));
568+
if let Some(region_name) = s3conn.region.name() {
569+
submit_cmd.push(format!(
570+
"--conf spark.hadoop.fs.s3a.endpoint.region=\"{region_name}\""
571+
));
572+
};
568573
if let Some(credentials) = &s3conn.credentials {
569574
let secret_class_name = credentials.secret_class.clone();
570575
let secret_dir = format!("{S3_SECRET_DIR_NAME}/{secret_class_name}");

0 commit comments

Comments
 (0)