mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-17 21:44:21 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 569b946454 |
@@ -2562,9 +2562,6 @@ 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?;
|
||||
}
|
||||
@@ -3757,15 +3754,6 @@ 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
|
||||
@@ -3985,9 +3973,7 @@ 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.restore_copyback {
|
||||
require_multipart_restore_target(opts, fi.version_id)?;
|
||||
} else if opts.versioned && replicated_null_version {
|
||||
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()) {
|
||||
@@ -4602,18 +4588,19 @@ impl crate::storage_api_contracts::multipart::MultipartOperations for SetDisks {
|
||||
)
|
||||
.await?;
|
||||
|
||||
if (opts.restore_copyback || !opts.versioned)
|
||||
if !opts.versioned
|
||||
&& !crate::bucket::utils::is_meta_bucketname(bucket)
|
||||
&& let Some(snapshot) = opts.object_lock_config_snapshot.as_deref()
|
||||
&& !matches!(snapshot.state(), ObjectLockConfigState::ConfirmedAbsent)
|
||||
{
|
||||
// Check the physical replacement, not necessarily the latest version.
|
||||
// Completion replaces the null version, not necessarily the latest
|
||||
// version inspected by the request-level Object Lock check.
|
||||
let current = self
|
||||
.get_object_info(
|
||||
bucket,
|
||||
object,
|
||||
&ObjectOptions {
|
||||
version_id: Some(fi.version_id.unwrap_or_default().to_string()),
|
||||
version_id: Some(Uuid::nil().to_string()),
|
||||
no_lock: true,
|
||||
metadata_cache_safe: false,
|
||||
versioned: opts.versioned,
|
||||
@@ -4629,8 +4616,8 @@ impl crate::storage_api_contracts::multipart::MultipartOperations for SetDisks {
|
||||
}
|
||||
}
|
||||
// A null delete marker has no protected payload to replace.
|
||||
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(StorageError::MethodNotAllowed) => {}
|
||||
Err(err) if is_err_object_not_found(&err) || is_err_version_not_found(&err) => {}
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
}
|
||||
@@ -5245,16 +5232,6 @@ 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
|
||||
@@ -14885,66 +14862,6 @@ 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,9 +12863,6 @@ 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)]
|
||||
{
|
||||
@@ -12967,8 +12964,20 @@ 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,
|
||||
..ropts
|
||||
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()
|
||||
};
|
||||
self_
|
||||
.clone()
|
||||
@@ -17606,12 +17615,7 @@ mod transition_commit_failure_tests {
|
||||
)
|
||||
.await
|
||||
.expect("the injected restore generation should be installed");
|
||||
let mut opts = ObjectOptions {
|
||||
object_lock_config_snapshot: Some(Arc::new(ObjectLockConfigSnapshot::new(
|
||||
ObjectLockConfigState::ConfirmedAbsent,
|
||||
))),
|
||||
..Default::default()
|
||||
};
|
||||
let mut opts = ObjectOptions::default();
|
||||
opts.transition.restore_request.days = Some(1);
|
||||
opts.user_defined = restore_operation_id_metadata(operation_id);
|
||||
set_disks
|
||||
@@ -17675,10 +17679,7 @@ mod transition_commit_failure_tests {
|
||||
)
|
||||
.await
|
||||
.expect("the successful restore generation should be installed");
|
||||
let mut opts = ObjectOptions {
|
||||
object_lock_config_snapshot: Some(Arc::new(ObjectLockConfigSnapshot::new(ObjectLockConfigState::ConfirmedAbsent))),
|
||||
..Default::default()
|
||||
};
|
||||
let mut opts = ObjectOptions::default();
|
||||
opts.transition.restore_request.days = Some(1);
|
||||
opts.user_defined = restore_operation_id_metadata(operation_id);
|
||||
set_disks
|
||||
@@ -18032,10 +18033,7 @@ mod transition_commit_failure_tests {
|
||||
)
|
||||
.await
|
||||
.expect("the restore generation should be installed");
|
||||
let mut restore_opts = ObjectOptions {
|
||||
object_lock_config_snapshot: Some(Arc::new(ObjectLockConfigSnapshot::new(ObjectLockConfigState::ConfirmedAbsent))),
|
||||
..Default::default()
|
||||
};
|
||||
let mut restore_opts = ObjectOptions::default();
|
||||
restore_opts.transition.restore_request.days = Some(1);
|
||||
restore_opts.user_defined = restore_operation_id_metadata(operation_id);
|
||||
set_disks
|
||||
|
||||
@@ -6878,8 +6878,7 @@ 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?;
|
||||
// Even an unqualified restore copies back to an existing version.
|
||||
if !is_meta_bucketname(bucket) {
|
||||
if opts.overwrites_existing_version() && !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. 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.
|
||||
5. Give RustFS exclusive ownership of every endpoint path.
|
||||
|
||||
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:
|
||||
|
||||
|
||||
+18
-38
@@ -16,7 +16,7 @@ use crate::version;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
/// Update check related errors
|
||||
#[derive(Error, Debug)]
|
||||
@@ -59,8 +59,6 @@ pub struct UpdateCheckResult {
|
||||
|
||||
/// Version checker
|
||||
pub struct VersionChecker {
|
||||
/// HTTP client
|
||||
client: reqwest::Client,
|
||||
/// Version server URL
|
||||
version_url: String,
|
||||
/// Request timeout
|
||||
@@ -73,52 +71,40 @@ impl Default for VersionChecker {
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the update-check HTTP client without panicking when the host has no
|
||||
/// system CA bundle (issue #6734): `reqwest::Client::new()` panics for the
|
||||
/// same reason a builder `build()` fails, so falling back to it turned a
|
||||
/// degraded environment into a process abort. With an explicit empty trust
|
||||
/// store the HTTPS version check fails closed per request instead.
|
||||
fn version_check_client(timeout: Duration) -> reqwest::Client {
|
||||
let builder = || {
|
||||
reqwest::Client::builder()
|
||||
.timeout(timeout)
|
||||
.user_agent(format!("RustFS/{}", get_current_version()))
|
||||
};
|
||||
builder().build().unwrap_or_else(|error| {
|
||||
warn!("update-check HTTP client could not load system TLS roots ({error}); continuing with an empty trust store");
|
||||
builder()
|
||||
.tls_certs_only(std::iter::empty::<reqwest::Certificate>())
|
||||
.build()
|
||||
.expect("HTTP client construction must succeed with an explicit empty trust store")
|
||||
})
|
||||
fn version_check_client(timeout: Duration, version: &str) -> Result<reqwest::Client, reqwest::Error> {
|
||||
reqwest::Client::builder()
|
||||
.timeout(timeout)
|
||||
.user_agent(format!("RustFS/{version}"))
|
||||
.build()
|
||||
}
|
||||
|
||||
impl VersionChecker {
|
||||
/// Create a new version checker
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
client: version_check_client(Duration::from_secs(10)),
|
||||
version_url: "https://version.rustfs.com/latest.json".to_string(),
|
||||
timeout: Duration::from_secs(10),
|
||||
}
|
||||
Self::with_config("https://version.rustfs.com/latest.json".to_string(), Duration::from_secs(10))
|
||||
}
|
||||
|
||||
/// Create version checker with custom configuration
|
||||
pub fn with_config(url: String, timeout: Duration) -> Self {
|
||||
Self {
|
||||
client: version_check_client(timeout),
|
||||
version_url: url,
|
||||
timeout,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check for updates
|
||||
/// Check for updates.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the HTTP client cannot be initialized, the request
|
||||
/// fails, or the response does not contain usable version information.
|
||||
pub async fn check_for_updates(&self) -> Result<UpdateCheckResult, UpdateCheckError> {
|
||||
let current_version = get_current_version();
|
||||
let client = version_check_client(self.timeout, ¤t_version)?;
|
||||
debug!("Checking for updates, current version: {}", current_version);
|
||||
|
||||
// Send HTTP GET request to get latest version information
|
||||
let response = self.client.get(&self.version_url).timeout(self.timeout).send().await?;
|
||||
let response = client.get(&self.version_url).send().await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
let status = response.status();
|
||||
@@ -190,16 +176,10 @@ pub async fn check_updates_with_url(url: String) -> Result<UpdateCheckResult, Up
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// The startup panic fix for hosts without a CA bundle (issue #6734) rests
|
||||
// on the constructor never panicking and its degraded fallback — an
|
||||
// explicit empty trust store — always building.
|
||||
#[test]
|
||||
fn version_check_client_construction_never_panics() {
|
||||
let _ = version_check_client(Duration::from_secs(1));
|
||||
reqwest::Client::builder()
|
||||
.tls_certs_only(std::iter::empty::<reqwest::Certificate>())
|
||||
.build()
|
||||
.expect("empty-trust-store client build must succeed without touching system roots");
|
||||
fn invalid_version_header_does_not_panic() {
|
||||
let error = version_check_client(Duration::from_secs(1), "refs/tags/1.0.6\u{7f}").unwrap_err();
|
||||
assert!(error.is_builder());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user