mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-16 04:52:36 +00:00
feat(gateway): serve bucket object lock configuration
Share the bucket Object Lock write between the legacy and gateway edges. Keep lock configuration and versioning as sequential writes against the authorized bucket incarnation, followed by peer reload, site replication and scanner invalidation.
Cover eight refusal or failure cases and three successful cases with durable metadata and signed requests. The two stacks run the same request cases and refusal matrix.
The mutation run detected both missing write fences, swallowed peer failure, propagated site failure, early or absent scanner invalidation, missing audit, wrong authorization action or resource, dropped request body and incorrect operation counting.
Validation used debug builds on d461908bf. The final lint pass elides an equivalent lifetime in a test helper. Peer and site failures were injected locally, with real multi-site delivery left unverified.
This commit is contained in:
@@ -14,14 +14,213 @@
|
||||
|
||||
//! Bucket Object Lock configuration use-case operations.
|
||||
//!
|
||||
//! NOT responsible for: the lock validators, which object writes share (`storage::ecfs_extend`).
|
||||
//! Default-retention policy here applies to bucket configuration. Object writes enforce their
|
||||
//! own retention rules.
|
||||
|
||||
use super::*;
|
||||
use rustfs_gateway_types::persistence::parse_object_lock_dto;
|
||||
use crate::app::storage_api::bucket_usecase::bucket::VersioningConfigExt as _;
|
||||
use crate::app::storage_api::bucket_usecase::bucket::metadata::OBJECT_LOCK_CONFIG;
|
||||
use rustfs_gateway_types::persistence::{PersistedDefaultRetention, parse_object_lock_dto};
|
||||
use rustfs_s3_types::{S3Error, S3ErrorCode, S3Result, s3_error};
|
||||
|
||||
const LOG_SUBSYSTEM_OBJECT_LOCK: &str = "object_lock";
|
||||
|
||||
const MAXIMUM_RETENTION_DAYS: i32 = 36_500;
|
||||
const MAXIMUM_RETENTION_YEARS: i32 = 100;
|
||||
|
||||
fn invalid_object_lock_configuration(message: impl Into<String>) -> S3Error {
|
||||
S3Error::with_message(S3ErrorCode::MalformedXML, message.into())
|
||||
}
|
||||
|
||||
fn propagate_object_lock_peer_reload(result: std::result::Result<(), StorageError>) -> S3Result<()> {
|
||||
result.map_err(|err| {
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("Failed to publish Object Lock metadata: {err}"))
|
||||
})
|
||||
}
|
||||
|
||||
fn invalid_retention_period(message: impl Into<String>) -> S3Error {
|
||||
let mut err = S3Error::with_message(S3ErrorCode::Custom("InvalidRetentionPeriod".into()), message.into());
|
||||
err.set_status_code(StatusCode::BAD_REQUEST);
|
||||
err
|
||||
}
|
||||
|
||||
fn validate_default_retention_configuration(default_retention: &PersistedDefaultRetention) -> S3Result<()> {
|
||||
let Some(mode) = default_retention.mode.as_deref() else {
|
||||
return Err(invalid_object_lock_configuration("retention mode must be specified"));
|
||||
};
|
||||
|
||||
match mode {
|
||||
"COMPLIANCE" | "GOVERNANCE" => {}
|
||||
_ => {
|
||||
return Err(invalid_object_lock_configuration(format!("unknown retention mode {mode}")));
|
||||
}
|
||||
}
|
||||
|
||||
match (default_retention.days, default_retention.years) {
|
||||
(Some(days), None) => {
|
||||
if days <= 0 {
|
||||
return Err(invalid_retention_period(
|
||||
"Default retention period must be a positive integer value for 'Days'",
|
||||
));
|
||||
}
|
||||
if days > MAXIMUM_RETENTION_DAYS {
|
||||
return Err(invalid_retention_period(format!("Default retention period too large for 'Days' {days}",)));
|
||||
}
|
||||
}
|
||||
(None, Some(years)) => {
|
||||
if years <= 0 {
|
||||
return Err(invalid_retention_period(
|
||||
"Default retention period must be a positive integer value for 'Years'",
|
||||
));
|
||||
}
|
||||
if years > MAXIMUM_RETENTION_YEARS {
|
||||
return Err(invalid_retention_period(format!(
|
||||
"Default retention period too large for 'Years' {years}",
|
||||
)));
|
||||
}
|
||||
}
|
||||
(Some(_), Some(_)) => {
|
||||
return Err(invalid_object_lock_configuration("either Days or Years must be specified, not both"));
|
||||
}
|
||||
(None, None) => {
|
||||
return Err(invalid_object_lock_configuration("either Days or Years must be specified"));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_object_lock_configuration_input(input_cfg: &ObjectLockConfiguration) -> S3Result<()> {
|
||||
let enabled = input_cfg.object_lock_enabled.as_deref();
|
||||
if enabled != Some("Enabled") {
|
||||
return Err(invalid_object_lock_configuration(
|
||||
"only 'Enabled' value is allowed to ObjectLockEnabled element",
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(rule) = input_cfg.rule.as_ref() {
|
||||
let Some(default_retention) = rule.default_retention.as_ref() else {
|
||||
return Err(invalid_object_lock_configuration("Rule must include DefaultRetention"));
|
||||
};
|
||||
validate_default_retention_configuration(default_retention)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl DefaultBucketUsecase {
|
||||
/// Persists the lock configuration, then enables versioning under the same authorization.
|
||||
///
|
||||
/// Each write is fenced independently. A versioning write or peer reload can fail after
|
||||
/// the lock configuration is durable.
|
||||
pub(crate) async fn execute_put_object_lock_configuration(
|
||||
&self,
|
||||
envelope: RequestEnvelope,
|
||||
bucket: &str,
|
||||
config: Option<ObjectLockConfiguration>,
|
||||
) -> S3Result<()> {
|
||||
RequestEnvelope::audit_only_operation(envelope, S3Operation::PutObjectLockConfiguration, StatusCode::OK, |envelope| {
|
||||
self.put_object_lock_configuration(envelope, bucket, config)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn put_object_lock_configuration(
|
||||
&self,
|
||||
envelope: RequestEnvelope,
|
||||
bucket: &str,
|
||||
config: Option<ObjectLockConfiguration>,
|
||||
) -> S3Result<()> {
|
||||
let expected_incarnation_id = bucket_config_mutation_incarnation(&envelope, bucket)?;
|
||||
let Some(config) = config else {
|
||||
return Err(s3_error!(InvalidArgument, "Invalid argument."));
|
||||
};
|
||||
self.ensure_config_bucket(bucket).await?;
|
||||
validate_object_lock_configuration_input(&config)?;
|
||||
|
||||
match metadata_sys::get_object_lock_config(bucket).await {
|
||||
Ok(_) => {}
|
||||
Err(StorageError::ConfigNotFound) => {
|
||||
if !BucketVersioningSys::enabled(bucket).await {
|
||||
return Err(s3_error!(
|
||||
InvalidBucketState,
|
||||
"Object Lock configuration cannot be enabled on existing buckets"
|
||||
));
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(
|
||||
component = LOG_COMPONENT_APP,
|
||||
subsystem = LOG_SUBSYSTEM_OBJECT_LOCK,
|
||||
event = "object_lock_config_load_failed",
|
||||
bucket = %bucket,
|
||||
error = ?err,
|
||||
"Failed to load bucket object lock configuration"
|
||||
);
|
||||
return Err(s3_error!(InternalError, "Failed to get bucket ObjectLockConfiguration"));
|
||||
}
|
||||
};
|
||||
|
||||
let data = serialize_config(&config)?;
|
||||
let object_lock_config = String::from_utf8(data.clone()).map_err(to_internal_error)?;
|
||||
let updated_at = update_bucket_config_for_incarnation(bucket, OBJECT_LOCK_CONFIG, data, expected_incarnation_id)
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
|
||||
#[cfg(test)]
|
||||
tests::after_lock_write(bucket).await;
|
||||
|
||||
// Versioning is a separate write and must stay fenced to the original incarnation.
|
||||
let versioning_config = BucketVersioningSys::get(bucket).await.map_err(ApiError::from)?;
|
||||
if !versioning_config.enabled() {
|
||||
let versioning_config = PersistedVersioningConfiguration {
|
||||
status: Some("Enabled".to_owned()),
|
||||
..Default::default()
|
||||
};
|
||||
let data = serialize_config(&versioning_config)?;
|
||||
update_bucket_config_for_incarnation(bucket, BUCKET_VERSIONING_CONFIG, data, expected_incarnation_id)
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
}
|
||||
|
||||
let peer_reload = match current_notification_system_for_context(self.context.as_deref()) {
|
||||
Some(notification_sys) => notification_sys.load_bucket_metadata(bucket).await,
|
||||
None => Ok(()),
|
||||
};
|
||||
#[cfg(test)]
|
||||
let peer_reload = peer_reload.and(tests::peer_reload_outcome(bucket).await);
|
||||
propagate_object_lock_peer_reload(peer_reload)?;
|
||||
|
||||
let site_result = site_replication_bucket_meta_hook(SRBucketMeta {
|
||||
bucket: bucket.to_owned(),
|
||||
r#type: "object-lock-config".to_owned(),
|
||||
object_lock_config: Some(object_lock_config),
|
||||
updated_at: Some(updated_at),
|
||||
api_version: Some(SITE_REPL_API_VERSION.to_owned()),
|
||||
..Default::default()
|
||||
})
|
||||
.await;
|
||||
#[cfg(test)]
|
||||
let site_result = site_result.and_then(|()| tests::site_hook_outcome());
|
||||
if let Err(err) = site_result {
|
||||
warn!(
|
||||
component = LOG_COMPONENT_APP,
|
||||
subsystem = LOG_SUBSYSTEM_OBJECT_LOCK,
|
||||
event = "put_object_lock_configuration",
|
||||
bucket = %bucket,
|
||||
result = "site_replication_hook_failed",
|
||||
error = ?err,
|
||||
"storage object lock state"
|
||||
);
|
||||
}
|
||||
|
||||
rustfs_scanner::record_dirty_usage_bucket_from_producer(
|
||||
bucket,
|
||||
rustfs_scanner::SegmentInvalidationProducerIdentity::BucketMetadata,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The stored Object Lock configuration as the gateway's answer holds it.
|
||||
///
|
||||
/// # Errors
|
||||
@@ -75,6 +274,365 @@ impl DefaultBucketUsecase {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use rustfs_gateway_types::persistence::PersistedObjectLockRule;
|
||||
|
||||
use crate::app::bucket_usecase::test_support::build_request;
|
||||
use crate::app::gating_test_env::{run_large_stack_test, shared_gating_ambient};
|
||||
use crate::app::runtime_sources::ServerContextSlot;
|
||||
use crate::app::storage_api::bucket_usecase::helper::MutationCompletionProbe;
|
||||
use crate::app::storage_api::owned_parity::authorize_bucket_config_mutation;
|
||||
use crate::site_replication::hooks::BUCKET_META_HOOK_CALLS;
|
||||
use http::Method;
|
||||
use rustfs_credentials::Credentials;
|
||||
use serial_test::serial;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
const ORIGINAL: &[u8] = b"<ObjectLockConfiguration><ObjectLockEnabled>Enabled</ObjectLockEnabled></ObjectLockConfiguration>";
|
||||
const CHANGED: &[u8] = b"<ObjectLockConfiguration><ObjectLockEnabled>Enabled</ObjectLockEnabled><Rule><DefaultRetention><Days>3</Days><Mode>GOVERNANCE</Mode></DefaultRetention></Rule></ObjectLockConfiguration>";
|
||||
const SUSPENDED: &[u8] = b"<VersioningConfiguration><Status>Suspended</Status></VersioningConfiguration>";
|
||||
const ENABLED: &[u8] = b"<VersioningConfiguration><Status>Enabled</Status></VersioningConfiguration>";
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Scenario {
|
||||
FirstFence,
|
||||
SecondFence,
|
||||
PeerFailure,
|
||||
SiteFailure,
|
||||
Success,
|
||||
}
|
||||
|
||||
type MetadataBytes = (Vec<u8>, Vec<u8>);
|
||||
|
||||
struct CompletionProbe {
|
||||
scenario: Scenario,
|
||||
store: Arc<ECStore>,
|
||||
observations: RefCell<Vec<MetadataBytes>>,
|
||||
recreated_scanner_generation: Cell<Option<u64>>,
|
||||
}
|
||||
|
||||
tokio::task_local! {
|
||||
static STATE: CompletionProbe;
|
||||
}
|
||||
|
||||
async fn stored_lock_and_versioning(bucket: &str) -> MetadataBytes {
|
||||
let metadata = metadata_sys::get_global_bucket_metadata_sys()
|
||||
.expect("metadata system")
|
||||
.read()
|
||||
.await
|
||||
.get_config_from_disk(bucket)
|
||||
.await
|
||||
.expect("read metadata from disk");
|
||||
(metadata.object_lock_config_xml, metadata.versioning_config_xml)
|
||||
}
|
||||
|
||||
async fn recreate(store: &Arc<ECStore>, bucket: &str) {
|
||||
store
|
||||
.delete_bucket(bucket, &DeleteBucketOptions::default())
|
||||
.await
|
||||
.expect("delete original bucket");
|
||||
store
|
||||
.make_bucket(bucket, &MakeBucketOptions::default())
|
||||
.await
|
||||
.expect("recreate bucket");
|
||||
seed(bucket).await;
|
||||
}
|
||||
|
||||
async fn seed(bucket: &str) {
|
||||
metadata_sys::update(bucket, OBJECT_LOCK_CONFIG, ORIGINAL.to_vec())
|
||||
.await
|
||||
.expect("store original lock");
|
||||
metadata_sys::update(bucket, BUCKET_VERSIONING_CONFIG, SUSPENDED.to_vec())
|
||||
.await
|
||||
.expect("store suspended versioning");
|
||||
}
|
||||
|
||||
pub(super) async fn after_lock_write(bucket: &str) {
|
||||
if let Ok((Scenario::SecondFence, store)) = STATE.try_with(|state| (state.scenario, Arc::clone(&state.store))) {
|
||||
let bytes = stored_lock_and_versioning(bucket).await;
|
||||
STATE.with(|state| state.observations.borrow_mut().push(bytes));
|
||||
recreate(&store, bucket).await;
|
||||
STATE.with(|state| {
|
||||
state
|
||||
.recreated_scanner_generation
|
||||
.set(rustfs_scanner::scanner_dirty_usage_bucket_generation(bucket));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn peer_reload_outcome(bucket: &str) -> Result<(), StorageError> {
|
||||
let Ok(scenario) = STATE.try_with(|state| state.scenario) else {
|
||||
return Ok(());
|
||||
};
|
||||
let bytes = stored_lock_and_versioning(bucket).await;
|
||||
STATE.with(|state| state.observations.borrow_mut().push(bytes));
|
||||
if scenario == Scenario::PeerFailure {
|
||||
return Err(StorageError::other("test peer reload failure"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn site_hook_outcome() -> S3Result<()> {
|
||||
if matches!(STATE.try_with(|state| state.scenario), Ok(Scenario::SiteFailure)) {
|
||||
return Err(s3_error!(InternalError, "test site replication failure"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn put_lock_with_observed_completion(scenario: Scenario) {
|
||||
let context = shared_gating_ambient().await;
|
||||
let store = context.object_store();
|
||||
let bucket = format!(
|
||||
"lock-cfg-{}-{}",
|
||||
match scenario {
|
||||
Scenario::FirstFence => "first",
|
||||
Scenario::SecondFence => "second",
|
||||
Scenario::PeerFailure => "peer",
|
||||
Scenario::SiteFailure => "site",
|
||||
Scenario::Success => "success",
|
||||
},
|
||||
uuid::Uuid::new_v4().simple()
|
||||
);
|
||||
store
|
||||
.make_bucket(&bucket, &MakeBucketOptions::default())
|
||||
.await
|
||||
.expect("create bucket");
|
||||
seed(&bucket).await;
|
||||
|
||||
let server = ServerContextSlot::new();
|
||||
assert!(server.install(Arc::clone(&context)));
|
||||
let mut request = build_request((), Method::PUT);
|
||||
request.uri = format!("/{bucket}?object-lock").parse().expect("request URI");
|
||||
request.extensions.insert(Arc::clone(&server));
|
||||
request.extensions.insert(ReqInfo {
|
||||
cred: Some(Credentials {
|
||||
access_key: "bucket-lock-owner".to_owned(),
|
||||
..Default::default()
|
||||
}),
|
||||
is_owner: true,
|
||||
..Default::default()
|
||||
});
|
||||
let mut envelope = RequestEnvelope::from_s3s(&request);
|
||||
authorize_bucket_config_mutation(
|
||||
&server,
|
||||
&mut envelope,
|
||||
&bucket,
|
||||
Action::S3Action(S3Action::PutBucketObjectLockConfigurationAction),
|
||||
)
|
||||
.await
|
||||
.expect("capture the authorized bucket incarnation");
|
||||
|
||||
if scenario == Scenario::FirstFence {
|
||||
recreate(&store, &bucket).await;
|
||||
}
|
||||
let scanner_before = rustfs_scanner::scanner_dirty_usage_bucket_generation(&bucket);
|
||||
let audits = MutationCompletionProbe::install(&bucket);
|
||||
let usecase = DefaultBucketUsecase::with_context(Some(context));
|
||||
let config = rustfs_gateway_types::persistence::parse_object_lock(CHANGED).expect("fixture parses");
|
||||
let (result, hooks, observed, recreated_scanner_generation) = STATE
|
||||
.scope(
|
||||
CompletionProbe {
|
||||
scenario,
|
||||
store,
|
||||
observations: RefCell::default(),
|
||||
recreated_scanner_generation: Cell::default(),
|
||||
},
|
||||
async {
|
||||
let (result, hooks) = BUCKET_META_HOOK_CALLS
|
||||
.scope(RefCell::default(), async {
|
||||
let result = usecase
|
||||
.execute_put_object_lock_configuration(envelope, &bucket, Some(config))
|
||||
.await;
|
||||
(result, BUCKET_META_HOOK_CALLS.with(RefCell::take))
|
||||
})
|
||||
.await;
|
||||
let (observed, recreated_scanner_generation) =
|
||||
STATE.with(|state| (state.observations.take(), state.recreated_scanner_generation.get()));
|
||||
(result, hooks, observed, recreated_scanner_generation)
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let stored = stored_lock_and_versioning(&bucket).await;
|
||||
let scanner_after = rustfs_scanner::scanner_dirty_usage_bucket_generation(&bucket);
|
||||
let audits_seen = audits.audits.lock().expect("audit entries");
|
||||
let seen: Vec<_> = audits_seen
|
||||
.iter()
|
||||
.map(|entry| (entry.api.name.as_deref(), entry.api.status_code))
|
||||
.collect();
|
||||
let batch = |lock: &[u8], version: &[u8]| (lock.to_vec(), version.to_vec());
|
||||
let (error, versioning, callbacks, status) = match scenario {
|
||||
Scenario::FirstFence => (Some(S3ErrorCode::NoSuchBucket), batch(ORIGINAL, SUSPENDED), vec![], 404),
|
||||
Scenario::SecondFence => (
|
||||
Some(S3ErrorCode::NoSuchBucket),
|
||||
batch(ORIGINAL, SUSPENDED),
|
||||
vec![batch(CHANGED, SUSPENDED)],
|
||||
404,
|
||||
),
|
||||
Scenario::PeerFailure => (
|
||||
Some(S3ErrorCode::InternalError),
|
||||
batch(CHANGED, ENABLED),
|
||||
vec![batch(CHANGED, ENABLED)],
|
||||
500,
|
||||
),
|
||||
Scenario::SiteFailure | Scenario::Success => (None, batch(CHANGED, ENABLED), vec![batch(CHANGED, ENABLED)], 200),
|
||||
};
|
||||
assert_eq!(
|
||||
(result.err().map(|error| error.code().clone()), stored, observed, seen),
|
||||
(
|
||||
error,
|
||||
versioning,
|
||||
callbacks,
|
||||
vec![(Some(S3Operation::PutObjectLockConfiguration.as_str()), Some(status))]
|
||||
),
|
||||
"{scenario:?}",
|
||||
);
|
||||
if scenario == Scenario::SiteFailure || scenario == Scenario::Success {
|
||||
let [hook] = hooks.as_slice() else { panic!("{scenario:?} must call site replication once") };
|
||||
assert_eq!(
|
||||
(&hook.bucket, hook.item_type.as_str(), hook.scanner_generation),
|
||||
(&bucket, "object-lock-config", scanner_before)
|
||||
);
|
||||
assert!(scanner_after > scanner_before, "{scenario:?} must invalidate scanner usage");
|
||||
} else {
|
||||
assert!(hooks.is_empty(), "{scenario:?} must stop before site replication");
|
||||
let expected_generation = if scenario == Scenario::SecondFence {
|
||||
recreated_scanner_generation
|
||||
} else {
|
||||
scanner_before
|
||||
};
|
||||
assert_eq!(expected_generation, scanner_after, "{scenario:?} must stop before scanner invalidation");
|
||||
}
|
||||
assert!(audits.events.lock().expect("event entries").is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn put_lock_configuration_fences_the_first_write() {
|
||||
run_large_stack_test("bucket-lock-first-write", || put_lock_with_observed_completion(Scenario::FirstFence));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn put_lock_configuration_fences_the_versioning_write() {
|
||||
run_large_stack_test("bucket-lock-version-write", || put_lock_with_observed_completion(Scenario::SecondFence));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn put_lock_configuration_propagates_peer_reload_failure() {
|
||||
run_large_stack_test("bucket-lock-peer-failure", || put_lock_with_observed_completion(Scenario::PeerFailure));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn put_lock_configuration_continues_after_site_hook_failure() {
|
||||
run_large_stack_test("bucket-lock-site-failure", || put_lock_with_observed_completion(Scenario::SiteFailure));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn put_lock_configuration_completes_durable_writes_before_callbacks() {
|
||||
run_large_stack_test("bucket-lock-callback-order", || put_lock_with_observed_completion(Scenario::Success));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_disabled_status() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some("Disabled".to_owned()),
|
||||
rule: None,
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_invalid_default_retention_mode() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some("Enabled".to_owned()),
|
||||
rule: Some(PersistedObjectLockRule {
|
||||
default_retention: Some(PersistedDefaultRetention {
|
||||
mode: Some("abc".to_owned()),
|
||||
days: Some(1),
|
||||
years: None,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_days_and_years_together() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some("Enabled".to_owned()),
|
||||
rule: Some(PersistedObjectLockRule {
|
||||
default_retention: Some(PersistedDefaultRetention {
|
||||
mode: Some("GOVERNANCE".to_owned()),
|
||||
days: Some(1),
|
||||
years: Some(1),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_missing_default_retention() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some("Enabled".to_owned()),
|
||||
rule: Some(PersistedObjectLockRule { default_retention: None }),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_zero_days() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some("Enabled".to_owned()),
|
||||
rule: Some(PersistedObjectLockRule {
|
||||
default_retention: Some(PersistedDefaultRetention {
|
||||
mode: Some("GOVERNANCE".to_owned()),
|
||||
days: Some(0),
|
||||
years: None,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::Custom("InvalidRetentionPeriod".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_too_many_years() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some("Enabled".to_owned()),
|
||||
rule: Some(PersistedObjectLockRule {
|
||||
default_retention: Some(PersistedDefaultRetention {
|
||||
mode: Some("COMPLIANCE".to_owned()),
|
||||
days: None,
|
||||
years: Some(101),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::Custom("InvalidRetentionPeriod".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_object_lock_peer_reload_failure_is_returned_to_the_client() {
|
||||
let err = propagate_object_lock_peer_reload(Err(StorageError::other("peer reload failed")))
|
||||
.expect_err("peer reload failure must prevent a successful Object Lock update response");
|
||||
|
||||
assert_eq!(err.code(), &S3ErrorCode::InternalError);
|
||||
assert!(err.message().is_some_and(|message| message.contains("peer reload failed")));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn execute_get_object_lock_configuration_returns_internal_error_when_store_uninitialized() {
|
||||
let input = gateway_dto::GetObjectLockConfigurationInput {
|
||||
|
||||
@@ -962,7 +962,6 @@ pub(crate) mod bucket {
|
||||
pub(crate) const BUCKET_TARGETS_FILE: &str = crate::storage::storage_api::ecstore_bucket::metadata::BUCKET_TARGETS_FILE;
|
||||
pub(crate) const BUCKET_VERSIONING_CONFIG: &str =
|
||||
crate::storage::storage_api::ecstore_bucket::metadata::BUCKET_VERSIONING_CONFIG;
|
||||
#[cfg(test)]
|
||||
pub(crate) const OBJECT_LOCK_CONFIG: &str = crate::storage::storage_api::ecstore_bucket::metadata::OBJECT_LOCK_CONFIG;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,10 @@ use crate::storage_api::server::http::access::{
|
||||
access_owned::bucket_replication_lifecycle::prepare_replication_config_edit, authorize_bucket_request,
|
||||
};
|
||||
use rustfs_gateway::{Req, Resp, dto};
|
||||
use rustfs_gateway_types::persistence::{parse_replication, serialize_replication_dto};
|
||||
use rustfs_gateway_types::persistence::{
|
||||
PersistedDefaultRetention, PersistedObjectLockConfiguration, PersistedObjectLockRule, parse_replication,
|
||||
serialize_replication_dto,
|
||||
};
|
||||
use rustfs_policy::policy::action::{Action, S3Action};
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
use rustfs_s3_types::S3Result;
|
||||
@@ -38,6 +41,7 @@ pub(super) const ROWS: &[OpRow] = &[
|
||||
row::<dto::PutBucketReplication>(),
|
||||
row::<dto::DeleteBucketReplication>(),
|
||||
row::<dto::GetObjectLockConfiguration>(),
|
||||
row::<dto::PutObjectLockConfiguration>(),
|
||||
];
|
||||
|
||||
impl Served for dto::GetBucketLifecycleConfiguration {
|
||||
@@ -113,6 +117,34 @@ impl Served for dto::DeleteBucketReplication {
|
||||
}
|
||||
}
|
||||
|
||||
impl Served for dto::PutObjectLockConfiguration {
|
||||
const METRIC: S3Operation = S3Operation::PutObjectLockConfiguration;
|
||||
|
||||
async fn authorize(envelope: &mut RequestEnvelope, request: &Req<Self>) -> S3Result<()> {
|
||||
let action = Action::S3Action(S3Action::PutBucketObjectLockConfigurationAction);
|
||||
authorize_bucket_config_mutation(envelope, request.input().bucket.as_str(), action).await
|
||||
}
|
||||
|
||||
async fn execute(context: Option<Arc<AppContext>>, envelope: RequestEnvelope, request: Req<Self>) -> S3Result<Resp<Self>> {
|
||||
let input = request.into_input();
|
||||
let config = input.object_lock_configuration;
|
||||
let config = PersistedObjectLockConfiguration {
|
||||
object_lock_enabled: config.object_lock_enabled.map(|enabled| enabled.as_str().to_owned()),
|
||||
rule: config.rule.map(|rule| PersistedObjectLockRule {
|
||||
default_retention: rule.default_retention.map(|retention| PersistedDefaultRetention {
|
||||
mode: retention.mode.map(|mode| mode.as_str().to_owned()),
|
||||
days: retention.days,
|
||||
years: retention.years,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
DefaultBucketUsecase::with_context(context)
|
||||
.execute_put_object_lock_configuration(envelope, input.bucket.as_str(), Some(config))
|
||||
.await?;
|
||||
Ok(Resp::new(dto::PutObjectLockConfigurationOutput::default()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Served for dto::GetObjectLockConfiguration {
|
||||
const METRIC: S3Operation = S3Operation::GetObjectLockConfiguration;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use super::{StorageError, decode_tags_to_map, is_err_bucket_not_found, is_err_object_not_found, is_err_version_not_found};
|
||||
use super::{decode_tags_to_map, is_err_bucket_not_found, is_err_object_not_found, is_err_version_not_found};
|
||||
use crate::app::{Answered, RequestEnvelope};
|
||||
use crate::error::ApiErrorDiagnostic;
|
||||
use crate::storage::s3_api;
|
||||
@@ -174,89 +174,6 @@ pub(crate) fn parse_object_version_id(version_id: Option<String>) -> S3Result<Op
|
||||
}
|
||||
}
|
||||
|
||||
const MAXIMUM_RETENTION_DAYS: i32 = 36_500;
|
||||
const MAXIMUM_RETENTION_YEARS: i32 = 100;
|
||||
|
||||
fn invalid_object_lock_configuration(message: impl Into<String>) -> S3Error {
|
||||
S3Error::with_message(S3ErrorCode::MalformedXML, message.into())
|
||||
}
|
||||
|
||||
pub(crate) fn propagate_object_lock_peer_reload(result: std::result::Result<(), StorageError>) -> S3Result<()> {
|
||||
result.map_err(|err| {
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("Failed to publish Object Lock metadata: {err}"))
|
||||
})
|
||||
}
|
||||
|
||||
fn invalid_retention_period(message: impl Into<String>) -> S3Error {
|
||||
let mut err = S3Error::with_message(S3ErrorCode::Custom("InvalidRetentionPeriod".into()), message.into());
|
||||
err.set_status_code(StatusCode::BAD_REQUEST);
|
||||
err
|
||||
}
|
||||
|
||||
fn validate_default_retention_configuration(default_retention: &DefaultRetention) -> S3Result<()> {
|
||||
let Some(mode) = default_retention.mode.as_ref() else {
|
||||
return Err(invalid_object_lock_configuration("retention mode must be specified"));
|
||||
};
|
||||
|
||||
match mode.as_str() {
|
||||
ObjectLockRetentionMode::COMPLIANCE | ObjectLockRetentionMode::GOVERNANCE => {}
|
||||
_ => {
|
||||
return Err(invalid_object_lock_configuration(format!("unknown retention mode {}", mode.as_str())));
|
||||
}
|
||||
}
|
||||
|
||||
match (default_retention.days, default_retention.years) {
|
||||
(Some(days), None) => {
|
||||
if days <= 0 {
|
||||
return Err(invalid_retention_period(
|
||||
"Default retention period must be a positive integer value for 'Days'",
|
||||
));
|
||||
}
|
||||
if days > MAXIMUM_RETENTION_DAYS {
|
||||
return Err(invalid_retention_period(format!("Default retention period too large for 'Days' {days}",)));
|
||||
}
|
||||
}
|
||||
(None, Some(years)) => {
|
||||
if years <= 0 {
|
||||
return Err(invalid_retention_period(
|
||||
"Default retention period must be a positive integer value for 'Years'",
|
||||
));
|
||||
}
|
||||
if years > MAXIMUM_RETENTION_YEARS {
|
||||
return Err(invalid_retention_period(format!(
|
||||
"Default retention period too large for 'Years' {years}",
|
||||
)));
|
||||
}
|
||||
}
|
||||
(Some(_), Some(_)) => {
|
||||
return Err(invalid_object_lock_configuration("either Days or Years must be specified, not both"));
|
||||
}
|
||||
(None, None) => {
|
||||
return Err(invalid_object_lock_configuration("either Days or Years must be specified"));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn validate_object_lock_configuration_input(input_cfg: &ObjectLockConfiguration) -> S3Result<()> {
|
||||
let enabled = input_cfg.object_lock_enabled.as_ref().map(ObjectLockEnabled::as_str);
|
||||
if enabled != Some(ObjectLockEnabled::ENABLED) {
|
||||
return Err(invalid_object_lock_configuration(
|
||||
"only 'Enabled' value is allowed to ObjectLockEnabled element",
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(rule) = input_cfg.rule.as_ref() {
|
||||
let Some(default_retention) = rule.default_retention.as_ref() else {
|
||||
return Err(invalid_object_lock_configuration("Rule must include DefaultRetention"));
|
||||
};
|
||||
validate_default_retention_configuration(default_retention)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Runs a use case that speaks the request envelope and the gateway's types behind this edge: the
|
||||
/// input and the output cross the gateway's compatibility seam, and nothing else is converted.
|
||||
pub(in crate::storage) async fn through_gateway_seam<I, GatewayInput, GatewayOutput, O, F>(
|
||||
|
||||
@@ -37,9 +37,7 @@ mod tests {
|
||||
use crate::config::WorkloadProfile;
|
||||
use crate::server::cors;
|
||||
use crate::storage::StorageError;
|
||||
use crate::storage::ecfs::{
|
||||
FS, parse_object_version_id, propagate_object_lock_peer_reload, validate_object_lock_configuration_input,
|
||||
};
|
||||
use crate::storage::ecfs::{FS, parse_object_version_id};
|
||||
use crate::storage::ecfs_extend::{apply_bucket_default_lock_retention, map_bucket_object_lock_config_state};
|
||||
use crate::storage::s3_api::common::{rustfs_initiator, rustfs_owner};
|
||||
use crate::storage::storage_api::ecstore_bucket::metadata_sys::ObjectLockConfigState;
|
||||
@@ -204,105 +202,6 @@ mod tests {
|
||||
crate::storage::persisted_from_s3s(cfg).expect("the test configuration converts")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_disabled_status() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some(ObjectLockEnabled::from("Disabled".to_string())),
|
||||
rule: None,
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_invalid_default_retention_mode() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some(ObjectLockEnabled::from_static(ObjectLockEnabled::ENABLED)),
|
||||
rule: Some(ObjectLockRule {
|
||||
default_retention: Some(DefaultRetention {
|
||||
mode: Some(ObjectLockRetentionMode::from("abc".to_string())),
|
||||
days: Some(1),
|
||||
years: None,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_days_and_years_together() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some(ObjectLockEnabled::from_static(ObjectLockEnabled::ENABLED)),
|
||||
rule: Some(ObjectLockRule {
|
||||
default_retention: Some(DefaultRetention {
|
||||
mode: Some(ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::GOVERNANCE)),
|
||||
days: Some(1),
|
||||
years: Some(1),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_missing_default_retention() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some(ObjectLockEnabled::from_static(ObjectLockEnabled::ENABLED)),
|
||||
rule: Some(ObjectLockRule { default_retention: None }),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::MalformedXML);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_zero_days() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some(ObjectLockEnabled::from_static(ObjectLockEnabled::ENABLED)),
|
||||
rule: Some(ObjectLockRule {
|
||||
default_retention: Some(DefaultRetention {
|
||||
mode: Some(ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::GOVERNANCE)),
|
||||
days: Some(0),
|
||||
years: None,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::Custom("InvalidRetentionPeriod".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_object_lock_configuration_rejects_too_many_years() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
object_lock_enabled: Some(ObjectLockEnabled::from_static(ObjectLockEnabled::ENABLED)),
|
||||
rule: Some(ObjectLockRule {
|
||||
default_retention: Some(DefaultRetention {
|
||||
mode: Some(ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::COMPLIANCE)),
|
||||
days: None,
|
||||
years: Some(101),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
let err = validate_object_lock_configuration_input(&cfg).unwrap_err();
|
||||
assert_eq!(err.code(), &S3ErrorCode::Custom("InvalidRetentionPeriod".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_object_lock_peer_reload_failure_is_returned_to_the_client() {
|
||||
let err = propagate_object_lock_peer_reload(Err(StorageError::other("peer reload failed")))
|
||||
.expect_err("peer reload failure must prevent a successful Object Lock update response");
|
||||
|
||||
assert_eq!(err.code(), &S3ErrorCode::InternalError);
|
||||
assert!(err.message().is_some_and(|message| message.contains("peer reload failed")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_apply_default_lock_retention_metadata_applies_bucket_default() {
|
||||
let cfg = ObjectLockConfiguration {
|
||||
|
||||
@@ -19,146 +19,19 @@
|
||||
//! former trait method bodies, unchanged; the batch that moves these operations onto the gateway
|
||||
//! owns this file and is the only one that edits it.
|
||||
|
||||
use crate::admin::handlers::site_replication::site_replication_bucket_meta_hook;
|
||||
use crate::app::RequestEnvelope;
|
||||
use crate::error::ApiError;
|
||||
use crate::storage::StorageVersioningConfigExt as _;
|
||||
use crate::storage::access::access_owned::bucket_replication_lifecycle::prepare_replication_config_edit;
|
||||
use crate::storage::access::bucket_config_mutation_incarnation;
|
||||
use crate::storage::ecfs::*;
|
||||
use crate::storage::helper::audit_only_operation;
|
||||
use crate::storage::persisted_from_s3s;
|
||||
use crate::storage::s3_api::{self, PreparedLifecycleConfiguration, validate_lifecycle_rule_status};
|
||||
use crate::storage::s3_compat::lifecycle::lifecycle_configuration_from_s3s;
|
||||
use crate::storage::s3_compat::replication::replication_configuration_from_s3s;
|
||||
use crate::storage::storage_api::ecfs_consumer::contract::bucket::{BucketOperations, BucketOptions};
|
||||
use crate::storage::storage_api::ecstore_bucket::utils::serialize as serialize_bucket_config;
|
||||
use crate::storage::storage_api::runtime_sources_consumer::runtime_sources;
|
||||
use crate::storage::{
|
||||
BUCKET_VERSIONING_CONFIG, BucketVersioningSys, OBJECT_LOCK_CONFIG, StorageError, get_bucket_object_lock_config,
|
||||
update_bucket_metadata_config_if_incarnation,
|
||||
};
|
||||
use rustfs_gateway_types::compat::s3s_5761ddfe::generated::ops::{
|
||||
get_bucket_lifecycle_configuration, get_bucket_replication, get_object_lock_configuration,
|
||||
};
|
||||
use rustfs_gateway_types::persistence::{PersistedDefaultRetention, PersistedObjectLockConfiguration, PersistedObjectLockRule};
|
||||
use rustfs_io_metrics::record_s3_op;
|
||||
use rustfs_madmin::{SITE_REPL_API_VERSION, SRBucketMeta};
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
use tracing::{instrument, warn};
|
||||
|
||||
const LOG_SUBSYSTEM_OBJECT_LOCK: &str = "object_lock";
|
||||
|
||||
/// Handler body that runs through `audit_only_operation`.
|
||||
impl FS {
|
||||
async fn put_object_lock_configuration_inner(
|
||||
&self,
|
||||
req: S3Request<PutObjectLockConfigurationInput>,
|
||||
) -> S3Result<S3Response<PutObjectLockConfigurationOutput>> {
|
||||
let expected_incarnation_id = bucket_config_mutation_incarnation(&req, &req.input.bucket)?;
|
||||
let PutObjectLockConfigurationInput {
|
||||
bucket,
|
||||
object_lock_configuration,
|
||||
..
|
||||
} = req.input;
|
||||
|
||||
let Some(input_cfg) = object_lock_configuration else { return Err(s3_error!(InvalidArgument)) };
|
||||
|
||||
let Some(store) = self.server_ctx.object_store() else {
|
||||
return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string()));
|
||||
};
|
||||
|
||||
store
|
||||
.get_bucket_info(&bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
|
||||
validate_object_lock_configuration_input(&input_cfg)?;
|
||||
|
||||
match get_bucket_object_lock_config(&bucket).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
if err == StorageError::ConfigNotFound {
|
||||
if !BucketVersioningSys::enabled(&bucket).await {
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::InvalidBucketState,
|
||||
"Object Lock configuration cannot be enabled on existing buckets".to_string(),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
warn!("get_object_lock_config err {:?}", err);
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::InternalError,
|
||||
"Failed to get bucket ObjectLockConfiguration".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let persisted_cfg =
|
||||
persisted_from_s3s::<_, rustfs_gateway_types::persistence::PersistedObjectLockConfiguration>(&input_cfg)?;
|
||||
let data = serialize_bucket_config(&persisted_cfg)
|
||||
.map_err(|err| S3Error::with_message(S3ErrorCode::InternalError, format!("{err}")))?;
|
||||
let object_lock_config =
|
||||
String::from_utf8(data.clone()).map_err(|err| S3Error::with_message(S3ErrorCode::InternalError, format!("{err}")))?;
|
||||
|
||||
let updated_at = update_bucket_metadata_config_if_incarnation(&bucket, OBJECT_LOCK_CONFIG, data, expected_incarnation_id)
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
|
||||
// When Object Lock is enabled, automatically enable versioning if not already enabled.
|
||||
// This matches S3-compatible behavior.
|
||||
let versioning_config = BucketVersioningSys::get(&bucket).await.map_err(ApiError::from)?;
|
||||
if !versioning_config.enabled() {
|
||||
let enable_versioning_config = rustfs_gateway_types::persistence::PersistedVersioningConfiguration {
|
||||
status: Some("Enabled".to_owned()),
|
||||
..Default::default()
|
||||
};
|
||||
let versioning_data = serialize_bucket_config(&enable_versioning_config)
|
||||
.map_err(|err| S3Error::with_message(S3ErrorCode::InternalError, format!("{err}")))?;
|
||||
update_bucket_metadata_config_if_incarnation(
|
||||
&bucket,
|
||||
BUCKET_VERSIONING_CONFIG,
|
||||
versioning_data,
|
||||
expected_incarnation_id,
|
||||
)
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
}
|
||||
|
||||
if let Some(notification_sys) =
|
||||
runtime_sources::current_notification_system_for_context(self.server_ctx.app_context().as_deref())
|
||||
{
|
||||
propagate_object_lock_peer_reload(notification_sys.load_bucket_metadata(&bucket).await)?;
|
||||
}
|
||||
|
||||
if let Err(err) = site_replication_bucket_meta_hook(SRBucketMeta {
|
||||
bucket: bucket.clone(),
|
||||
r#type: "object-lock-config".to_string(),
|
||||
object_lock_config: Some(object_lock_config),
|
||||
updated_at: Some(updated_at),
|
||||
api_version: Some(SITE_REPL_API_VERSION.to_string()),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
{
|
||||
warn!(
|
||||
component = LOG_COMPONENT_STORAGE,
|
||||
subsystem = LOG_SUBSYSTEM_OBJECT_LOCK,
|
||||
event = "put_object_lock_configuration",
|
||||
bucket = %bucket,
|
||||
result = "site_replication_hook_failed",
|
||||
error = ?err,
|
||||
"storage object lock state"
|
||||
);
|
||||
}
|
||||
|
||||
rustfs_scanner::record_dirty_usage_bucket_from_producer(
|
||||
&bucket,
|
||||
rustfs_scanner::SegmentInvalidationProducerIdentity::BucketMetadata,
|
||||
);
|
||||
Ok(S3Response::new(PutObjectLockConfigurationOutput::default()))
|
||||
}
|
||||
}
|
||||
use tracing::instrument;
|
||||
|
||||
impl FS {
|
||||
#[instrument(name = "delete_bucket_lifecycle", level = "debug", skip(self, req))]
|
||||
@@ -288,9 +161,25 @@ impl FS {
|
||||
&self,
|
||||
req: S3Request<PutObjectLockConfigurationInput>,
|
||||
) -> S3Result<S3Response<PutObjectLockConfigurationOutput>> {
|
||||
audit_only_operation(req, S3Operation::PutObjectLockConfiguration, |req| {
|
||||
self.put_object_lock_configuration_inner(req)
|
||||
})
|
||||
.await
|
||||
let envelope = RequestEnvelope::from_s3s(&req);
|
||||
let PutObjectLockConfigurationInput {
|
||||
bucket,
|
||||
object_lock_configuration,
|
||||
..
|
||||
} = req.input;
|
||||
let config = object_lock_configuration.map(|config| PersistedObjectLockConfiguration {
|
||||
object_lock_enabled: config.object_lock_enabled.map(|enabled| enabled.as_str().to_owned()),
|
||||
rule: config.rule.map(|rule| PersistedObjectLockRule {
|
||||
default_retention: rule.default_retention.map(|retention| PersistedDefaultRetention {
|
||||
mode: retention.mode.map(|mode| mode.as_str().to_owned()),
|
||||
days: retention.days,
|
||||
years: retention.years,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
s3_api::bucket_usecase_for(self)
|
||||
.execute_put_object_lock_configuration(envelope, &bucket, config)
|
||||
.await?;
|
||||
Ok(S3Response::new(PutObjectLockConfigurationOutput::default()))
|
||||
}
|
||||
}
|
||||
|
||||
+25
-26
@@ -49,32 +49,31 @@ pub(crate) use ecfs_extend::*;
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use storage_api::{
|
||||
BUCKET_ACCELERATE_CONFIG, BUCKET_REQUEST_PAYMENT_CONFIG, BUCKET_TABLE_CATALOG_META_PREFIX,
|
||||
BUCKET_TABLE_CATALOG_TABLE_BUCKETS_PREFIX, BUCKET_TABLE_CONFIG, BUCKET_TABLE_RESERVED_PREFIX, BUCKET_VERSIONING_CONFIG,
|
||||
BUCKET_WEBSITE_CONFIG, BucketBandwidthMonitor, BucketMetadata, BucketVersioningSys, CheckPartsResp, CollectMetricsOpts,
|
||||
DEFAULT_READ_BUFFER_SIZE, DailyAllTierStats, DeleteOptions, DiskError, DiskInfo, DiskInfoOptions, DiskResult, DiskStore,
|
||||
DynReader, DynReplicationPool, ECStore, Endpoint, EndpointServerPools, Error, EventArgs, ExpiryState, FS, FileInfoVersions,
|
||||
FileReader, FileWriter, GetObjectReader, HashReader, LocalPeerS3Client, MetricType, NotificationSys, OBJECT_LOCK_CONFIG,
|
||||
ObjectInfo, ObjectLockBlockReason, ObjectOptions, ObjectPartInfo, PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PolicySys, PutObjReader,
|
||||
QuotaError, RUSTFS_META_BUCKET, RawFileInfo, ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameDataResp,
|
||||
ReplicationStats, ReplicationStatusType, Result, SERVICE_SIGNAL_REFRESH_CONFIG, SERVICE_SIGNAL_RELOAD_DYNAMIC,
|
||||
StorageDeletedObject, StorageDiskRpcExt, StorageError, StorageGetObjectReader, StorageObjectInfo, StorageObjectOptions,
|
||||
StorageObjectToDelete, StoragePeerS3ClientExt, StoragePutObjReader, StorageVersioningConfigExt, TONIC_RPC_PREFIX,
|
||||
TierConfigMgr, UpdateMetadataOpts, VolumeInfo, WalkDirOptions, WorkloadAdmissionSnapshotProviderRef, WriteEncryption,
|
||||
WritePlan, access_consumer, add_object_lock_years, all_local_disk, all_local_disk_path, check_retention_for_modification,
|
||||
collect_local_metrics, compression_metadata_value, contract, decode_tags, decode_tags_to_map, delete_bucket_metadata_config,
|
||||
delete_bucket_metadata_config_if_incarnation, disk_drive_path, disk_endpoint, ecfs_consumer, ecfs_extend_consumer,
|
||||
ecstore_admin, ecstore_bucket, ecstore_capacity, ecstore_client, ecstore_cluster, ecstore_compression, ecstore_config,
|
||||
ecstore_data_usage, ecstore_disk, ecstore_error, ecstore_event, ecstore_layout, ecstore_metrics, ecstore_notification,
|
||||
ecstore_rebalance, ecstore_rio, ecstore_rpc, ecstore_set_disk, ecstore_storage, ecstore_tier, encode_tags,
|
||||
find_local_disk_by_ref, get_bucket_cors_config, get_bucket_metadata, get_bucket_notification_config,
|
||||
get_bucket_object_lock_config, get_bucket_sse_config, get_bucket_website_config_for_store, get_local_server_property,
|
||||
get_lock_acquire_timeout, head_prefix_consumer, helper_consumer, init_background_replication, init_bucket_metadata_sys,
|
||||
init_ecstore_config, init_local_disks_with_instance_ctx, init_lock_clients, is_err_bucket_not_found, is_err_object_not_found,
|
||||
is_err_version_not_found, is_valid_storage_class, options_consumer, prewarm_local_disk_id_map_with_instance_ctx, read_config,
|
||||
record_replication_proxy, rpc_consumer, runtime_sources_consumer, s3_api_consumer, table_catalog_path_hash, to_s3s_etag,
|
||||
topology_snapshot_from_endpoint_pools_with_capabilities, try_migrate_bucket_metadata, try_migrate_iam_config,
|
||||
try_migrate_server_config, update_bucket_metadata_config, update_bucket_metadata_config_if_incarnation,
|
||||
validate_website_configuration, verify_rpc_signature, wrap_reader,
|
||||
BUCKET_TABLE_CATALOG_TABLE_BUCKETS_PREFIX, BUCKET_TABLE_CONFIG, BUCKET_TABLE_RESERVED_PREFIX, BUCKET_WEBSITE_CONFIG,
|
||||
BucketBandwidthMonitor, BucketMetadata, BucketVersioningSys, CheckPartsResp, CollectMetricsOpts, DEFAULT_READ_BUFFER_SIZE,
|
||||
DailyAllTierStats, DeleteOptions, DiskError, DiskInfo, DiskInfoOptions, DiskResult, DiskStore, DynReader, DynReplicationPool,
|
||||
ECStore, Endpoint, EndpointServerPools, Error, EventArgs, ExpiryState, FS, FileInfoVersions, FileReader, FileWriter,
|
||||
GetObjectReader, HashReader, LocalPeerS3Client, MetricType, NotificationSys, ObjectInfo, ObjectLockBlockReason,
|
||||
ObjectOptions, ObjectPartInfo, PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PolicySys, PutObjReader, QuotaError, RUSTFS_META_BUCKET,
|
||||
RawFileInfo, ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameDataResp, ReplicationStats, ReplicationStatusType, Result,
|
||||
SERVICE_SIGNAL_REFRESH_CONFIG, SERVICE_SIGNAL_RELOAD_DYNAMIC, StorageDeletedObject, StorageDiskRpcExt, StorageError,
|
||||
StorageGetObjectReader, StorageObjectInfo, StorageObjectOptions, StorageObjectToDelete, StoragePeerS3ClientExt,
|
||||
StoragePutObjReader, TONIC_RPC_PREFIX, TierConfigMgr, UpdateMetadataOpts, VolumeInfo, WalkDirOptions,
|
||||
WorkloadAdmissionSnapshotProviderRef, WriteEncryption, WritePlan, access_consumer, add_object_lock_years, all_local_disk,
|
||||
all_local_disk_path, check_retention_for_modification, collect_local_metrics, compression_metadata_value, contract,
|
||||
decode_tags, decode_tags_to_map, delete_bucket_metadata_config, delete_bucket_metadata_config_if_incarnation,
|
||||
disk_drive_path, disk_endpoint, ecfs_consumer, ecfs_extend_consumer, ecstore_admin, ecstore_bucket, ecstore_capacity,
|
||||
ecstore_client, ecstore_cluster, ecstore_compression, ecstore_config, ecstore_data_usage, ecstore_disk, ecstore_error,
|
||||
ecstore_event, ecstore_layout, ecstore_metrics, ecstore_notification, ecstore_rebalance, ecstore_rio, ecstore_rpc,
|
||||
ecstore_set_disk, ecstore_storage, ecstore_tier, encode_tags, find_local_disk_by_ref, get_bucket_cors_config,
|
||||
get_bucket_metadata, get_bucket_notification_config, get_bucket_sse_config, get_bucket_website_config_for_store,
|
||||
get_local_server_property, get_lock_acquire_timeout, head_prefix_consumer, helper_consumer, init_background_replication,
|
||||
init_bucket_metadata_sys, init_ecstore_config, init_local_disks_with_instance_ctx, init_lock_clients,
|
||||
is_err_bucket_not_found, is_err_object_not_found, is_err_version_not_found, is_valid_storage_class, options_consumer,
|
||||
prewarm_local_disk_id_map_with_instance_ctx, read_config, record_replication_proxy, rpc_consumer, runtime_sources_consumer,
|
||||
s3_api_consumer, table_catalog_path_hash, to_s3s_etag, topology_snapshot_from_endpoint_pools_with_capabilities,
|
||||
try_migrate_bucket_metadata, try_migrate_iam_config, try_migrate_server_config, update_bucket_metadata_config,
|
||||
update_bucket_metadata_config_if_incarnation, validate_website_configuration, verify_rpc_signature, wrap_reader,
|
||||
};
|
||||
pub(crate) use storage_api::{persisted_from_s3s, persisted_to_s3s, tagging_from_s3s, tagging_to_s3s};
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
use crate::config::RustFSBufferConfig;
|
||||
use crate::runtime_sources as root_runtime_sources;
|
||||
use crate::storage::storage_api::NotificationSys;
|
||||
use crate::storage::storage_api::runtime_sources_consumer::ECStore;
|
||||
use rustfs_credentials::Credentials;
|
||||
use rustfs_iam::{error::Result as IamResult, store::object::ObjectStore, sys::IamSys};
|
||||
@@ -42,10 +41,6 @@ pub(crate) fn current_object_store_handle_for_context(context: Option<&AppContex
|
||||
root_runtime_sources::current_object_store_handle_for_context(context)
|
||||
}
|
||||
|
||||
pub(crate) fn current_notification_system_for_context(context: Option<&AppContext>) -> Option<Arc<NotificationSys>> {
|
||||
root_runtime_sources::current_notification_system_for_context(context)
|
||||
}
|
||||
|
||||
pub(crate) fn current_replication_stats_handle_for_context(
|
||||
context: Option<&AppContext>,
|
||||
) -> Option<Arc<crate::storage::storage_api::ReplicationStats>> {
|
||||
|
||||
@@ -765,10 +765,8 @@ pub(crate) const BUCKET_TABLE_CATALOG_TABLE_BUCKETS_PREFIX: &str =
|
||||
ecstore_bucket::metadata::BUCKET_TABLE_CATALOG_TABLE_BUCKETS_PREFIX;
|
||||
pub(crate) const BUCKET_TABLE_CONFIG: &str = ecstore_bucket::metadata::BUCKET_TABLE_CONFIG;
|
||||
pub(crate) const BUCKET_TABLE_RESERVED_PREFIX: &str = ecstore_bucket::metadata::BUCKET_TABLE_RESERVED_PREFIX;
|
||||
pub(crate) const BUCKET_VERSIONING_CONFIG: &str = ecstore_bucket::metadata::BUCKET_VERSIONING_CONFIG;
|
||||
pub(crate) const BUCKET_WEBSITE_CONFIG: &str = ecstore_bucket::metadata::BUCKET_WEBSITE_CONFIG;
|
||||
pub(crate) const DEFAULT_READ_BUFFER_SIZE: usize = ecstore_set_disk::DEFAULT_READ_BUFFER_SIZE;
|
||||
pub(crate) const OBJECT_LOCK_CONFIG: &str = ecstore_bucket::metadata::OBJECT_LOCK_CONFIG;
|
||||
pub(crate) const PEER_RESTDRY_RUN: &str = ecstore_rpc::PEER_RESTDRY_RUN;
|
||||
pub(crate) const PEER_RESTSIGNAL: &str = ecstore_rpc::PEER_RESTSIGNAL;
|
||||
pub(crate) const PEER_RESTSUB_SYS: &str = ecstore_rpc::PEER_RESTSUB_SYS;
|
||||
@@ -2088,12 +2086,6 @@ pub(crate) async fn get_bucket_cors_config(
|
||||
ecstore_bucket::metadata_sys::get_cors_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_object_lock_config(
|
||||
bucket: &str,
|
||||
) -> Result<(rustfs_gateway_types::persistence::PersistedObjectLockConfiguration, time::OffsetDateTime)> {
|
||||
ecstore_bucket::metadata_sys::get_object_lock_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn persist_force_delete_intent(
|
||||
api: Arc<ECStore>,
|
||||
entry: ecstore_bucket::replication::MrfReplicateEntry,
|
||||
@@ -2677,16 +2669,6 @@ pub(crate) async fn find_local_disk_by_ref_for_rpc(disk_ref: &str) -> std::resul
|
||||
ecstore_storage::find_local_disk_by_ref_for_rpc(disk_ref).await
|
||||
}
|
||||
|
||||
pub(crate) trait StorageVersioningConfigExt {
|
||||
fn enabled(&self) -> bool;
|
||||
}
|
||||
|
||||
impl StorageVersioningConfigExt for rustfs_gateway_types::persistence::PersistedVersioningConfiguration {
|
||||
fn enabled(&self) -> bool {
|
||||
<rustfs_gateway_types::persistence::PersistedVersioningConfiguration as ecstore_bucket::versioning::VersioningApi>::enabled(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) type GetObjectReader = <ECStore as contract::object::ObjectIO>::GetObjectReader;
|
||||
pub(crate) type ObjectInfo = <ECStore as contract::object::ObjectOperations>::ObjectInfo;
|
||||
pub(crate) type ObjectOptions = <ECStore as contract::object::ObjectOperations>::ObjectOptions;
|
||||
|
||||
@@ -110,6 +110,19 @@ pub(crate) const MATRIX: &[MatrixRow] = &[
|
||||
})
|
||||
},
|
||||
},
|
||||
MatrixRow {
|
||||
operation: "PutObjectLockConfiguration",
|
||||
metric: S3Operation::PutObjectLockConfiguration,
|
||||
has_error_body: true,
|
||||
call: |client, _| {
|
||||
Box::pin(async move {
|
||||
metadata_sys::update(LOCK_CONFIGURATION_MATRIX_BUCKET, OBJECT_LOCK_CONFIG, OBJECT_LOCK.to_vec())
|
||||
.await
|
||||
.expect("seed bucket lock configuration");
|
||||
outcome(put_lock(client, LOCK_CONFIGURATION_MATRIX_BUCKET, LOCK_UPDATE).send().await)
|
||||
})
|
||||
},
|
||||
},
|
||||
MatrixRow {
|
||||
operation: "GetObjectLockConfiguration",
|
||||
metric: S3Operation::GetObjectLockConfiguration,
|
||||
@@ -665,6 +678,7 @@ fn gateway_lifecycle_put_rejects_submillisecond_date() {
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) const LOCK_CONFIGURATION_MATRIX_BUCKET: &str = "lock-configuration-matrix";
|
||||
pub(super) const REPLICATION_MATRIX_BUCKET: &str = "replication-matrix";
|
||||
const REPLICATION_ARN: &str = "arn:rustfs:replication:us-east-1:operator:replica";
|
||||
const REPLICATION_WRITE: &str = concat!(
|
||||
@@ -906,3 +920,143 @@ fn owned_replication_gateway_writes_and_removes_the_config_and_targets() {
|
||||
fn owned_replication_legacy_writes_and_removes_the_config_and_targets() {
|
||||
with_stack(LEGACY, owned_replication_wire_and_disk);
|
||||
}
|
||||
|
||||
const LOCK_UPDATE: &str = "<ObjectLockConfiguration><ObjectLockEnabled>Enabled</ObjectLockEnabled><Rule><DefaultRetention><Mode>COMPLIANCE</Mode><Years>2</Years></DefaultRetention></Rule></ObjectLockConfiguration>";
|
||||
const LOCK_ENABLED_VERSIONING: &[u8] = b"<VersioningConfiguration><Status>Enabled</Status></VersioningConfiguration>";
|
||||
const LOCK_SUSPENDED_VERSIONING: &[u8] = b"<VersioningConfiguration><Status>Suspended</Status></VersioningConfiguration>";
|
||||
|
||||
fn put_lock(
|
||||
client: &Client,
|
||||
bucket: &str,
|
||||
document: &'static str,
|
||||
) -> CustomizableOperation<
|
||||
aws_sdk_s3::operation::put_object_lock_configuration::PutObjectLockConfigurationOutput,
|
||||
aws_sdk_s3::operation::put_object_lock_configuration::PutObjectLockConfigurationError,
|
||||
aws_sdk_s3::operation::put_object_lock_configuration::builders::PutObjectLockConfigurationFluentBuilder,
|
||||
> {
|
||||
client
|
||||
.put_object_lock_configuration()
|
||||
.bucket(bucket)
|
||||
.customize()
|
||||
.mutate_request(move |request| send_document(request, document))
|
||||
}
|
||||
|
||||
async fn lock_bytes(bucket: &str) -> (Vec<u8>, Vec<u8>) {
|
||||
let metadata = metadata_sys::get_config_from_disk(bucket)
|
||||
.await
|
||||
.expect("durable bucket metadata");
|
||||
(metadata.object_lock_config_xml, metadata.versioning_config_xml)
|
||||
}
|
||||
|
||||
async fn put_lock_preserves_responses_and_storage(server: RustFSServer, native: bool) {
|
||||
const BUCKET: &str = "lock-put-ordinary";
|
||||
const RESERVED: &str = "sthree-lock-put-reserved";
|
||||
const PLAIN: &str = "lock-put-plain";
|
||||
const WRITER: &str = "lock-put-writer";
|
||||
for bucket in [BUCKET, RESERVED, PLAIN] {
|
||||
create_bucket_in_the_store(bucket).await;
|
||||
}
|
||||
for bucket in [BUCKET, RESERVED] {
|
||||
metadata_sys::update(bucket, OBJECT_LOCK_CONFIG, OBJECT_LOCK.to_vec())
|
||||
.await
|
||||
.unwrap();
|
||||
metadata_sys::update(bucket, BUCKET_VERSIONING_CONFIG, LOCK_SUSPENDED_VERSIONING.to_vec())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
create_user_allowed_on_one_bucket(WRITER, "s3:PutBucketObjectLockConfiguration", BUCKET).await;
|
||||
let endpoint = server.endpoint();
|
||||
let root = s3_client(&endpoint, server.access_key(), server.secret_key());
|
||||
let writer = s3_client(&endpoint, WRITER, USER_SECRET_KEY);
|
||||
|
||||
let invalid = "<ObjectLockConfiguration><ObjectLockEnabled>Enabled</ObjectLockEnabled><Rule><DefaultRetention><Mode>GOVERNANCE</Mode><Days>0</Days></DefaultRetention></Rule></ObjectLockConfiguration>";
|
||||
for (client, bucket, document, code, status, message) in [
|
||||
(&writer, RESERVED, LOCK_UPDATE, "AccessDenied", 403, "Access Denied"),
|
||||
(
|
||||
&root,
|
||||
"lock-put-missing",
|
||||
invalid,
|
||||
"NoSuchBucket",
|
||||
404,
|
||||
"The specified bucket does not exist",
|
||||
),
|
||||
(
|
||||
&root,
|
||||
PLAIN,
|
||||
LOCK_UPDATE,
|
||||
"InvalidBucketState",
|
||||
409,
|
||||
"Object Lock configuration cannot be enabled on existing buckets",
|
||||
),
|
||||
(
|
||||
&root,
|
||||
BUCKET,
|
||||
invalid,
|
||||
"InvalidRetentionPeriod",
|
||||
400,
|
||||
"Default retention period must be a positive integer value for 'Days'",
|
||||
),
|
||||
] {
|
||||
let before = if bucket == "lock-put-missing" {
|
||||
None
|
||||
} else {
|
||||
Some(lock_bytes(bucket).await)
|
||||
};
|
||||
let refused = put_lock(client, bucket, document)
|
||||
.send()
|
||||
.await
|
||||
.expect_err("refused Object Lock change");
|
||||
let actual = refused.as_service_error().expect("service error");
|
||||
let bytes = if before.is_some() {
|
||||
Some(lock_bytes(bucket).await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
assert_eq!(
|
||||
(
|
||||
actual.code(),
|
||||
refused.raw_response().map(|response| response.status().as_u16()),
|
||||
actual.message(),
|
||||
bytes
|
||||
),
|
||||
(Some(code), Some(status), Some(message), before),
|
||||
"{bucket}",
|
||||
);
|
||||
}
|
||||
|
||||
for (client, bucket) in [(&writer, BUCKET), (&root, RESERVED)] {
|
||||
let before = rustfs_io_metrics::s3_op_metrics_snapshot()
|
||||
.into_iter()
|
||||
.find(|row| row.op == S3Operation::PutObjectLockConfiguration.as_str())
|
||||
.map(|row| row.total);
|
||||
let scanner_before = rustfs_scanner::scanner_dirty_usage_bucket_generation(bucket);
|
||||
let status = StatusCapture::default();
|
||||
let result = put_lock(client, bucket, LOCK_UPDATE).interceptor(status.clone()).send().await;
|
||||
let counts = rustfs_io_metrics::s3_op_metrics_snapshot()
|
||||
.into_iter()
|
||||
.find(|row| row.op == S3Operation::PutObjectLockConfiguration.as_str())
|
||||
.map(|row| row.total);
|
||||
assert_eq!(
|
||||
(outcome(result), status.take(), lock_bytes(bucket).await, counts),
|
||||
(
|
||||
Ok(()),
|
||||
Some(200),
|
||||
(LOCK_UPDATE.as_bytes().to_vec(), LOCK_ENABLED_VERSIONING.to_vec()),
|
||||
if native { Some(before.unwrap_or_default() + 1) } else { None }
|
||||
),
|
||||
"{bucket}",
|
||||
);
|
||||
assert!(rustfs_scanner::scanner_dirty_usage_bucket_generation(bucket) > scanner_before);
|
||||
}
|
||||
server.shutdown().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_put_object_lock_preserves_responses_and_storage() {
|
||||
with_stack(LEGACY, |server| put_lock_preserves_responses_and_storage(server, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_put_object_lock_preserves_responses_and_storage() {
|
||||
with_stack(GATEWAY, |server| put_lock_preserves_responses_and_storage(server, true));
|
||||
}
|
||||
|
||||
@@ -357,6 +357,7 @@ async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_ad
|
||||
bucket_configs::store_read_configs(MATRIX_BUCKET, bucket_configs::ENCRYPTION_MATRIX_BUCKET).await;
|
||||
bucket_core::seed_website(MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(bucket_replication_lifecycle::REPLICATION_MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(bucket_replication_lifecycle::LOCK_CONFIGURATION_MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(object_meta::MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(object_misc::MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(object_read::MATRIX_BUCKET).await;
|
||||
@@ -403,6 +404,7 @@ async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_ad
|
||||
| S3Operation::DeleteBucketWebsite
|
||||
| S3Operation::PutBucketReplication
|
||||
| S3Operation::DeleteBucketReplication
|
||||
| S3Operation::PutObjectLockConfiguration
|
||||
| S3Operation::PutBucketEncryption
|
||||
| S3Operation::PutBucketTagging
|
||||
| S3Operation::DeleteBucketEncryption
|
||||
|
||||
Reference in New Issue
Block a user