mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-17 21:44:21 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b13deb567 | |||
| 4aded279ae |
@@ -2562,6 +2562,9 @@ impl SetDisks {
|
||||
opts: &ObjectOptions,
|
||||
) -> Result<ObjectInfo> {
|
||||
Self::validate_completed_multipart_publication(bucket, object, upload_id, &completed)?;
|
||||
if opts.restore_copyback {
|
||||
require_multipart_restore_target(opts, completed.version_id)?;
|
||||
}
|
||||
if let Some(publication) = publication_identity(&completed)? {
|
||||
confirm_target(disks, &publication, &self.multipart_proof_verification_context()).await?;
|
||||
}
|
||||
@@ -3754,6 +3757,15 @@ impl crate::storage_api_contracts::multipart::MultipartOperations for SetDisks {
|
||||
.await?;
|
||||
|
||||
let expected_restore_operation_id = restore_commit_operation_id_from_metadata(&opts.user_defined)?;
|
||||
if opts.restore_copyback
|
||||
&& !crate::bucket::utils::is_meta_bucketname(bucket)
|
||||
&& opts
|
||||
.object_lock_config_snapshot
|
||||
.as_deref()
|
||||
.is_none_or(|snapshot| matches!(snapshot.state(), ObjectLockConfigState::Fabricated))
|
||||
{
|
||||
return Err(Error::other("multipart restore requires an authoritative Object Lock snapshot"));
|
||||
}
|
||||
let (mut fi, mut files_metas) = match self
|
||||
.check_upload_id_exists_with_opts(bucket, object, upload_id, true, opts)
|
||||
.await
|
||||
@@ -3973,7 +3985,9 @@ impl crate::storage_api_contracts::multipart::MultipartOperations for SetDisks {
|
||||
// completion in a versioned bucket gets a concrete version.
|
||||
let replicated_null_version = fi.version_id.is_none_or(|version_id| version_id.is_nil())
|
||||
&& (opts.replication_request || opts.delete_marker_replication_status() == ReplicationStatusType::Replica);
|
||||
if opts.versioned && replicated_null_version {
|
||||
if opts.restore_copyback {
|
||||
require_multipart_restore_target(opts, fi.version_id)?;
|
||||
} else if opts.versioned && replicated_null_version {
|
||||
fi.version_id = Some(Uuid::nil());
|
||||
} else if opts.versioned {
|
||||
fi.version_id = Some(match fi.version_id.filter(|version_id| !version_id.is_nil()) {
|
||||
@@ -4588,19 +4602,18 @@ impl crate::storage_api_contracts::multipart::MultipartOperations for SetDisks {
|
||||
)
|
||||
.await?;
|
||||
|
||||
if !opts.versioned
|
||||
if (opts.restore_copyback || !opts.versioned)
|
||||
&& !crate::bucket::utils::is_meta_bucketname(bucket)
|
||||
&& let Some(snapshot) = opts.object_lock_config_snapshot.as_deref()
|
||||
&& !matches!(snapshot.state(), ObjectLockConfigState::ConfirmedAbsent)
|
||||
{
|
||||
// Completion replaces the null version, not necessarily the latest
|
||||
// version inspected by the request-level Object Lock check.
|
||||
// Check the physical replacement, not necessarily the latest version.
|
||||
let current = self
|
||||
.get_object_info(
|
||||
bucket,
|
||||
object,
|
||||
&ObjectOptions {
|
||||
version_id: Some(Uuid::nil().to_string()),
|
||||
version_id: Some(fi.version_id.unwrap_or_default().to_string()),
|
||||
no_lock: true,
|
||||
metadata_cache_safe: false,
|
||||
versioned: opts.versioned,
|
||||
@@ -4616,8 +4629,8 @@ impl crate::storage_api_contracts::multipart::MultipartOperations for SetDisks {
|
||||
}
|
||||
}
|
||||
// A null delete marker has no protected payload to replace.
|
||||
Err(StorageError::MethodNotAllowed) => {}
|
||||
Err(err) if is_err_object_not_found(&err) || is_err_version_not_found(&err) => {}
|
||||
Err(StorageError::MethodNotAllowed) if !opts.restore_copyback => {}
|
||||
Err(err) if !opts.restore_copyback && (is_err_object_not_found(&err) || is_err_version_not_found(&err)) => {}
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
}
|
||||
@@ -5232,6 +5245,16 @@ fn preserves_staged_encrypted_etag_proof(fi: &FileInfo, opts: &ObjectOptions, re
|
||||
&& get_consistent_str(&fi.metadata, rustfs_utils::http::SUFFIX_OPAQUE_ENCRYPTED_ETAG) == Some("v1")
|
||||
}
|
||||
|
||||
// A missing ID on disk denotes the null version, but a missing request ID
|
||||
// means "latest" and cannot authorize publication to a particular version.
|
||||
fn require_multipart_restore_target(opts: &ObjectOptions, physical: Option<Uuid>) -> Result<()> {
|
||||
let selected = opts.version_id.as_deref().ok_or(StorageError::PreconditionFailed)?;
|
||||
if Uuid::parse_str(selected)? != physical.unwrap_or_default() {
|
||||
return Err(StorageError::PreconditionFailed);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Final ETag for a completed multipart object. An authorized replication
|
||||
/// request preserves the source ETag so the replication HEAD comparison
|
||||
/// converges even when the source ETag is not derivable from the uploaded
|
||||
@@ -14862,6 +14885,66 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn multipart_restore_preserves_explicit_target_across_versioning_modes() {
|
||||
let (_temp_dirs, disk_stores, set_disks) = hermetic_set_disks(4).await;
|
||||
let bucket = "restore-target-bucket";
|
||||
make_bucket_on_all(&disk_stores, bucket).await;
|
||||
for (index, (versioned, selected)) in [
|
||||
(true, Uuid::nil()),
|
||||
(true, Uuid::new_v4()),
|
||||
(false, Uuid::nil()),
|
||||
(false, Uuid::new_v4()),
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let object = format!("object-{index}");
|
||||
let create_opts = ObjectOptions {
|
||||
versioned,
|
||||
version_suspended: !versioned,
|
||||
version_id: Some(selected.to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
let (upload, parts) =
|
||||
stage_upload_with_create_opts(&set_disks, bucket, &object, b"copy-back", &create_opts).await;
|
||||
let mut complete_opts = ObjectOptions {
|
||||
restore_copyback: true,
|
||||
..create_opts
|
||||
};
|
||||
assert!(
|
||||
set_disks
|
||||
.clone()
|
||||
.complete_multipart_upload(bucket, &object, &upload, parts.clone(), &complete_opts)
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
complete_opts.object_lock_config_snapshot =
|
||||
Some(Arc::new(ObjectLockConfigSnapshot::new(ObjectLockConfigState::ConfirmedAbsent)));
|
||||
complete_opts.version_id = Some(Uuid::new_v4().to_string());
|
||||
assert!(matches!(
|
||||
set_disks
|
||||
.clone()
|
||||
.complete_multipart_upload(bucket, &object, &upload, parts.clone(), &complete_opts)
|
||||
.await,
|
||||
Err(StorageError::PreconditionFailed)
|
||||
));
|
||||
complete_opts.version_id = Some(selected.to_string());
|
||||
let result = set_disks
|
||||
.clone()
|
||||
.complete_multipart_upload(bucket, &object, &upload, parts, &complete_opts)
|
||||
.await
|
||||
.expect("publish to staged version");
|
||||
assert_eq!(result.version_id, Some(selected));
|
||||
let stored = set_disks
|
||||
.get_object_info(bucket, &object, &complete_opts)
|
||||
.await
|
||||
.expect("read exact version");
|
||||
assert_eq!(stored.version_id, Some(selected));
|
||||
}
|
||||
}
|
||||
|
||||
/// Read the whole committed object back; returns `(body, etag)`. The full
|
||||
/// body read also proves the served length matches (never a torn/short body).
|
||||
async fn read_object(set_disks: &Arc<SetDisks>, bucket: &str, object: &str) -> (Vec<u8>, Option<String>) {
|
||||
|
||||
@@ -12863,6 +12863,9 @@ impl crate::storage_api_contracts::object::ObjectOperations for SetDisks {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Even an unversioned source has a specific physical target: omitting
|
||||
// its null ID here would let MPU creation choose a new version.
|
||||
ropts.version_id = Some(actual_fi.version_id.unwrap_or_default().to_string());
|
||||
let res = self_.clone().new_multipart_upload(bucket, object, &ropts).await?;
|
||||
#[cfg(test)]
|
||||
{
|
||||
@@ -12964,20 +12967,8 @@ impl crate::storage_api_contracts::object::ObjectOperations for SetDisks {
|
||||
.etag = Some("injected-invalid-complete-etag".to_string());
|
||||
}
|
||||
let complete_opts = ObjectOptions {
|
||||
mod_time: oi.mod_time,
|
||||
version_id: oi.version_id.map(|version| version.to_string()),
|
||||
expected_bucket_incarnation_id: opts.expected_bucket_incarnation_id,
|
||||
bucket_lifecycle_lock_fence: opts.bucket_lifecycle_lock_fence.clone(),
|
||||
user_defined: restore_commit_metadata,
|
||||
no_lock: false,
|
||||
restore_copyback: true,
|
||||
decommission_capacity_admission: opts.decommission_capacity_admission.clone(),
|
||||
// The composite ETag would otherwise be recomputed from the
|
||||
// parts as they were written back, which for an encrypted or
|
||||
// compressed object digests stored bytes rather than the
|
||||
// object's public ETag.
|
||||
preserve_etag: oi.etag.clone(),
|
||||
..Default::default()
|
||||
..ropts
|
||||
};
|
||||
self_
|
||||
.clone()
|
||||
@@ -17615,7 +17606,12 @@ mod transition_commit_failure_tests {
|
||||
)
|
||||
.await
|
||||
.expect("the injected restore generation should be installed");
|
||||
let mut opts = ObjectOptions::default();
|
||||
let mut opts = ObjectOptions {
|
||||
object_lock_config_snapshot: Some(Arc::new(ObjectLockConfigSnapshot::new(
|
||||
ObjectLockConfigState::ConfirmedAbsent,
|
||||
))),
|
||||
..Default::default()
|
||||
};
|
||||
opts.transition.restore_request.days = Some(1);
|
||||
opts.user_defined = restore_operation_id_metadata(operation_id);
|
||||
set_disks
|
||||
@@ -17679,7 +17675,10 @@ mod transition_commit_failure_tests {
|
||||
)
|
||||
.await
|
||||
.expect("the successful restore generation should be installed");
|
||||
let mut opts = ObjectOptions::default();
|
||||
let mut opts = ObjectOptions {
|
||||
object_lock_config_snapshot: Some(Arc::new(ObjectLockConfigSnapshot::new(ObjectLockConfigState::ConfirmedAbsent))),
|
||||
..Default::default()
|
||||
};
|
||||
opts.transition.restore_request.days = Some(1);
|
||||
opts.user_defined = restore_operation_id_metadata(operation_id);
|
||||
set_disks
|
||||
@@ -18033,7 +18032,10 @@ mod transition_commit_failure_tests {
|
||||
)
|
||||
.await
|
||||
.expect("the restore generation should be installed");
|
||||
let mut restore_opts = ObjectOptions::default();
|
||||
let mut restore_opts = ObjectOptions {
|
||||
object_lock_config_snapshot: Some(Arc::new(ObjectLockConfigSnapshot::new(ObjectLockConfigState::ConfirmedAbsent))),
|
||||
..Default::default()
|
||||
};
|
||||
restore_opts.transition.restore_request.days = Some(1);
|
||||
restore_opts.user_defined = restore_operation_id_metadata(operation_id);
|
||||
set_disks
|
||||
|
||||
@@ -6878,7 +6878,8 @@ impl ECStore {
|
||||
let object = encode_dir_object(object);
|
||||
let opts = transition_restore_pool_opts(opts);
|
||||
let (mut opts, _bucket_lifecycle_guard) = self.guard_multipart_bucket_incarnation(bucket, &opts).await?;
|
||||
if opts.overwrites_existing_version() && !is_meta_bucketname(bucket) {
|
||||
// Even an unqualified restore copies back to an existing version.
|
||||
if !is_meta_bucketname(bucket) {
|
||||
let expected_incarnation_id = opts
|
||||
.expected_bucket_incarnation_id
|
||||
.ok_or_else(|| Error::other("restore is missing its bucket incarnation snapshot"))?;
|
||||
|
||||
@@ -28,7 +28,7 @@ Runtime roles:
|
||||
2. Pick each pool's set width. Pools may differ in width, but each pool must split evenly into sets of one width from `SET_SIZES`; `RUSTFS_ERASURE_SET_DRIVE_COUNT` may pin a width that is already a symmetric divisor, nothing else.
|
||||
3. Pick STANDARD and RRS parity per §4, then validate against the narrowest pool, because an explicit parity must fit every pool.
|
||||
4. Record the full launch command, endpoint order, pool order, set width, and storage-class variables. They must be identical on every node and on every restart.
|
||||
5. Give RustFS exclusive ownership of every endpoint path.
|
||||
5. Give RustFS exclusive ownership of every endpoint path. For a separate deployment, use independently mounted drives with non-overlapping storage roots and separate service endpoints. Do not point a new deployment at an existing drive root or a directory inside it: the parent deployment owns that entire tree. For example, if `/data/rustfs1` already belongs to a cluster, `/data/rustfs1/test` is not a safe drive for another cluster, even if it starts empty. To test a different topology without changing the original cluster, start it on separate drives or in an isolated lab and copy any test data through S3. Do not write `format.json` by hand to make either deployment start.
|
||||
|
||||
Volumes come from positional arguments or `RUSTFS_VOLUMES`; `rustfs` with no arguments behaves as `rustfs server` with volumes from the environment (`rustfs/src/config/cli.rs`). Ellipsis expansion follows MinIO:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user