mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-31 17:28:12 +00:00
fix(table-catalog): harden commit publication (#5779)
* fix(table-catalog): harden commit publication * fix(table-catalog): make commit replay deterministic * test(table-catalog): cover denied commit object reads * fix(table-catalog): guard ref commits and order publication locks * fix(table-catalog): close commit publication race gaps * fix(table-catalog): close publication review gaps * fix(table-catalog): isolate blocked strong publications * fix(table-catalog): scale and fence commit publication * fix(table-catalog): close publication compatibility gaps * fix(table-catalog): clarify compatibility cleanup marker * fix(table-catalog): repair publication hardening checks * fix(table-catalog): align commit tests with publication fences * fix(table-catalog): bind authorization to request context * refactor(table-catalog): reuse internal error mapping * test(storage): install request context for tag conditions --------- Co-authored-by: Henry Guo <marshawcoco@users.noreply.github.com> Co-authored-by: houseme <housemecn@gmail.com> Co-authored-by: Zhengchao An <anzhengchao@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ use crate::set_disk::get_lock_acquire_timeout;
|
||||
use crate::storage_api_contracts::bucket::{BUCKET_LIFECYCLE_LOCK_OBJECT, SRBucketDeleteOp};
|
||||
use crate::storage_api_contracts::namespace::NamespaceLocking as _;
|
||||
use futures::stream::{self, StreamExt};
|
||||
use rustfs_policy::policy::BucketPolicy;
|
||||
use std::collections::BTreeMap;
|
||||
use std::future::Future;
|
||||
|
||||
@@ -153,6 +154,31 @@ where
|
||||
}
|
||||
|
||||
impl ECStore {
|
||||
pub async fn get_bucket_metadata(&self, bucket: &str) -> Result<Arc<BucketMetadata>> {
|
||||
let sys = metadata_sys::require_bucket_metadata_sys_in(&self.ctx)?;
|
||||
sys.read().await.get(bucket).await
|
||||
}
|
||||
|
||||
pub async fn get_bucket_policy(&self, bucket: &str) -> Result<(BucketPolicy, OffsetDateTime)> {
|
||||
let sys = metadata_sys::require_bucket_metadata_sys_in(&self.ctx)?;
|
||||
sys.read().await.get_bucket_policy(bucket).await
|
||||
}
|
||||
|
||||
pub async fn get_bucket_policy_raw(&self, bucket: &str) -> Result<(String, OffsetDateTime)> {
|
||||
let sys = metadata_sys::require_bucket_metadata_sys_in(&self.ctx)?;
|
||||
sys.read().await.get_bucket_policy_raw(bucket).await
|
||||
}
|
||||
|
||||
pub async fn restricts_public_bucket_access(&self, bucket: &str) -> Result<bool> {
|
||||
let sys = metadata_sys::require_bucket_metadata_sys_in(&self.ctx)?;
|
||||
let (config, _) = sys.read().await.get_public_access_block_config(bucket).await?;
|
||||
Ok(config.restrict_public_buckets.unwrap_or(false))
|
||||
}
|
||||
|
||||
pub async fn update_bucket_metadata_config(&self, bucket: &str, config_file: &str, data: Vec<u8>) -> Result<OffsetDateTime> {
|
||||
metadata_sys::update_in(&self.ctx, bucket, config_file, data).await
|
||||
}
|
||||
|
||||
pub async fn bucket_incarnation_id(&self, bucket: &str) -> Result<Uuid> {
|
||||
metadata_sys::get_cached_bucket_incarnation_id_in(&self.ctx, bucket).await
|
||||
}
|
||||
@@ -1077,6 +1103,26 @@ mod tests {
|
||||
(temp_dir, ecstore)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn request_metadata_methods_fail_closed_before_instance_initialization() {
|
||||
let (_temp_dir, store) = setup_multi_pool_scanner_listing_test_env().await;
|
||||
|
||||
let expected = "bucket metadata sys not initialized for this instance";
|
||||
let errors = [
|
||||
store.get_bucket_metadata("bucket").await.unwrap_err(),
|
||||
store.get_bucket_policy("bucket").await.unwrap_err(),
|
||||
store.get_bucket_policy_raw("bucket").await.unwrap_err(),
|
||||
store.restricts_public_bucket_access("bucket").await.unwrap_err(),
|
||||
store
|
||||
.update_bucket_metadata_config("bucket", crate::bucket::metadata::BUCKET_POLICY_CONFIG, Vec::new())
|
||||
.await
|
||||
.unwrap_err(),
|
||||
];
|
||||
for error in errors {
|
||||
assert_eq!(error.to_string(), format!("Io error: {expected}"));
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_bucket_with_object(ecstore: &Arc<ECStore>, bucket: &str, object: &str) {
|
||||
let generation_before_make = ecstore.scanner_namespace_mutation_generation();
|
||||
ecstore
|
||||
|
||||
Reference in New Issue
Block a user