feat(tiering): add Wasabi lifecycle target support (#5057)

This commit is contained in:
cxymds
2026-07-21 00:11:53 +08:00
committed by GitHub
parent 302dd42d38
commit 4f133eb95f
13 changed files with 2195 additions and 118 deletions
+25
View File
@@ -79,6 +79,14 @@ pub struct AddTierQuery {
pub struct AddTier {}
fn wasabi_payload_name(config: &TierConfig) -> S3Result<String> {
config
.wasabi
.as_ref()
.map(|wasabi| wasabi.name.clone())
.ok_or_else(|| S3Error::with_message(S3ErrorCode::InvalidRequest, "missing Wasabi configuration"))
}
fn spawn_transition_tier_config_propagation(action: &'static str) {
if let Some(notification_sys) = current_notification_system() {
spawn_traced(async move {
@@ -271,6 +279,9 @@ impl Operation for AddTier {
.ok_or_else(|| S3Error::with_message(S3ErrorCode::InvalidRequest, "missing S3 configuration"))?
.name;
}
TierType::Wasabi => {
args.name = wasabi_payload_name(&args)?;
}
TierType::RustFS => {
args.name = args
.rustfs
@@ -944,6 +955,20 @@ mod tests {
use http::Uri;
use matchit::Router;
#[test]
fn wasabi_payload_name_requires_nested_configuration() {
let config: TierConfig = serde_json::from_slice(
br#"{"type":"wasabi","wasabi":{"name":"WASABI-FIRST","accessKey":"ak","secretKey":"sk","bucket":"archive","region":"us-east-1"}}"#,
)
.expect("Wasabi AddTier payload should decode");
assert_eq!(wasabi_payload_name(&config).expect("Wasabi payload name should exist"), "WASABI-FIRST");
let missing: TierConfig = serde_json::from_slice(br#"{"type":"wasabi"}"#).expect("type-only payload should decode");
let err = wasabi_payload_name(&missing).expect_err("missing Wasabi payload must fail at the AddTier boundary");
assert_eq!(err.code(), &S3ErrorCode::InvalidRequest);
assert_eq!(err.message(), Some("missing Wasabi configuration"));
}
#[test]
fn resolve_tier_name_prefers_path_parameter() {
let uri: Uri = "/rustfs/admin/v3/tier/HOT?tier=COLD".parse().expect("uri should parse");