Fix/correctly handle terraform s3 backend with versioned bucket (#1686)

Co-authored-by: loverustfs <hello@rustfs.com>
This commit is contained in:
LeonWang0735
2026-02-02 12:43:07 +08:00
committed by GitHub
parent 00ccc19e27
commit ec4458f846
3 changed files with 56 additions and 4 deletions
@@ -395,4 +395,46 @@ mod tests {
info!("✅ PASSED: Veeam backup workflow simulation completed successfully");
}
#[tokio::test]
#[serial]
async fn test_terraform_put_after_delete() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
init_logging();
let mut env = RustFSTestEnvironment::new().await.expect("Failed to create test environment");
env.start_rustfs_server(vec![]).await.expect("Failed to start RustFS");
// Use a versioned bucket for this test
let bucket = "terraform";
let client = env.create_s3_client();
env.create_test_bucket(bucket).await?;
let key = "terraform.tfstate";
let response = client
.put_object()
.bucket(bucket)
.key(key)
.body(ByteStream::from(b"v1".to_vec()))
.send()
.await;
assert!(response.is_ok());
client.delete_object().bucket(bucket).key(key).send().await?;
let response = client
.put_object()
.bucket(bucket)
.key(key)
.body(ByteStream::from(b"v1".to_vec()))
.send()
.await;
assert!(response.is_ok());
let get_response = client.get_object().bucket(bucket).key(key).send().await;
assert!(get_response.is_ok(), "Object should exist after PUT");
Ok(())
}
}
+4
View File
@@ -3583,6 +3583,10 @@ impl SetDisks {
match oi {
Ok(oi) => {
// If top level is a delete marker proceed to upload.
if oi.delete_marker {
return None;
}
if should_prevent_write(&oi, http_preconditions.if_none_match, http_preconditions.if_match) {
return Some(StorageError::PreconditionFailed);
}