Skip to content

Commit b73b446

Browse files
refactor(storage/opendal): remove OSS native backend, route through S3 only
1 parent d849e4d commit b73b446

3 files changed

Lines changed: 2 additions & 161 deletions

File tree

crates/storage/opendal/src/lib.rs

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,8 @@ cfg_if! {
7373
}
7474
}
7575

76-
cfg_if! {
77-
if #[cfg(feature = "opendal-oss")] {
78-
mod oss;
79-
use opendal::services::OssConfig;
80-
use oss::*;
81-
}
82-
}
76+
// When `opendal-oss` is enabled, `oss://` URLs are routed through the S3
77+
// backend (OSS is S3-API-compatible). No native OSS module is needed.
8378

8479
cfg_if! {
8580
if #[cfg(feature = "opendal-s3")] {
@@ -151,10 +146,6 @@ impl StorageFactory for OpenDalStorageFactory {
151146
config: s3_config_parse(config.props().clone())?.into(),
152147
customized_credential_load: None,
153148
})),
154-
#[cfg(all(feature = "opendal-oss", not(feature = "opendal-s3")))]
155-
OpenDalStorageFactory::Oss => Ok(Arc::new(OpenDalStorage::Oss {
156-
config: oss_config_parse(config.props().clone())?.into(),
157-
})),
158149
#[cfg(feature = "opendal-azdls")]
159150
OpenDalStorageFactory::Azdls => Ok(Arc::new(OpenDalStorage::Azdls {
160151
config: azdls_config_parse(config.props().clone())?.into(),
@@ -208,12 +199,6 @@ pub enum OpenDalStorage {
208199
/// GCS configuration.
209200
config: Arc<GcsConfig>,
210201
},
211-
/// OSS storage variant.
212-
#[cfg(feature = "opendal-oss")]
213-
Oss {
214-
/// OSS configuration.
215-
config: Arc<OssConfig>,
216-
},
217202
/// Azure Data Lake Storage variant.
218203
///
219204
/// Accepts paths of the form
@@ -303,19 +288,6 @@ impl OpenDalStorage {
303288
));
304289
}
305290
}
306-
#[cfg(feature = "opendal-oss")]
307-
OpenDalStorage::Oss { config } => {
308-
let op = oss_config_build(config, path)?;
309-
let prefix = format!("oss://{}/", op.info().name());
310-
if path.starts_with(&prefix) {
311-
(op, &path[prefix.len()..])
312-
} else {
313-
return Err(Error::new(
314-
ErrorKind::DataInvalid,
315-
format!("Invalid oss url: {path}, should start with {prefix}"),
316-
));
317-
}
318-
}
319291
#[cfg(feature = "opendal-azdls")]
320292
OpenDalStorage::Azdls { config } => azdls_create_operator(path, config)?,
321293
#[cfg(all(
@@ -389,25 +361,6 @@ impl OpenDalStorage {
389361
))
390362
}
391363
}
392-
#[cfg(feature = "opendal-oss")]
393-
OpenDalStorage::Oss { .. } => {
394-
let url = url::Url::parse(path)?;
395-
let bucket = url.host_str().ok_or_else(|| {
396-
Error::new(
397-
ErrorKind::DataInvalid,
398-
format!("Invalid oss url: {path}, missing bucket"),
399-
)
400-
})?;
401-
let prefix = format!("oss://{}/", bucket);
402-
if path.starts_with(&prefix) {
403-
Ok(&path[prefix.len()..])
404-
} else {
405-
Err(Error::new(
406-
ErrorKind::DataInvalid,
407-
format!("Invalid oss url: {path}, should start with {prefix}"),
408-
))
409-
}
410-
}
411364
#[cfg(feature = "opendal-azdls")]
412365
OpenDalStorage::Azdls { config } => {
413366
let azure_path = path.parse::<AzureStoragePath>()?;
@@ -671,35 +624,6 @@ mod tests {
671624
);
672625
}
673626

674-
#[cfg(feature = "opendal-oss")]
675-
#[test]
676-
fn test_relativize_path_oss() {
677-
let storage = OpenDalStorage::Oss {
678-
config: Arc::new(OssConfig::default()),
679-
};
680-
681-
assert_eq!(
682-
storage
683-
.relativize_path("oss://my-bucket/path/to/file.parquet")
684-
.unwrap(),
685-
"path/to/file.parquet"
686-
);
687-
}
688-
689-
#[cfg(feature = "opendal-oss")]
690-
#[test]
691-
fn test_relativize_path_oss_invalid_scheme() {
692-
let storage = OpenDalStorage::Oss {
693-
config: Arc::new(OssConfig::default()),
694-
};
695-
696-
assert!(
697-
storage
698-
.relativize_path("s3://my-bucket/path/to/file.parquet")
699-
.is_err()
700-
);
701-
}
702-
703627
#[cfg(feature = "opendal-azdls")]
704628
#[test]
705629
fn test_relativize_path_azdls() {

crates/storage/opendal/src/oss.rs

Lines changed: 0 additions & 63 deletions
This file was deleted.

crates/storage/opendal/src/resolving.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,6 @@ fn build_storage_for_scheme(
110110
customized_credential_load: customized_credential_load.clone(),
111111
})
112112
}
113-
// Fallback: builds without `opendal-s3` but with `opendal-oss`
114-
// still use the native OSS service (which consumes `oss.*` keys).
115-
#[cfg(all(feature = "opendal-oss", not(feature = "opendal-s3")))]
116-
"oss" => {
117-
let config = crate::oss::oss_config_parse(props.clone())?;
118-
Ok(OpenDalStorage::Oss {
119-
config: Arc::new(config),
120-
})
121-
}
122113
#[cfg(feature = "opendal-azdls")]
123114
"azdls" => {
124115
let config = crate::azdls::azdls_config_parse(props.clone())?;
@@ -420,15 +411,4 @@ mod tests {
420411
let cached = resolving.resolve("oss://my-bucket/other").unwrap();
421412
assert!(Arc::ptr_eq(&storage, &cached));
422413
}
423-
424-
#[cfg(all(feature = "opendal-oss", not(feature = "opendal-s3")))]
425-
#[test]
426-
fn oss_scheme_falls_back_to_native_oss_backend() {
427-
let props = HashMap::new();
428-
let storage = build_storage_for_scheme("oss", &props).unwrap();
429-
assert!(
430-
matches!(storage, OpenDalStorage::Oss { .. }),
431-
"Without opendal-s3, OSS should use the native OSS backend"
432-
);
433-
}
434414
}

0 commit comments

Comments
 (0)