mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-26 18:32:42 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ef63577e8 | |||
| 2e9e206d02 |
@@ -106,6 +106,8 @@ when restoring `/rustfs/console` for a custom OEM build.
|
||||
## Distributed endpoint locality
|
||||
|
||||
- `RUSTFS_LOCAL_ENDPOINT_HOST` identifies this server's host in a distributed `RUSTFS_VOLUMES` topology without resolving every peer during startup. Set it to exactly one host, without a scheme, port, or path. It is accepted only for orchestrated URL topologies and must match at least one endpoint on the RustFS server port; invalid or unmatched values fail startup. Leave it unset to retain DNS-based locality discovery.
|
||||
- DNS-based discovery resolves each configured hostname once successfully per startup and reuses the result across drives and pools. If discovery finds no local endpoint, startup exits before opening the service listener. Check that this member's advertised hostname resolves to an address on a local interface and that its endpoint port matches `RUSTFS_ADDRESS`. The next start resolves the hosts again.
|
||||
- A finite, positive `RUSTFS_STARTUP_TOPOLOGY_WAIT_TIMEOUT` bounds how long endpoint discovery waits for DNS, including lookups and retry delays. If it expires during startup, the CLI reports the error and exits without waiting for an already-running system resolver call.
|
||||
|
||||
## Scanner environment aliases
|
||||
|
||||
|
||||
@@ -680,13 +680,11 @@ async fn test_copy_object_does_not_inherit_source_legal_hold() {
|
||||
.key("implicit-copy")
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
.expect_err("copy should not inherit the source hold");
|
||||
assert_eq!(implicit_legal_hold.raw_response().map(|response| response.status().as_u16()), Some(404));
|
||||
assert_eq!(
|
||||
implicit_legal_hold
|
||||
.legal_hold()
|
||||
.and_then(|value| value.status())
|
||||
.map(|value| value.as_str()),
|
||||
Some("OFF")
|
||||
implicit_legal_hold.as_service_error().and_then(ProvideErrorMetadata::code),
|
||||
Some("NoSuchObjectLockConfiguration")
|
||||
);
|
||||
|
||||
client
|
||||
@@ -2028,12 +2026,12 @@ async fn test_copy_object_retention_uses_destination_policy() {
|
||||
.key("no-default-copy")
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
let no_default_retention = no_default_retention
|
||||
.retention()
|
||||
.expect("retention response should be present");
|
||||
assert!(no_default_retention.mode().is_none());
|
||||
assert!(no_default_retention.retain_until_date().is_none());
|
||||
.expect_err("copy should have no retention without a destination default");
|
||||
assert_eq!(no_default_retention.raw_response().map(|response| response.status().as_u16()), Some(404));
|
||||
assert_eq!(
|
||||
no_default_retention.as_service_error().and_then(ProvideErrorMetadata::code),
|
||||
Some("NoSuchObjectLockConfiguration")
|
||||
);
|
||||
|
||||
let retained_version_id = put_object_with_retention(
|
||||
&client,
|
||||
|
||||
@@ -230,10 +230,10 @@ pub mod bucket {
|
||||
ObjectLockConfigState, ScannerBucketIncarnationReadGuard, acquire_bucket_metadata_transaction_lock,
|
||||
acquire_bucket_metadata_transaction_lock_for_incarnation, acquire_scanner_bucket_incarnation_fence,
|
||||
acquire_scanner_bucket_incarnation_read_fence, capture_bucket_metadata_incarnation, delete, delete_if_incarnation,
|
||||
delete_if_incarnation_at, delete_under_transaction_lock, get, get_accelerate_config, get_bucket_policy,
|
||||
get_bucket_policy_raw, get_bucket_targets_config, get_config_from_disk, get_cors_config, get_durability_config,
|
||||
get_etag_config, get_global_bucket_metadata_sys, get_lifecycle_config, get_logging_config, get_notification_config,
|
||||
get_object_lock_config, get_object_lock_config_state, get_on_demand_migration_config,
|
||||
delete_if_incarnation_at, delete_under_transaction_lock, find_object_lock_config_state, get, get_accelerate_config,
|
||||
get_bucket_policy, get_bucket_policy_raw, get_bucket_targets_config, get_config_from_disk, get_cors_config,
|
||||
get_durability_config, get_etag_config, get_global_bucket_metadata_sys, get_lifecycle_config, get_logging_config,
|
||||
get_notification_config, get_object_lock_config, get_object_lock_config_state, get_on_demand_migration_config,
|
||||
get_on_demand_migration_config_in, get_public_access_block_config, get_quota_config, get_replication_config,
|
||||
get_request_payment_config, get_s3_tagging_config, get_sse_config, get_tagging_config, get_versioning_config,
|
||||
get_website_config, init_bucket_metadata_sys, list_bucket_targets, reload_bucket_metadata, remove_bucket_metadata,
|
||||
|
||||
@@ -151,6 +151,15 @@ pub enum ObjectLockConfigState {
|
||||
Fabricated,
|
||||
}
|
||||
|
||||
// Only namespace probes can name the requested bucket. Internal metadata
|
||||
// storage errors must not be mistaken for absence of that bucket.
|
||||
fn bucket_namespace_error(bucket: &str, error: Error) -> Error {
|
||||
match error {
|
||||
Error::VolumeNotFound => Error::BucketNotFound(bucket.to_owned()),
|
||||
error => error,
|
||||
}
|
||||
}
|
||||
|
||||
enum BucketMetadataAuthority {
|
||||
Authoritative(Arc<BucketMetadata>),
|
||||
Fabricated,
|
||||
@@ -1695,6 +1704,24 @@ pub async fn get_object_lock_config_state(bucket: &str) -> Result<ObjectLockConf
|
||||
bucket_meta_sys.get_object_lock_config_state(bucket).await
|
||||
}
|
||||
|
||||
/// Read Object Lock state from authoritative bucket metadata.
|
||||
///
|
||||
/// `Ok(None)` means the bucket is confirmed missing. An existing bucket with
|
||||
/// no Object Lock configuration returns `Some(ConfirmedAbsent)`.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns storage, migration, or validation errors when the state cannot be read.
|
||||
pub async fn find_object_lock_config_state(bucket: &str) -> Result<Option<ObjectLockConfigState>> {
|
||||
let bucket_meta_sys_lock = get_bucket_metadata_sys()?;
|
||||
let bucket_meta_sys = bucket_meta_sys_lock.read().await.clone();
|
||||
|
||||
match bucket_meta_sys.find_object_lock_config_state(bucket).await {
|
||||
Err(Error::BucketNotFound(name)) if name == bucket => Ok(None),
|
||||
result => result,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn get_object_lock_config_state_in(
|
||||
ctx: &crate::runtime::instance::InstanceContext,
|
||||
bucket: &str,
|
||||
@@ -3201,14 +3228,16 @@ impl BucketMetadataSys {
|
||||
Box::pin(async {
|
||||
let store = self.object_store();
|
||||
let options = crate::storage_api_contracts::bucket::BucketOptions::default();
|
||||
if require_write_quorum {
|
||||
store.get_bucket_info_from_sets(bucket, &options).await.map(|_| ())
|
||||
let info = if require_write_quorum {
|
||||
store.get_bucket_info_from_sets(bucket, &options).await
|
||||
} else {
|
||||
store.check_bucket_presence_at_read_quorum(bucket).await
|
||||
}
|
||||
store.get_bucket_info_from_sets_at_read_quorum(bucket, &options).await
|
||||
};
|
||||
info.map(|_| ())
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|err| bucket_namespace_error(bucket, err))?;
|
||||
if guard.is_lock_lost() {
|
||||
return Err(Error::other(format!(
|
||||
"bucket namespace lock was lost before lazy bucket metadata publish: {bucket}"
|
||||
@@ -3368,14 +3397,18 @@ impl BucketMetadataSys {
|
||||
}
|
||||
|
||||
pub async fn get_object_lock_config_state(&self, bucket: &str) -> Result<ObjectLockConfigState> {
|
||||
match self.get_metadata_authority(bucket).await? {
|
||||
BucketMetadataAuthority::Authoritative(bm) => object_lock_config_state_from_authoritative_metadata(&bm),
|
||||
BucketMetadataAuthority::Fabricated => match self.migrate_legacy_metadata(bucket).await? {
|
||||
BucketMetadataAuthority::Authoritative(bm) => object_lock_config_state_from_authoritative_metadata(&bm),
|
||||
BucketMetadataAuthority::MissingBucket => Err(Error::ConfigNotFound),
|
||||
BucketMetadataAuthority::Fabricated => Ok(ObjectLockConfigState::Fabricated),
|
||||
},
|
||||
BucketMetadataAuthority::MissingBucket => Err(Error::ConfigNotFound),
|
||||
self.find_object_lock_config_state(bucket).await?.ok_or(Error::ConfigNotFound)
|
||||
}
|
||||
|
||||
async fn find_object_lock_config_state(&self, bucket: &str) -> Result<Option<ObjectLockConfigState>> {
|
||||
let authority = match self.get_metadata_authority(bucket).await? {
|
||||
BucketMetadataAuthority::Fabricated => self.migrate_legacy_metadata(bucket).await?,
|
||||
authority => authority,
|
||||
};
|
||||
match authority {
|
||||
BucketMetadataAuthority::Authoritative(bm) => object_lock_config_state_from_authoritative_metadata(&bm).map(Some),
|
||||
BucketMetadataAuthority::Fabricated => Ok(Some(ObjectLockConfigState::Fabricated)),
|
||||
BucketMetadataAuthority::MissingBucket => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3515,7 +3548,8 @@ impl BucketMetadataSys {
|
||||
self.object_store()
|
||||
.get_bucket_info_from_sets(bucket, &crate::storage_api_contracts::bucket::BucketOptions::default()),
|
||||
)
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|err| bucket_namespace_error(bucket, err))?;
|
||||
|
||||
let (mut metadata, persisted) = await_bucket_namespace_operation(
|
||||
Some(&namespace_guard),
|
||||
@@ -3768,12 +3802,19 @@ impl BucketMetadataSys {
|
||||
#[cfg(test)]
|
||||
self.authority_disk_loads.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
|
||||
let (bucket_presence_res, metadata_res) = tokio::join!(
|
||||
let (bucket_info_res, metadata_res) = tokio::join!(
|
||||
Box::pin(await_bucket_namespace_operation(
|
||||
Some(guard),
|
||||
bucket,
|
||||
"bucket metadata snapshot existence check",
|
||||
store.check_bucket_presence_at_read_quorum(bucket),
|
||||
async {
|
||||
store
|
||||
.get_bucket_info_from_sets_at_read_quorum(
|
||||
bucket,
|
||||
&crate::storage_api_contracts::bucket::BucketOptions::default(),
|
||||
)
|
||||
.await
|
||||
},
|
||||
)),
|
||||
Box::pin(await_bucket_namespace_operation(
|
||||
Some(guard),
|
||||
@@ -3782,8 +3823,8 @@ impl BucketMetadataSys {
|
||||
load_bucket_metadata_parse_with_presence(Arc::clone(&store), bucket, false),
|
||||
)),
|
||||
);
|
||||
match bucket_presence_res {
|
||||
Ok(()) => {}
|
||||
match bucket_info_res {
|
||||
Ok(_) => {}
|
||||
Err(Error::VolumeNotFound) => return Ok(BucketMetadataAuthority::MissingBucket),
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
@@ -4556,14 +4597,17 @@ mod tests {
|
||||
sys.get_bucket_policy("migration-write-failure").await,
|
||||
Err(Error::ConfigNotFound)
|
||||
));
|
||||
assert!(sys.get_object_lock_config_state("migration-write-failure").await.is_err());
|
||||
assert!(sys.find_object_lock_config_state("migration-write-failure").await.is_err());
|
||||
assert!(sys.get("migration-write-failure").await.is_err());
|
||||
sys.legacy_migration_write_error.store(false, Ordering::Relaxed);
|
||||
|
||||
let loads_before = sys.lazy_disk_loads.load(Ordering::Relaxed);
|
||||
assert!(sys.find_object_lock_config_state("missing-bucket").await.unwrap().is_none());
|
||||
assert!(matches!(
|
||||
sys.get_object_lock_config_state("missing-bucket").await,
|
||||
Err(Error::ConfigNotFound)
|
||||
));
|
||||
assert_eq!(sys.lazy_disk_loads.load(Ordering::Relaxed), loads_before + 1);
|
||||
assert!(matches!(sys.get_bucket_policy("missing-bucket").await, Err(Error::ConfigNotFound)));
|
||||
assert!(matches!(sys.get_bucket_policy_raw("missing-bucket").await, Err(Error::ConfigNotFound)));
|
||||
|
||||
@@ -5282,14 +5326,14 @@ mod tests {
|
||||
// be lazily republished as a live bucket generation.
|
||||
let mut deleted_lazy = BucketMetadata::new("deleted-lazy-bucket");
|
||||
deleted_lazy.policy_config_json = b"stale-generation".to_vec();
|
||||
sys.persist_and_set(deleted_lazy)
|
||||
sys.persist_new_and_set(deleted_lazy)
|
||||
.await
|
||||
.expect("stale metadata should persist");
|
||||
.expect("stale committed metadata should persist");
|
||||
sys.metadata_map.write().await.remove("deleted-lazy-bucket");
|
||||
assert!(
|
||||
sys.get_config("deleted-lazy-bucket").await.is_err(),
|
||||
"lazy load must fail when the physical bucket no longer exists"
|
||||
);
|
||||
assert!(matches!(
|
||||
sys.get_config("deleted-lazy-bucket").await,
|
||||
Err(Error::BucketNotFound(name)) if name == "deleted-lazy-bucket"
|
||||
));
|
||||
assert!(sys.get("deleted-lazy-bucket").await.is_err());
|
||||
|
||||
// (d) The namespace generation fence must be acquired before lazy
|
||||
|
||||
@@ -32,8 +32,8 @@ use crate::disk::{
|
||||
DeleteRecoveryInspection, DeleteRecoveryPage, DeleteRecoveryRpcOperation, DeleteRecoveryRpcReply, DiskAPI, DiskInfo,
|
||||
DiskInfoOptions, DiskLocation, DiskOption, FileInfoVersions, FileReader, FileWriter, GuardedDeleteVersionsPayload,
|
||||
GuardedFileInfoVersions, PartTransactionAction, PoolMetaNativeRecoveryRequest, PoolMetaNativeRecoveryResponse,
|
||||
ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameDataGuards, RenameDataObservation, RenameDataResp,
|
||||
RenameDispatchDeadline, SnapshotLeaseToken, UpdateMetadataOpts, VolumeInfo, WalkDirOptions, batch_read_version_one_by_one,
|
||||
ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameDataResp, SnapshotLeaseToken, UpdateMetadataOpts, VolumeInfo,
|
||||
WalkDirOptions, batch_read_version_one_by_one,
|
||||
disk_store::{
|
||||
DEFAULT_RUSTFS_DRIVE_ACTIVE_MONITORING, ENV_RUSTFS_DRIVE_ACTIVE_MONITORING, SKIP_IF_SUCCESS_BEFORE,
|
||||
get_drive_active_check_interval, get_drive_active_check_timeout, get_drive_disk_info_timeout, get_drive_list_dir_timeout,
|
||||
@@ -3313,25 +3313,6 @@ fn validate_decoded_file_info(file_info: &FileInfo) -> Result<()> {
|
||||
file_info.validate_for_metadata_read().map_err(Into::into)
|
||||
}
|
||||
|
||||
// Dropping preparation is safe only before the mutation enters the transport.
|
||||
async fn before_rename_dispatch<T>(mut deadline: Option<RenameDispatchDeadline>, prepare: impl Future<Output = T>) -> Option<T> {
|
||||
let Some(deadline) = deadline.as_mut() else {
|
||||
return Some(prepare.await);
|
||||
};
|
||||
tokio::select! {
|
||||
biased;
|
||||
result = prepare => Some(result),
|
||||
() = async {
|
||||
let at = deadline.wait_for(Option::is_some).await.ok().and_then(|deadline| *deadline);
|
||||
if let Some(at) = at {
|
||||
time::sleep_until(at).await;
|
||||
} else {
|
||||
std::future::pending::<()>().await;
|
||||
}
|
||||
} => None,
|
||||
}
|
||||
}
|
||||
|
||||
impl RemoteDisk {
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn rename_data_borrowed(
|
||||
@@ -3354,7 +3335,6 @@ impl RemoteDisk {
|
||||
dst_volume: &str,
|
||||
dst_path: &str,
|
||||
items: Vec<RenameBatchClientItem<'_>>,
|
||||
dispatch_deadline: Option<RenameDispatchDeadline>,
|
||||
) -> std::result::Result<RemoteRenameBatchStream, RenameBatchStartError> {
|
||||
if self.rename_admission.is_none() || items.is_empty() || items.len() > 16 {
|
||||
return Err(RenameBatchStartError::NotDispatched(DiskError::UnsupportedDisk));
|
||||
@@ -3374,35 +3354,20 @@ impl RemoteDisk {
|
||||
if let Some(error) = self.offline_bypass_error() {
|
||||
return Err(RenameBatchStartError::NotDispatched(error));
|
||||
}
|
||||
let prepared = before_rename_dispatch(dispatch_deadline, async {
|
||||
let routing = super::client::node_service_rename_batch_client(
|
||||
&self.addr,
|
||||
TonicInterceptor::Signature(gen_tonic_signature_interceptor()),
|
||||
);
|
||||
let client = match tokio::time::timeout_at(deadline, routing).await {
|
||||
Ok(Ok(Some(client))) => client,
|
||||
Ok(Ok(None)) => return Err(RenameBatchStartError::UnsupportedBeforeStream),
|
||||
Ok(Err(error)) => {
|
||||
return Err(RenameBatchStartError::NotDispatched(DiskError::RemoteClientUnavailable(
|
||||
error.to_string(),
|
||||
)));
|
||||
}
|
||||
Err(_) => return Err(RenameBatchStartError::NotDispatched(DiskError::Timeout)),
|
||||
};
|
||||
let admission = self
|
||||
.acquire_rename_admission_until(items.len(), deadline)
|
||||
.await
|
||||
.map_err(RenameBatchStartError::NotDispatched)?;
|
||||
let guard = RenameBatchCallGuard {
|
||||
admission,
|
||||
deadline,
|
||||
dispatch_state: RenameAdmissionDispatchState::NotDispatched,
|
||||
};
|
||||
Ok((client, guard))
|
||||
})
|
||||
.await
|
||||
.ok_or(RenameBatchStartError::NotDispatched(DiskError::DiskNotFound))?;
|
||||
let (mut client, mut guard) = prepared?;
|
||||
let routing = super::client::node_service_rename_batch_client(
|
||||
&self.addr,
|
||||
TonicInterceptor::Signature(gen_tonic_signature_interceptor()),
|
||||
);
|
||||
let mut client = match tokio::time::timeout_at(deadline, routing).await {
|
||||
Ok(Ok(Some(client))) => client,
|
||||
Ok(Ok(None)) => return Err(RenameBatchStartError::UnsupportedBeforeStream),
|
||||
Ok(Err(error)) => {
|
||||
return Err(RenameBatchStartError::NotDispatched(DiskError::RemoteClientUnavailable(
|
||||
error.to_string(),
|
||||
)));
|
||||
}
|
||||
Err(_) => return Err(RenameBatchStartError::NotDispatched(DiskError::Timeout)),
|
||||
};
|
||||
let mut request_items = Vec::with_capacity(items.len());
|
||||
for item in items {
|
||||
let item_index = u32::try_from(item.slot)
|
||||
@@ -3428,11 +3393,21 @@ impl RemoteDisk {
|
||||
crate::cluster::rpc::set_tonic_canonical_body_digest(&mut request, &canonical_body)
|
||||
.map_err(Error::other)
|
||||
.map_err(RenameBatchStartError::NotDispatched)?;
|
||||
let admission = self
|
||||
.acquire_rename_admission_until(request.get_ref().items.len(), deadline)
|
||||
.await
|
||||
.map_err(RenameBatchStartError::NotDispatched)?;
|
||||
let guard = RenameBatchCallGuard {
|
||||
admission,
|
||||
deadline,
|
||||
dispatch_state: RenameAdmissionDispatchState::NotDispatched,
|
||||
};
|
||||
let call_timeout = deadline.saturating_duration_since(tokio::time::Instant::now());
|
||||
if call_timeout == Duration::ZERO {
|
||||
guard.release_without_quarantine();
|
||||
return Err(RenameBatchStartError::NotDispatched(DiskError::Timeout));
|
||||
}
|
||||
let mut guard = guard;
|
||||
guard.mark_dispatched();
|
||||
let response = match self
|
||||
.execute_peer_batch_with_timeout(
|
||||
@@ -3458,6 +3433,7 @@ impl RemoteDisk {
|
||||
Ok(guard.into_stream(response.into_inner(), expected_mask))
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn rename_data_borrowed_with_fence(
|
||||
&self,
|
||||
src_volume: &str,
|
||||
@@ -3467,36 +3443,6 @@ impl RemoteDisk {
|
||||
dst_path: &str,
|
||||
scanner_publication_lease_token: Option<Uuid>,
|
||||
) -> Result<RenameDataResp> {
|
||||
self.rename_data_observed(
|
||||
src_volume,
|
||||
src_path,
|
||||
fi,
|
||||
dst_volume,
|
||||
dst_path,
|
||||
RenameDataGuards {
|
||||
scanner_publication_lease_token,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.result
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn rename_data_observed(
|
||||
&self,
|
||||
src_volume: &str,
|
||||
src_path: &str,
|
||||
fi: &FileInfo,
|
||||
dst_volume: &str,
|
||||
dst_path: &str,
|
||||
guards: RenameDataGuards,
|
||||
) -> RenameDataObservation {
|
||||
let RenameDataGuards {
|
||||
scanner_publication_lease_token,
|
||||
dispatch_deadline,
|
||||
..
|
||||
} = guards;
|
||||
let multipart_rename = src_volume == crate::disk::RUSTFS_META_MULTIPART_BUCKET;
|
||||
let pool_meta_cas = rustfs_utils::http::metadata_compat::contains_key_str(
|
||||
&fi.metadata,
|
||||
@@ -3507,7 +3453,7 @@ impl RemoteDisk {
|
||||
|| dst_path != "pool.bin"
|
||||
|| scanner_publication_lease_token.is_some())
|
||||
{
|
||||
return RenameDataObservation::unknown(Err(DiskError::UnsupportedDisk));
|
||||
return Err(DiskError::UnsupportedDisk);
|
||||
}
|
||||
trace!(
|
||||
event = EVENT_REMOTE_DISK_RPC,
|
||||
@@ -3523,36 +3469,11 @@ impl RemoteDisk {
|
||||
"Remote disk RPC started"
|
||||
);
|
||||
|
||||
let mut dispatch_expired = false;
|
||||
let result = Self::execute_with_timeout_for_op(
|
||||
self,
|
||||
self.execute_with_timeout_for_op(
|
||||
"rename_data",
|
||||
|| async {
|
||||
let prepare_started = rustfs_io_metrics::put_stage_timer();
|
||||
let collect_prepare_timing = prepare_started.is_some();
|
||||
let prepared = before_rename_dispatch(dispatch_deadline, async {
|
||||
let get_client_started = collect_prepare_timing.then(Instant::now);
|
||||
let client = self.get_client_with_msgpack_policy().await;
|
||||
rustfs_io_metrics::record_put_object_stage_duration_from(
|
||||
rustfs_io_metrics::PUT_STAGE_SET_DISK_RENAME_REMOTE_CLIENT_GET_CLIENT,
|
||||
get_client_started,
|
||||
);
|
||||
let (client, policy) = client?;
|
||||
let rename_deadline = tokio::time::Instant::now() + get_max_timeout_duration();
|
||||
let rename_admission = self.acquire_rename_admission_until(1, rename_deadline).await?;
|
||||
let rename_admission_guard = RenameBatchCallGuard {
|
||||
admission: rename_admission,
|
||||
deadline: rename_deadline,
|
||||
dispatch_state: RenameAdmissionDispatchState::NotDispatched,
|
||||
};
|
||||
Ok::<_, DiskError>((client, policy, rename_admission_guard))
|
||||
})
|
||||
.await;
|
||||
let Some(prepared) = prepared else {
|
||||
dispatch_expired = true;
|
||||
return Err(DiskError::DiskNotFound);
|
||||
};
|
||||
let (mut client, mut policy, mut rename_admission_guard) = prepared?;
|
||||
let msgpack_encode_started = collect_prepare_timing.then(Instant::now);
|
||||
let file_info_bin = Bytes::from(encode_file_info_msgpack(fi)?);
|
||||
rustfs_io_metrics::record_put_object_stage_duration_from(
|
||||
@@ -3565,6 +3486,13 @@ impl RemoteDisk {
|
||||
file_info_bin.len(),
|
||||
);
|
||||
}
|
||||
let get_client_started = collect_prepare_timing.then(Instant::now);
|
||||
let client = self.get_client_with_msgpack_policy().await;
|
||||
rustfs_io_metrics::record_put_object_stage_duration_from(
|
||||
rustfs_io_metrics::PUT_STAGE_SET_DISK_RENAME_REMOTE_CLIENT_GET_CLIENT,
|
||||
get_client_started,
|
||||
);
|
||||
let (mut client, mut policy) = client?;
|
||||
let bucket_incarnation_id = crate::store::bucket_heal_scope_for_object(dst_volume, dst_path)
|
||||
.map(|scope| Bytes::copy_from_slice(scope.incarnation.as_bytes()))
|
||||
.unwrap_or_default();
|
||||
@@ -3576,6 +3504,13 @@ impl RemoteDisk {
|
||||
let scanner_publication_lease = scanner_publication_lease_token
|
||||
.map(|token| Bytes::copy_from_slice(token.as_bytes()))
|
||||
.unwrap_or_default();
|
||||
let rename_deadline = tokio::time::Instant::now() + get_max_timeout_duration();
|
||||
let rename_admission = self.acquire_rename_admission_until(1, rename_deadline).await?;
|
||||
let mut rename_admission_guard = RenameBatchCallGuard {
|
||||
admission: rename_admission,
|
||||
deadline: rename_deadline,
|
||||
dispatch_state: RenameAdmissionDispatchState::NotDispatched,
|
||||
};
|
||||
let rpc_kind = if multipart_rename {
|
||||
rustfs_io_metrics::ECSTORE_RENAME_RPC_KIND_MULTIPART
|
||||
} else if pool_meta_cas {
|
||||
@@ -3738,11 +3673,7 @@ impl RemoteDisk {
|
||||
},
|
||||
get_max_timeout_duration(),
|
||||
)
|
||||
.await;
|
||||
RenameDataObservation {
|
||||
result,
|
||||
rejected_before_publication: dispatch_expired,
|
||||
}
|
||||
.await
|
||||
}
|
||||
|
||||
/// Delete a path while binding the target-side operation to a scanner
|
||||
@@ -6553,66 +6484,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn rename_dispatch_budget_only_starts_after_the_quorum_signal() {
|
||||
use futures::FutureExt as _;
|
||||
|
||||
let (tx, rx) = tokio::sync::watch::channel(None);
|
||||
let mut dial = std::pin::pin!(before_rename_dispatch(Some(rx), std::future::pending::<()>()));
|
||||
assert!(dial.as_mut().now_or_never().is_none());
|
||||
time::advance(Duration::from_secs(2)).await;
|
||||
assert!(dial.as_mut().now_or_never().is_none(), "quorum has not been reached");
|
||||
|
||||
tx.send_replace(Some(time::Instant::now() + Duration::from_secs(1)));
|
||||
assert!(dial.as_mut().now_or_never().is_none(), "quorum grants a connection grace period");
|
||||
time::advance(Duration::from_secs(1)).await;
|
||||
assert_eq!(dial.await, None, "only the unresolved connection expires");
|
||||
assert_eq!(before_rename_dispatch(Some(tx.subscribe()), std::future::ready(8)).await, Some(8));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rename_dispatch_budget_does_not_cancel_a_dispatched_rpc() {
|
||||
use futures::FutureExt as _;
|
||||
|
||||
runtime_sources::ensure_test_rpc_secret();
|
||||
let peer = TestGrpcPeer::spawn(Bytes::new(), Bytes::new())
|
||||
.await
|
||||
.expect("bind rename peer");
|
||||
peer.peer.serve_rename_data();
|
||||
let gate = Arc::new(TestFormatReadGate::default());
|
||||
*peer.peer.rename_data_reply_gate.lock().expect("rename reply gate") = Some(gate.clone());
|
||||
let disk = remote_disk_for_addr(&peer.addr).await;
|
||||
let (tx, rx) = tokio::sync::watch::channel(None);
|
||||
let file_info = sample_rename_data_file_info();
|
||||
let mut rename = std::pin::pin!(disk.rename_data_observed(
|
||||
"tmp",
|
||||
"source",
|
||||
&file_info,
|
||||
"bucket",
|
||||
"object",
|
||||
RenameDataGuards {
|
||||
dispatch_deadline: Some(rx),
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
time::timeout(Duration::from_secs(5), async {
|
||||
tokio::select! {
|
||||
() = gate.entered.notified() => {},
|
||||
_ = rename.as_mut() => panic!("rename completed before the peer received it"),
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("peer should receive the authenticated mutation");
|
||||
|
||||
tx.send_replace(Some(time::Instant::now()));
|
||||
assert!(rename.as_mut().now_or_never().is_none(), "the dispatched mutation must continue to drain");
|
||||
gate.release.cancel();
|
||||
let observed = rename.await;
|
||||
assert!(!observed.rejected_before_publication());
|
||||
observed.result.expect("remote rename should return success");
|
||||
peer.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn multipart_rename_old_peer_rejects_without_legacy_fallback() {
|
||||
runtime_sources::ensure_test_rpc_secret();
|
||||
@@ -6669,7 +6540,7 @@ mod tests {
|
||||
|
||||
for (object, calls) in [("object", 1), ("other-object", 2)] {
|
||||
let result = remote
|
||||
.start_rename_data_batch("tmp", "source", "bucket", object, rename_batch_client_items(&file_infos), None)
|
||||
.start_rename_data_batch("tmp", "source", "bucket", object, rename_batch_client_items(&file_infos))
|
||||
.await;
|
||||
assert!(matches!(result, Err(RenameBatchStartError::UnsupportedBeforeStream)));
|
||||
assert_eq!(
|
||||
@@ -6706,7 +6577,7 @@ mod tests {
|
||||
for width in [2_usize, 4] {
|
||||
let file_infos = (0..width).map(|_| sample_rename_data_file_info()).collect::<Vec<_>>();
|
||||
let mut stream = remote
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos), None)
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos))
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!("{width}-item real batch must start"));
|
||||
assert_eq!(
|
||||
@@ -6744,62 +6615,6 @@ mod tests {
|
||||
peer.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn rename_dispatch_budget_releases_waiting_batch_admission_without_dispatch() {
|
||||
use std::task::Poll;
|
||||
|
||||
runtime_sources::ensure_test_rpc_secret();
|
||||
let peer = TestGrpcPeer::spawn(Bytes::new(), Bytes::new())
|
||||
.await
|
||||
.expect("bind rename batch peer");
|
||||
peer.peer.serve_rename_batch_results(usize::MAX);
|
||||
temp_env::async_with_vars([(ENV_RUSTFS_EXPERIMENTAL_RENAME_STREAM_BATCH, Some("true"))], async {
|
||||
let remote = remote_disk_for_addr(&peer.addr).await;
|
||||
let gate = Arc::clone(remote.rename_admission.as_ref().expect("rename admission enabled"));
|
||||
let capacity = rustfs_protos::INTERNODE_CONTROL_RPC_CONCURRENCY_LIMIT;
|
||||
let held = Arc::clone(&gate)
|
||||
.acquire_many_owned(u32::try_from(capacity - 1).expect("valid permit count"))
|
||||
.await
|
||||
.expect("reserve all but one permit");
|
||||
let file_infos = [sample_rename_data_file_info(), sample_rename_data_file_info()];
|
||||
let (tx, rx) = tokio::sync::watch::channel(None);
|
||||
let mut rename = std::pin::pin!(remote.start_rename_data_batch(
|
||||
"tmp",
|
||||
"source",
|
||||
"bucket",
|
||||
"object",
|
||||
rename_batch_client_items(&file_infos),
|
||||
Some(rx),
|
||||
));
|
||||
time::timeout(
|
||||
Duration::from_secs(5),
|
||||
std::future::poll_fn(|cx| {
|
||||
assert!(rename.as_mut().poll(cx).is_pending(), "batch must wait for two permits");
|
||||
if gate.available_permits() == 0 {
|
||||
Poll::Ready(())
|
||||
} else {
|
||||
Poll::Pending
|
||||
}
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.expect("the queued batch must reserve the spare permit");
|
||||
|
||||
tx.send_replace(Some(time::Instant::now()));
|
||||
let result = time::timeout(Duration::from_secs(5), rename)
|
||||
.await
|
||||
.expect("elapsed dispatch budget must release the batch waiter");
|
||||
assert!(matches!(result, Err(RenameBatchStartError::NotDispatched(DiskError::DiskNotFound))));
|
||||
assert_eq!(peer.peer.rename_batch_calls(), 0, "expiry must not send a mutation to the peer");
|
||||
assert_eq!(gate.available_permits(), 1, "the cancelled acquire must release its reservation");
|
||||
drop(held);
|
||||
assert_eq!(gate.available_permits(), capacity);
|
||||
})
|
||||
.await;
|
||||
peer.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn rename_batch_real_partial_eof_quarantines_only_missing_items() {
|
||||
@@ -6818,7 +6633,7 @@ mod tests {
|
||||
let gate = Arc::clone(remote.rename_admission.as_ref().expect("rename admission enabled"));
|
||||
let file_infos = (0..4).map(|_| sample_rename_data_file_info()).collect::<Vec<_>>();
|
||||
let mut stream = remote
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos), None)
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos))
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!("real partial batch must start"));
|
||||
|
||||
@@ -7385,7 +7200,7 @@ mod tests {
|
||||
fn msgpack_eligible_requests_bind_one_policy_and_bounded_local_retry() {
|
||||
let source = rustfs_protos::compat_manifest::production_source(include_str!("remote_disk.rs"), "remote_disk.rs");
|
||||
for function in [
|
||||
"rename_data_observed",
|
||||
"rename_data_borrowed_with_fence",
|
||||
"write_metadata",
|
||||
"update_metadata",
|
||||
"read_version",
|
||||
@@ -7735,7 +7550,6 @@ mod tests {
|
||||
rename_batch_result_limit: Arc<StdMutex<Option<usize>>>,
|
||||
serve_rename_data: Arc<AtomicBool>,
|
||||
rename_data_disks: Arc<StdMutex<Vec<String>>>,
|
||||
rename_data_reply_gate: Arc<StdMutex<Option<Arc<TestFormatReadGate>>>>,
|
||||
object_read_all_disks: Arc<StdMutex<Vec<String>>>,
|
||||
format_data: Bytes,
|
||||
read_all_data: Bytes,
|
||||
@@ -7770,7 +7584,6 @@ mod tests {
|
||||
rename_batch_result_limit: Arc::default(),
|
||||
serve_rename_data: Arc::default(),
|
||||
rename_data_disks: Arc::default(),
|
||||
rename_data_reply_gate: Arc::default(),
|
||||
object_read_all_disks: Arc::default(),
|
||||
format_data,
|
||||
read_all_data,
|
||||
@@ -7898,11 +7711,6 @@ mod tests {
|
||||
.lock()
|
||||
.expect("rename data disks lock poisoned")
|
||||
.push(request.disk);
|
||||
let gate = peer.rename_data_reply_gate.lock().expect("rename reply gate lock").take();
|
||||
if let Some(gate) = gate {
|
||||
gate.entered.notify_one();
|
||||
gate.release.cancelled().await;
|
||||
}
|
||||
let payload = serde_json::to_string(&RenameDataResp {
|
||||
sign: Some(vec![1]),
|
||||
..Default::default()
|
||||
|
||||
@@ -645,7 +645,7 @@ impl LocalDiskWrapper {
|
||||
get_max_timeout_duration()
|
||||
};
|
||||
let observed = run_owned_mutation(external_guard, move || async move {
|
||||
let mut rejected_before_publication = false;
|
||||
let mut preflight_rejection = None;
|
||||
let result = operation
|
||||
.track_disk_health_mutation(
|
||||
"rename_data",
|
||||
@@ -661,7 +661,7 @@ impl LocalDiskWrapper {
|
||||
namespace_owner,
|
||||
))
|
||||
.await;
|
||||
rejected_before_publication = observed.rejected_before_publication();
|
||||
preflight_rejection = observed.preflight_rejection;
|
||||
observed.result
|
||||
},
|
||||
timeout_duration,
|
||||
@@ -670,7 +670,7 @@ impl LocalDiskWrapper {
|
||||
// Health tracking must observe the real disk error, not an Ok tuple.
|
||||
Ok(super::RenameDataObservation {
|
||||
result,
|
||||
rejected_before_publication,
|
||||
preflight_rejection,
|
||||
})
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(in crate::disk) use self::commit::LocalRenamePreflightRejection;
|
||||
#[cfg(test)]
|
||||
#[path = "local/read_path_tests.rs"]
|
||||
mod read_path_tests;
|
||||
@@ -977,7 +978,7 @@ fn restore_part_transaction_file(current: &Path, backup: &Path, absent: &Path, r
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, not(windows)))]
|
||||
#[cfg(test)]
|
||||
async fn write_metadata_rollback_backup(object_dir: &Path, rollback_dir: Uuid, data: &[u8]) -> Result<()> {
|
||||
write_delete_rollback_file(
|
||||
object_dir.parent().unwrap_or(object_dir),
|
||||
@@ -9323,29 +9324,10 @@ impl LocalDisk {
|
||||
}
|
||||
let path = trash.join(name);
|
||||
let result = async {
|
||||
let is_dir = entry.file_type().await?.is_dir();
|
||||
#[cfg(windows)]
|
||||
{
|
||||
// Competing recursive deletions can deny each other's directory
|
||||
// handles. Keep ownership until the blocking operation returns.
|
||||
let lease = os::acquire_namespace_mutation_lease_with_owner(&path, None).await;
|
||||
let path = path.clone();
|
||||
os::run_blocking_namespace_operation(lease, move || {
|
||||
if is_dir {
|
||||
std::fs::remove_dir_all(path)
|
||||
} else {
|
||||
std::fs::remove_file(path)
|
||||
}
|
||||
})
|
||||
.await
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
if is_dir {
|
||||
fs::remove_dir_all(&path).await
|
||||
} else {
|
||||
fs::remove_file(&path).await
|
||||
}
|
||||
if entry.file_type().await?.is_dir() {
|
||||
fs::remove_dir_all(&path).await
|
||||
} else {
|
||||
fs::remove_file(&path).await
|
||||
}
|
||||
}
|
||||
.await;
|
||||
|
||||
@@ -540,7 +540,7 @@ async fn prepare_rename_commit_and_destination_metadata(
|
||||
/// Proof produced only when the local rename returns at an existing access
|
||||
/// preflight, before metadata, backups, or object data can be published.
|
||||
#[derive(Debug)]
|
||||
struct LocalRenamePreflightRejection(());
|
||||
pub(in crate::disk) struct LocalRenamePreflightRejection(());
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct RenameDataState {
|
||||
@@ -2947,7 +2947,7 @@ impl LocalDisk {
|
||||
.await;
|
||||
super::super::RenameDataObservation {
|
||||
result,
|
||||
rejected_before_publication: state.preflight_rejection.is_some(),
|
||||
preflight_rejection: state.preflight_rejection,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2599,7 +2599,6 @@ mod tests {
|
||||
assert!(!disk.root.join(RUSTFS_META_TMP_BUCKET).join(raw_path).exists());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
async fn assert_cold_recovery_after_present_head_failure(
|
||||
fixture: &mut Fixture,
|
||||
publication: &PublicationIdentity,
|
||||
|
||||
@@ -755,7 +755,7 @@ impl SourceStore {
|
||||
.await?;
|
||||
Ok(state)
|
||||
}
|
||||
#[cfg(all(test, unix))]
|
||||
#[cfg(test)]
|
||||
pub async fn write_owned_backup(&self, owner: Uuid, target: bool, bytes: &[u8]) -> Result<()> {
|
||||
if owner.is_nil() {
|
||||
return Err(DiskError::FileCorrupt);
|
||||
|
||||
@@ -130,28 +130,24 @@ pub(crate) struct RenameDataGuards {
|
||||
pub(crate) scanner_publication_lease_token: Option<Uuid>,
|
||||
pub(crate) external_guard: Option<Arc<dyn Send + Sync>>,
|
||||
pub(crate) namespace_owner: Option<Arc<dyn Send + Sync>>,
|
||||
pub(crate) dispatch_deadline: Option<RenameDispatchDeadline>,
|
||||
}
|
||||
|
||||
/// The fanout publishes this deadline once enough disks have committed.
|
||||
pub(crate) type RenameDispatchDeadline = tokio::sync::watch::Receiver<Option<tokio::time::Instant>>;
|
||||
|
||||
/// Pre-dispatch evidence stays outside DiskAPI and the RPC response format.
|
||||
/// Local preflight evidence stays outside DiskAPI and the RPC response format.
|
||||
pub(crate) struct RenameDataObservation {
|
||||
pub(crate) result: Result<RenameDataResp>,
|
||||
pub(crate) rejected_before_publication: bool,
|
||||
preflight_rejection: Option<local::LocalRenamePreflightRejection>,
|
||||
}
|
||||
|
||||
impl RenameDataObservation {
|
||||
pub(crate) fn unknown(result: Result<RenameDataResp>) -> Self {
|
||||
fn unknown(result: Result<RenameDataResp>) -> Self {
|
||||
Self {
|
||||
result,
|
||||
rejected_before_publication: false,
|
||||
preflight_rejection: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn rejected_before_publication(&self) -> bool {
|
||||
self.result.is_err() && self.rejected_before_publication
|
||||
self.result.is_err() && self.preflight_rejection.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1392,11 +1388,18 @@ impl Disk {
|
||||
.rename_data_observed_with_guards(src_volume, src_path, fi, dst_volume, dst_path, guards)
|
||||
.await
|
||||
}
|
||||
Disk::Remote(remote_disk) => {
|
||||
Disk::Remote(remote_disk) => RenameDataObservation::unknown(
|
||||
remote_disk
|
||||
.rename_data_observed(src_volume, src_path, fi, dst_volume, dst_path, guards)
|
||||
.await
|
||||
}
|
||||
.rename_data_borrowed_with_fence(
|
||||
src_volume,
|
||||
src_path,
|
||||
fi,
|
||||
dst_volume,
|
||||
dst_path,
|
||||
guards.scanner_publication_lease_token,
|
||||
)
|
||||
.await,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2751,7 +2751,7 @@ impl DiskBlockingLane {
|
||||
#[derive(Default)]
|
||||
struct DiskBlockingQueueState {
|
||||
jobs: VecDeque<Box<dyn FnOnce() + Send>>,
|
||||
#[cfg(all(test, unix))]
|
||||
#[cfg(test)]
|
||||
submitted_jobs: usize,
|
||||
active_workers: usize,
|
||||
idle_workers: usize,
|
||||
@@ -2879,7 +2879,7 @@ impl DiskBlockingQueue {
|
||||
let should_spawn = {
|
||||
let mut state = self.lane(lane).state.lock();
|
||||
state.jobs.push_back(job);
|
||||
#[cfg(all(test, unix))]
|
||||
#[cfg(test)]
|
||||
{
|
||||
state.submitted_jobs += 1;
|
||||
}
|
||||
@@ -2897,7 +2897,7 @@ impl DiskBlockingQueue {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, unix))]
|
||||
#[cfg(test)]
|
||||
pub(crate) fn submitted_jobs_for_test(&self) -> usize {
|
||||
self.lanes.iter().map(|lane| lane.state.lock().submitted_jobs).sum()
|
||||
}
|
||||
@@ -3326,8 +3326,8 @@ static DISK_METADATA_MUTATION_LOCKS: LazyLock<ShardedPathLockRegistry<NamespaceM
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct MetadataMutationLockHandle(Arc<NamespaceMutationLock>);
|
||||
|
||||
#[cfg(all(test, unix))]
|
||||
impl MetadataMutationLockHandle {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn ptr_eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
@@ -3337,8 +3337,8 @@ impl MetadataMutationLockHandle {
|
||||
#[derive(Clone)]
|
||||
pub(in crate::disk) struct NamespaceMutationLockHandle(Arc<NamespaceMutationLock>);
|
||||
|
||||
#[cfg(all(test, unix))]
|
||||
impl NamespaceMutationLockHandle {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn ptr_eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.0, &other.0)
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ impl TryFrom<&str> for Endpoint {
|
||||
|
||||
/// Performs the conversion.
|
||||
fn try_from(value: &str) -> std::result::Result<Self, Self::Error> {
|
||||
const INVALID_URL_PORT: &str = "invalid URL endpoint format: port number must be between 1 to 65535";
|
||||
|
||||
// check whether given path is not empty.
|
||||
if ["", "/", "\\"].iter().any(|&v| v.eq(value)) {
|
||||
return Err(Error::other("empty or root endpoint is not supported"));
|
||||
@@ -80,6 +82,7 @@ impl TryFrom<&str> for Endpoint {
|
||||
|
||||
let mut is_local = false;
|
||||
let url = match Url::parse(value) {
|
||||
Ok(url) if url.port() == Some(0) => return Err(Error::other(INVALID_URL_PORT)),
|
||||
#[allow(unused_mut)]
|
||||
Ok(mut url) if url.has_host() => {
|
||||
// URL style of endpoint.
|
||||
@@ -139,9 +142,7 @@ impl TryFrom<&str> for Endpoint {
|
||||
url_parse_from_file_path(value)?
|
||||
}
|
||||
Err(e) => match e {
|
||||
ParseError::InvalidPort => {
|
||||
return Err(Error::other("invalid URL endpoint format: port number must be between 1 to 65535"));
|
||||
}
|
||||
ParseError::InvalidPort => return Err(Error::other(INVALID_URL_PORT)),
|
||||
ParseError::EmptyHost => return Err(Error::other("invalid URL endpoint format: empty host name")),
|
||||
ParseError::RelativeUrlWithoutBase => {
|
||||
// like /foo
|
||||
@@ -450,6 +451,12 @@ mod test {
|
||||
expected_type: Some(EndpointType::Url),
|
||||
expected_err: None,
|
||||
},
|
||||
TestCase {
|
||||
arg: "http://127.0.0.1:0/path",
|
||||
expected_endpoint: None,
|
||||
expected_type: None,
|
||||
expected_err: Some(Error::other("invalid URL endpoint format: port number must be between 1 to 65535")),
|
||||
},
|
||||
TestCase {
|
||||
arg: "https://93.184.216.34:808080/path",
|
||||
expected_endpoint: None,
|
||||
|
||||
@@ -21,20 +21,25 @@ use rustfs_config::{
|
||||
ENV_KUBERNETES_SERVICE_HOST, ENV_LOCAL_ENDPOINT_HOST, ENV_MINIO_CI, ENV_STARTUP_TOPOLOGY_RETRY_MAX_DELAY,
|
||||
ENV_STARTUP_TOPOLOGY_WAIT_MODE, ENV_STARTUP_TOPOLOGY_WAIT_TIMEOUT, ENV_UNSAFE_BYPASS_DISK_CHECK,
|
||||
};
|
||||
use rustfs_utils::{XHost, check_local_server_addr, get_env_opt_str, get_host_ip, is_local_host};
|
||||
use rustfs_utils::{XHost, check_local_server_addr, get_env_opt_str, is_local_ip};
|
||||
#[cfg(test)]
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{BTreeMap, BTreeSet, HashMap, HashSet, hash_map::Entry},
|
||||
future::Future,
|
||||
io::{Error, ErrorKind, Result},
|
||||
net::IpAddr,
|
||||
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
use tokio::time::sleep as async_sleep;
|
||||
use tokio::time::{Instant as TokioInstant, sleep as async_sleep, sleep_until};
|
||||
use tracing::{error, info, instrument, warn};
|
||||
use url::Host;
|
||||
|
||||
const LOG_COMPONENT_ECSTORE: &str = "ecstore";
|
||||
const LOG_SUBSYSTEM_ENDPOINT_TOPOLOGY: &str = "endpoint_topology";
|
||||
const EVENT_STARTUP_ENDPOINT_DNS_FAILED: &str = "startup_endpoint_dns_failed";
|
||||
|
||||
/// enum for setup type.
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub enum SetupType {
|
||||
@@ -196,18 +201,17 @@ struct PoolEndpointList {
|
||||
setup_type: SetupType,
|
||||
}
|
||||
|
||||
struct ResolvedStartupHost {
|
||||
addresses: HashSet<IpAddr>,
|
||||
is_local: bool,
|
||||
}
|
||||
|
||||
impl AsRef<Vec<Endpoints>> for PoolEndpointList {
|
||||
fn as_ref(&self) -> &Vec<Endpoints> {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<Vec<Endpoints>> for PoolEndpointList {
|
||||
fn as_mut(&mut self) -> &mut Vec<Endpoints> {
|
||||
&mut self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl PoolEndpointList {
|
||||
/// Creates a list of endpoints per pool, resolves their relevant hostnames
|
||||
/// and discovers whether those are local or remote.
|
||||
@@ -322,76 +326,41 @@ impl PoolEndpointList {
|
||||
|
||||
let convergence_started = Instant::now();
|
||||
let dns_retry_deadline = DnsRetryDeadline::new(policy.wait_timeout, policy.retry_max_delay);
|
||||
if let Some(local_endpoint_host) = local_endpoint_host {
|
||||
let resolved_hosts = if let Some(local_endpoint_host) = local_endpoint_host {
|
||||
pool_endpoint_list.update_is_local_from_explicit_host(disks_layout, server_addr.port(), local_endpoint_host)?;
|
||||
HashMap::new()
|
||||
} else {
|
||||
pool_endpoint_list
|
||||
.update_is_local(server_addr.port(), &dns_retry_deadline)
|
||||
.await?;
|
||||
|
||||
// Collapse divergent local/remote verdicts for the same host:port that
|
||||
// orchestrated DNS churn can produce during startup, before any check
|
||||
// relies on the local flag.
|
||||
normalize_same_host_local_state(pool_endpoint_list.as_mut());
|
||||
}
|
||||
.resolve_startup_hosts(server_addr.port(), &dns_retry_deadline, lookup_startup_host_ips)
|
||||
.await?
|
||||
};
|
||||
|
||||
let mut total_endpoints = 0;
|
||||
let mut local_endpoints = 0;
|
||||
for endpoints in pool_endpoint_list.inner.iter_mut() {
|
||||
// Check whether same path is not used in endpoints of a host on different port.
|
||||
// This relies on resolving every host to its IP set, which can flap while a
|
||||
// Kubernetes headless service is still publishing records; defer it in
|
||||
// orchestrated mode and re-run the DNS-independent checks below.
|
||||
if !policy.is_orchestrated() {
|
||||
let mut path_ip_map: HashMap<String, HashSet<IpAddr>> = HashMap::new();
|
||||
let mut host_ip_cache: HashMap<Host<&str>, HashSet<IpAddr>> = HashMap::new();
|
||||
let mut path_ip_map: HashMap<String, Cow<'_, HashSet<IpAddr>>> = HashMap::new();
|
||||
for ep in endpoints.as_ref() {
|
||||
let Some(host) = ep.url.host() else {
|
||||
let Some(host) = ep.url.host_str().and_then(|host| resolved_hosts.get(host)) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let host_ip_set = if let Some(set) = host_ip_cache.get(&host) {
|
||||
info!(
|
||||
target: "rustfs::ecstore::endpoints",
|
||||
host = %host,
|
||||
endpoint = %ep.to_string(),
|
||||
from = "cache",
|
||||
"Create pool endpoints host '{}' found in cache for endpoint '{}'", host, ep.to_string()
|
||||
);
|
||||
set.clone()
|
||||
} else {
|
||||
let ips = match resolve_host_ips_with_retry(host.clone(), &ep.to_string(), &dns_retry_deadline).await {
|
||||
Ok(ips) => ips,
|
||||
Err(e) => {
|
||||
error!("Create pool endpoints host {} not found, error:{}", host, e);
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
info!(
|
||||
target: "rustfs::ecstore::endpoints",
|
||||
host = %host,
|
||||
endpoint = %ep.to_string(),
|
||||
from = "get_host_ip",
|
||||
"Create pool endpoints host '{}' resolved to ips {:?} for endpoint '{}'",
|
||||
host,
|
||||
ips,
|
||||
ep.to_string()
|
||||
);
|
||||
host_ip_cache.insert(host.clone(), ips.clone());
|
||||
ips
|
||||
};
|
||||
|
||||
let path = ep.get_file_path();
|
||||
match path_ip_map.entry(path) {
|
||||
Entry::Occupied(mut e) => {
|
||||
if e.get().intersection(&host_ip_set).count() > 0 {
|
||||
let path_key = e.key().clone();
|
||||
if !e.get().is_disjoint(&host.addresses) {
|
||||
return Err(Error::other(format!(
|
||||
"same path '{path_key}' can not be served by different port on same address"
|
||||
"same path '{}' can not be served by different port on same address",
|
||||
e.key()
|
||||
)));
|
||||
}
|
||||
e.get_mut().extend(host_ip_set.iter());
|
||||
e.get_mut().to_mut().extend(&host.addresses);
|
||||
}
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(host_ip_set);
|
||||
e.insert(Cow::Borrowed(&host.addresses));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,13 +383,11 @@ impl PoolEndpointList {
|
||||
}
|
||||
|
||||
// Here all endpoints are URL style.
|
||||
let mut ep_path_set = HashSet::new();
|
||||
let mut local_server_host_set = HashSet::new();
|
||||
let mut local_port_set = HashSet::new();
|
||||
let mut local_endpoint_count = 0;
|
||||
|
||||
for ep in endpoints.as_ref() {
|
||||
ep_path_set.insert(ep.get_file_path());
|
||||
if ep.is_local && ep.url.has_host() {
|
||||
local_server_host_set.insert(ep.url.host());
|
||||
local_port_set.insert(ep.url.port());
|
||||
@@ -438,30 +405,20 @@ impl PoolEndpointList {
|
||||
}
|
||||
|
||||
// Add missing port in all endpoints.
|
||||
total_endpoints += endpoints.as_ref().len();
|
||||
for ep in endpoints.as_mut() {
|
||||
local_endpoints += usize::from(ep.is_local);
|
||||
if !ep.url.has_host() {
|
||||
unique_args.insert(format!("localhost:{}", server_addr.port()));
|
||||
continue;
|
||||
}
|
||||
match ep.url.port() {
|
||||
None => {
|
||||
if local_endpoint_host.is_none() {
|
||||
let _ = ep.url.set_port(Some(server_addr.port()));
|
||||
}
|
||||
}
|
||||
Some(port) => {
|
||||
// If endpoint is local, but port is different than serverAddrPort, then make it as remote.
|
||||
if ep.is_local && server_addr.port() != port {
|
||||
ep.is_local = false;
|
||||
}
|
||||
}
|
||||
if ep.url.port().is_none() && local_endpoint_host.is_none() {
|
||||
let _ = ep.url.set_port(Some(server_addr.port()));
|
||||
}
|
||||
unique_args.insert(ep.host_port());
|
||||
}
|
||||
}
|
||||
|
||||
validate_local_physical_disk_independence(pool_endpoint_list.as_ref())?;
|
||||
|
||||
let setup_type = match pool_endpoint_list.as_ref()[0].as_ref()[0].get_type() {
|
||||
EndpointType::Path => SetupType::Erasure,
|
||||
EndpointType::Url => match unique_args.len() {
|
||||
@@ -470,15 +427,25 @@ impl PoolEndpointList {
|
||||
},
|
||||
};
|
||||
|
||||
pool_endpoint_list.setup_type = setup_type;
|
||||
// A storage member can belong to just one pool, but it must own a slot somewhere in the topology.
|
||||
if local_endpoints == 0 {
|
||||
let local_port = server_addr.port();
|
||||
if local_endpoint_host.is_some() {
|
||||
return Err(Error::other(format!(
|
||||
"{ENV_LOCAL_ENDPOINT_HOST} does not match any distributed endpoint on the local server port {local_port}"
|
||||
)));
|
||||
}
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidInput,
|
||||
format!(
|
||||
"no local storage endpoints on the local server port {local_port}; \
|
||||
check that a host in RUSTFS_VOLUMES resolves to a local interface and uses the RUSTFS_ADDRESS port"
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
let total_endpoints: usize = pool_endpoint_list.inner.iter().map(|eps| eps.as_ref().len()).sum();
|
||||
let local_endpoints = pool_endpoint_list
|
||||
.inner
|
||||
.iter()
|
||||
.flat_map(|eps| eps.as_ref())
|
||||
.filter(|ep| ep.is_local)
|
||||
.count();
|
||||
validate_local_physical_disk_independence(pool_endpoint_list.as_ref())?;
|
||||
pool_endpoint_list.setup_type = setup_type;
|
||||
info!(
|
||||
target: "rustfs::ecstore::endpoints",
|
||||
mode = ?policy.mode,
|
||||
@@ -492,34 +459,33 @@ impl PoolEndpointList {
|
||||
Ok(pool_endpoint_list)
|
||||
}
|
||||
|
||||
/// resolves all hosts and discovers which are local
|
||||
async fn update_is_local(&mut self, local_port: u16, dns_retry_deadline: &DnsRetryDeadline) -> Result<()> {
|
||||
self._update_is_local(local_port, dns_retry_deadline).await
|
||||
}
|
||||
|
||||
/// resolves all hosts and discovers which are local
|
||||
async fn _update_is_local(&mut self, local_port: u16, dns_retry_deadline: &DnsRetryDeadline) -> Result<()> {
|
||||
// Keep each successful answer for the whole startup so all drives and path checks agree.
|
||||
async fn resolve_startup_hosts(
|
||||
&mut self,
|
||||
local_port: u16,
|
||||
dns_retry_deadline: &DnsRetryDeadline,
|
||||
resolve: impl for<'a> AsyncFn(Host<&'a str>) -> Result<HashSet<IpAddr>>,
|
||||
) -> Result<HashMap<String, ResolvedStartupHost>> {
|
||||
let mut resolved_hosts: HashMap<String, ResolvedStartupHost> = HashMap::new();
|
||||
for endpoints in self.inner.iter_mut() {
|
||||
for ep in endpoints.as_mut() {
|
||||
match ep.url.host() {
|
||||
None => {
|
||||
ep.is_local = true;
|
||||
}
|
||||
Some(host) => {
|
||||
ep.is_local = resolve_local_host_with_retry(
|
||||
host,
|
||||
ep.url.port().unwrap_or_default(),
|
||||
local_port,
|
||||
&ep.to_string(),
|
||||
dns_retry_deadline,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
let (Some(host_name), Some(host)) = (ep.url.host_str(), ep.url.host()) else {
|
||||
ep.is_local = true;
|
||||
continue;
|
||||
};
|
||||
let is_local = if let Some(resolved) = resolved_hosts.get(host_name) {
|
||||
resolved.is_local
|
||||
} else {
|
||||
let addresses = resolve_startup_host_with_retry(host, &ep.to_string(), dns_retry_deadline, &resolve).await?;
|
||||
let is_local = addresses.iter().any(is_local_ip);
|
||||
resolved_hosts.insert(host_name.to_owned(), ResolvedStartupHost { addresses, is_local });
|
||||
is_local
|
||||
};
|
||||
ep.is_local = is_local && ep.url.port().is_none_or(|port| port == local_port);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(resolved_hosts)
|
||||
}
|
||||
|
||||
fn update_is_local_from_explicit_host(
|
||||
@@ -529,7 +495,6 @@ impl PoolEndpointList {
|
||||
raw_local_host: &str,
|
||||
) -> Result<()> {
|
||||
let local_host = parse_explicit_local_endpoint_host(raw_local_host)?;
|
||||
let mut local_endpoint_found = false;
|
||||
let mut host_path_ports = HashMap::new();
|
||||
debug_assert_eq!(self.inner.len(), disks_layout.pools.len());
|
||||
|
||||
@@ -575,17 +540,9 @@ impl PoolEndpointList {
|
||||
entry.insert(endpoint_port);
|
||||
}
|
||||
}
|
||||
|
||||
local_endpoint_found |= endpoint.is_local;
|
||||
}
|
||||
}
|
||||
|
||||
if !local_endpoint_found {
|
||||
return Err(Error::other(format!(
|
||||
"{ENV_LOCAL_ENDPOINT_HOST} does not match any distributed endpoint on the local server port {local_port}"
|
||||
)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -686,17 +643,21 @@ fn kernel_hostname_for_endpoint_identity() -> Result<String> {
|
||||
.map_err(|_| Error::new(ErrorKind::InvalidData, "kernel hostname is not valid UTF-8"))
|
||||
}
|
||||
|
||||
fn endpoint_is_local_host(host: Host<&str>, port: u16, local_port: u16) -> Result<bool> {
|
||||
async fn lookup_startup_host_ips(host: Host<&str>) -> Result<HashSet<IpAddr>> {
|
||||
#[cfg(test)]
|
||||
if local_host_resolution_timeout_forced(&host) {
|
||||
return Err(Error::new(ErrorKind::TimedOut, "resolver timeout"));
|
||||
}
|
||||
|
||||
is_local_host(host, port, local_port)
|
||||
match host {
|
||||
Host::Domain(domain) => Ok(tokio::net::lookup_host((domain, 0)).await?.map(|addr| addr.ip()).collect()),
|
||||
Host::Ipv4(ip) => Ok(HashSet::from([IpAddr::V4(ip)])),
|
||||
Host::Ipv6(ip) => Ok(HashSet::from([IpAddr::V6(ip)])),
|
||||
}
|
||||
}
|
||||
|
||||
struct DnsRetryDeadline {
|
||||
started: Instant,
|
||||
started: TokioInstant,
|
||||
timeout: Duration,
|
||||
max_delay: Duration,
|
||||
}
|
||||
@@ -704,7 +665,7 @@ struct DnsRetryDeadline {
|
||||
impl DnsRetryDeadline {
|
||||
fn new(timeout: Duration, max_delay: Duration) -> Self {
|
||||
Self {
|
||||
started: Instant::now(),
|
||||
started: TokioInstant::now(),
|
||||
timeout,
|
||||
max_delay,
|
||||
}
|
||||
@@ -718,6 +679,14 @@ impl DnsRetryDeadline {
|
||||
self.started.elapsed()
|
||||
}
|
||||
|
||||
fn expires_at(&self) -> Option<TokioInstant> {
|
||||
// Zero means one lookup with no retries. MAX is the unbounded orchestrated policy.
|
||||
if matches!(self.timeout, Duration::ZERO | Duration::MAX) {
|
||||
return None;
|
||||
}
|
||||
self.started.checked_add(self.timeout)
|
||||
}
|
||||
|
||||
fn bounded_delay(&self, delay: Duration) -> Option<Duration> {
|
||||
let remaining = self.timeout.saturating_sub(self.started.elapsed());
|
||||
if remaining.is_zero() {
|
||||
@@ -746,17 +715,16 @@ where
|
||||
RetryLog: FnMut(u32, Duration, Duration, &Error),
|
||||
{
|
||||
let mut attempts: u32 = 0;
|
||||
let mut last_warn: Option<Instant> = None;
|
||||
|
||||
loop {
|
||||
match resolve().await {
|
||||
Ok(value) => return Ok(value),
|
||||
Err(err) => {
|
||||
if !is_retryable_dns_error(&err) {
|
||||
return Err(permanent_error(err));
|
||||
}
|
||||
|
||||
let result = {
|
||||
let retry = async {
|
||||
let mut last_warn: Option<Instant> = None;
|
||||
loop {
|
||||
attempts += 1;
|
||||
let err = match resolve().await {
|
||||
Ok(value) => return Ok(value),
|
||||
Err(err) if is_retryable_dns_error(&err) => err,
|
||||
Err(err) => return Err(permanent_error(err)),
|
||||
};
|
||||
let Some(delay) = dns_retry_deadline.bounded_delay(dns_retry_delay(attempts, dns_retry_deadline.max_delay))
|
||||
else {
|
||||
return Err(timeout_error(attempts, dns_retry_deadline.timeout(), err));
|
||||
@@ -770,8 +738,25 @@ where
|
||||
}
|
||||
sleep(delay).await;
|
||||
}
|
||||
};
|
||||
|
||||
match dns_retry_deadline.expires_at() {
|
||||
Some(expires_at) if expires_at <= TokioInstant::now() => None,
|
||||
Some(expires_at) => tokio::select! {
|
||||
biased;
|
||||
() = sleep_until(expires_at) => None,
|
||||
result = retry => Some(result),
|
||||
},
|
||||
None => Some(retry.await),
|
||||
}
|
||||
}
|
||||
};
|
||||
result.unwrap_or_else(|| {
|
||||
Err(timeout_error(
|
||||
attempts,
|
||||
dns_retry_deadline.timeout(),
|
||||
Error::new(ErrorKind::TimedOut, "startup DNS deadline elapsed"),
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
/// Action-oriented tail shared by topology convergence timeout errors so a
|
||||
@@ -781,26 +766,30 @@ const TOPOLOGY_TIMEOUT_HINT: &str = "check DNS and /etc/hosts resolution, the ht
|
||||
and that all peer nodes have started; on Kubernetes/orchestrated deployments set \
|
||||
RUSTFS_STARTUP_TOPOLOGY_WAIT_MODE=orchestrated to keep waiting instead of exiting";
|
||||
|
||||
async fn resolve_local_host_with_retry(
|
||||
async fn resolve_startup_host_with_retry(
|
||||
host: Host<&str>,
|
||||
port: u16,
|
||||
local_port: u16,
|
||||
context: &str,
|
||||
dns_retry_deadline: &DnsRetryDeadline,
|
||||
) -> Result<bool> {
|
||||
resolve: &impl for<'a> AsyncFn(Host<&'a str>) -> Result<HashSet<IpAddr>>,
|
||||
) -> Result<HashSet<IpAddr>> {
|
||||
retry_dns_operation(
|
||||
|| {
|
||||
let host = host.clone();
|
||||
async move { endpoint_is_local_host(host, port, local_port) }
|
||||
},
|
||||
|| resolve(host.clone()),
|
||||
async_sleep,
|
||||
dns_retry_deadline,
|
||||
|err| Error::other(format!("endpoint '{context}' local-host detection failed for host '{host}': {err}")),
|
||||
|attempts, timeout, err| {
|
||||
Error::other(format!(
|
||||
"endpoint '{context}' local-host detection did not converge for host '{host}' after {attempts} attempts \
|
||||
let kind = if timeout.is_zero() {
|
||||
ErrorKind::Other
|
||||
} else {
|
||||
ErrorKind::TimedOut
|
||||
};
|
||||
Error::new(
|
||||
kind,
|
||||
format!(
|
||||
"endpoint '{context}' local-host detection did not converge for host '{host}' after {attempts} attempts \
|
||||
over {timeout:?} (stage=local_host_detection): {err}. {TOPOLOGY_TIMEOUT_HINT}"
|
||||
))
|
||||
),
|
||||
)
|
||||
},
|
||||
|attempts, delay, elapsed, err| {
|
||||
warn!(
|
||||
@@ -817,42 +806,18 @@ over {timeout:?} (stage=local_host_detection): {err}. {TOPOLOGY_TIMEOUT_HINT}"
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn resolve_host_ips_with_retry(
|
||||
host: Host<&str>,
|
||||
context: &str,
|
||||
dns_retry_deadline: &DnsRetryDeadline,
|
||||
) -> Result<HashSet<IpAddr>> {
|
||||
retry_dns_operation(
|
||||
|| {
|
||||
let host = host.clone();
|
||||
async move { get_host_ip(host).await }
|
||||
},
|
||||
async_sleep,
|
||||
dns_retry_deadline,
|
||||
|err| Error::other(format!("endpoint '{context}' host '{host}' cannot resolve: {err}")),
|
||||
|attempts, timeout, err| {
|
||||
Error::other(format!(
|
||||
"endpoint '{context}' host '{host}' DNS resolution did not converge after {attempts} attempts over \
|
||||
{timeout:?} (stage=host_ip_resolution): {err}. {TOPOLOGY_TIMEOUT_HINT}"
|
||||
))
|
||||
},
|
||||
|attempts, delay, elapsed, err| {
|
||||
warn!(
|
||||
target = "rustfs::ecstore::endpoints",
|
||||
stage = "host_ip_resolution",
|
||||
context = %context,
|
||||
host = %host,
|
||||
attempt = attempts,
|
||||
delay_ms = delay.as_millis(),
|
||||
elapsed_ms = elapsed.as_millis(),
|
||||
error = %err,
|
||||
"retrying endpoint DNS resolution after temporary error"
|
||||
);
|
||||
},
|
||||
)
|
||||
.await
|
||||
.inspect_err(|err| {
|
||||
error!(
|
||||
target: "rustfs::ecstore::endpoints",
|
||||
event = EVENT_STARTUP_ENDPOINT_DNS_FAILED,
|
||||
component = LOG_COMPONENT_ECSTORE,
|
||||
subsystem = LOG_SUBSYSTEM_ENDPOINT_TOPOLOGY,
|
||||
state = "failed",
|
||||
host = %host,
|
||||
error_kind = ?err.kind(),
|
||||
"Startup endpoint DNS resolution failed"
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
fn is_retryable_dns_error(err: &Error) -> bool {
|
||||
@@ -936,6 +901,26 @@ fn explicit_url_port(raw: &str) -> Result<Option<u16>> {
|
||||
port.parse().map(Some).map_err(|_| invalid())
|
||||
}
|
||||
|
||||
fn is_url_topology_with_non_literal_hosts(disks_layout: &DisksLayout) -> Result<bool> {
|
||||
let mut endpoints = disks_layout
|
||||
.pools
|
||||
.iter()
|
||||
.flat_map(|pool| pool.iter().flatten())
|
||||
.map(|endpoint| Endpoint::try_from(endpoint.as_str()));
|
||||
let Some(first) = endpoints.next().transpose()? else {
|
||||
return Ok(false);
|
||||
};
|
||||
if first.get_type() != EndpointType::Url {
|
||||
return Ok(false);
|
||||
}
|
||||
for endpoint in std::iter::once(Ok(first)).chain(endpoints) {
|
||||
if !matches!(endpoint?.url.host(), Some(Host::Ipv4(_) | Host::Ipv6(_))) {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn infer_kubernetes_local_endpoint_host(
|
||||
disks_layout: &DisksLayout,
|
||||
local_port: u16,
|
||||
@@ -1189,34 +1174,6 @@ fn parse_wait_duration(raw: &str) -> Option<Duration> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Collapses divergent local/remote verdicts for endpoints that share the same
|
||||
/// `host:port`. A `host:port` is a single network identity, so if any endpoint
|
||||
/// of the group resolved as local, all of them are local. This absorbs the
|
||||
/// transient inconsistency that orchestrated DNS churn can produce across the
|
||||
/// several drives exported by one host.
|
||||
fn normalize_same_host_local_state(pools: &mut [Endpoints]) {
|
||||
let mut local_hosts: HashSet<String> = HashSet::new();
|
||||
for endpoints in pools.iter() {
|
||||
for ep in endpoints.as_ref() {
|
||||
if ep.is_local && ep.url.has_host() {
|
||||
local_hosts.insert(ep.host_port());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if local_hosts.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
for endpoints in pools.iter_mut() {
|
||||
for ep in endpoints.as_mut() {
|
||||
if !ep.is_local && ep.url.has_host() && local_hosts.contains(&ep.host_port()) {
|
||||
ep.is_local = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// represent endpoints in a given pool
|
||||
/// along with its setCount and setDriveCount.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -1280,32 +1237,11 @@ impl EndpointServerPools {
|
||||
) -> Result<(EndpointServerPools, SetupType)> {
|
||||
let mut local_endpoint_host = get_env_opt_str(ENV_LOCAL_ENDPOINT_HOST);
|
||||
let mut policy_override = None;
|
||||
let first_endpoint = disks_layout
|
||||
.pools
|
||||
.iter()
|
||||
.flat_map(|pool| pool.iter().flatten())
|
||||
.next()
|
||||
.map(|endpoint| Endpoint::try_from(endpoint.as_str()))
|
||||
.transpose()?;
|
||||
let distributed = first_endpoint
|
||||
.as_ref()
|
||||
.is_some_and(|endpoint| endpoint.get_type() == EndpointType::Url);
|
||||
let mut all_distributed_hosts_are_ip_literals = distributed;
|
||||
if distributed {
|
||||
for raw_endpoint in disks_layout.pools.iter().flat_map(|pool| pool.iter().flatten()) {
|
||||
let endpoint = Endpoint::try_from(raw_endpoint.as_str())?;
|
||||
if !matches!(endpoint.url.host(), Some(Host::Ipv4(_) | Host::Ipv6(_))) {
|
||||
all_distributed_hosts_are_ip_literals = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let wait_mode = get_env_opt_str(ENV_STARTUP_TOPOLOGY_WAIT_MODE).map(|value| value.trim().to_ascii_lowercase());
|
||||
let infer_kubernetes_host = local_endpoint_host.is_none()
|
||||
&& distributed
|
||||
&& !all_distributed_hosts_are_ip_literals
|
||||
&& std::env::var_os(ENV_KUBERNETES_SERVICE_HOST).is_some()
|
||||
&& matches!(wait_mode.as_deref(), None | Some("") | Some("auto") | Some("orchestrated"));
|
||||
&& matches!(wait_mode.as_deref(), None | Some("") | Some("auto") | Some("orchestrated"))
|
||||
&& is_url_topology_with_non_literal_hosts(disks_layout)?;
|
||||
if infer_kubernetes_host {
|
||||
let kernel_hostname = kernel_hostname_for_endpoint_identity()?;
|
||||
let local_port = check_local_server_addr(server_addr)?.port();
|
||||
@@ -1317,7 +1253,7 @@ impl EndpointServerPools {
|
||||
policy_override = Some(StartupTopologyPolicy::resolve_from(
|
||||
Some("bounded"),
|
||||
true,
|
||||
distributed,
|
||||
true,
|
||||
get_env_opt_str(ENV_STARTUP_TOPOLOGY_WAIT_TIMEOUT).as_deref(),
|
||||
get_env_opt_str(ENV_STARTUP_TOPOLOGY_RETRY_MAX_DELAY).as_deref(),
|
||||
false,
|
||||
@@ -1788,7 +1724,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn system_resolver_negative_result_reaches_the_dns_allowlist() {
|
||||
let Err(err) = get_host_ip(Host::Domain("rustfs-startup-negative.invalid")).await else {
|
||||
let Err(err) = lookup_startup_host_ips(Host::Domain("rustfs-startup-negative.invalid")).await else {
|
||||
// Some corporate and ISP resolvers synthesize an address for
|
||||
// unknown names, including the reserved .invalid suffix.
|
||||
return;
|
||||
@@ -1959,22 +1895,48 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normalize_same_host_local_state_unifies_divergent_verdicts() {
|
||||
let mut d1 = Endpoint::try_from("http://node1:9000/d1").unwrap();
|
||||
let mut d2 = Endpoint::try_from("http://node1:9000/d2").unwrap();
|
||||
d1.is_local = true;
|
||||
d2.is_local = false; // divergent verdict for the same host:port
|
||||
let mut remote = Endpoint::try_from("http://node2:9000/d1").unwrap();
|
||||
remote.is_local = false;
|
||||
#[tokio::test]
|
||||
async fn startup_reuses_one_dns_answer_per_host_across_ports_and_pools() {
|
||||
let mut pools = PoolEndpointList {
|
||||
inner: vec![
|
||||
Endpoints::try_from(["http://node1:9000/d1", "http://node1:9000/d2", "http://node2:9000/d1"].as_slice())
|
||||
.expect("first pool endpoints should parse"),
|
||||
Endpoints::try_from(["http://node1:9000/d3", "http://node1:9001/d4"].as_slice())
|
||||
.expect("second pool endpoints should parse"),
|
||||
],
|
||||
setup_type: SetupType::Unknown,
|
||||
};
|
||||
let deadline = DnsRetryDeadline::new(Duration::ZERO, DNS_RETRY_MAX_DELAY);
|
||||
let node1_lookups = std::cell::Cell::new(0);
|
||||
let local_ip = IpAddr::V4(std::net::Ipv4Addr::LOCALHOST);
|
||||
let stale_ip = IpAddr::V4(std::net::Ipv4Addr::new(192, 0, 2, 10));
|
||||
let resolve = async |host: Host<&str>| match host {
|
||||
Host::Domain("node1") => {
|
||||
let lookups = node1_lookups.get();
|
||||
node1_lookups.set(lookups + 1);
|
||||
Ok(HashSet::from([if lookups == 0 { stale_ip } else { local_ip }]))
|
||||
}
|
||||
Host::Domain("node2") => Ok(HashSet::from([stale_ip])),
|
||||
_ => panic!("unexpected hostname in test: {host}"),
|
||||
};
|
||||
|
||||
let mut pools = vec![Endpoints::from(vec![d1, d2, remote])];
|
||||
normalize_same_host_local_state(&mut pools);
|
||||
let first_start = pools
|
||||
.resolve_startup_hosts(9000, &deadline, resolve)
|
||||
.await
|
||||
.expect("first lookup");
|
||||
assert_eq!(node1_lookups.get(), 1);
|
||||
assert_eq!(first_start["node1"].addresses, HashSet::from([stale_ip]));
|
||||
assert_eq!(local_flags(&pools.inner[0]), [false, false, false]);
|
||||
assert_eq!(local_flags(&pools.inner[1]), [false, false]);
|
||||
|
||||
let eps = pools[0].as_ref();
|
||||
assert!(eps[0].is_local);
|
||||
assert!(eps[1].is_local, "same host:port must inherit the local verdict");
|
||||
assert!(!eps[2].is_local, "a genuinely remote host must stay remote");
|
||||
let restart = pools
|
||||
.resolve_startup_hosts(9000, &deadline, resolve)
|
||||
.await
|
||||
.expect("fresh lookup");
|
||||
assert_eq!(node1_lookups.get(), 2);
|
||||
assert_eq!(restart["node1"].addresses, HashSet::from([local_ip]));
|
||||
assert_eq!(local_flags(&pools.inner[0]), [true, true, false]);
|
||||
assert_eq!(local_flags(&pools.inner[1]), [true, false]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2020,11 +1982,11 @@ mod test {
|
||||
// trip the DNS-IP cross-port check in bounded mode but must be deferred
|
||||
// (allowed) in orchestrated mode, where headless-service records can
|
||||
// still be flapping.
|
||||
let args = vec![
|
||||
let args = [
|
||||
"http://192.0.2.10:9000/export",
|
||||
"http://192.0.2.10:9001/export",
|
||||
"http://192.0.2.11:9000/export",
|
||||
"http://192.0.2.12:9000/export",
|
||||
"http://127.0.0.1:9000/export",
|
||||
];
|
||||
let layout = DisksLayout::from_volumes(args.as_slice()).unwrap();
|
||||
|
||||
@@ -2046,6 +2008,24 @@ mod test {
|
||||
assert_eq!(resolved.setup_type, SetupType::DistErasure);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rejects_startup_when_no_endpoint_is_local() {
|
||||
for volumes in [
|
||||
["http://192.0.2.10:9000/data", "http://192.0.2.11:9000/data"],
|
||||
["http://192.0.2.10:9000/data", "http://127.0.0.1:9001/data"],
|
||||
["http://192.0.2.10:9000/data1", "http://192.0.2.10:9000/data2"],
|
||||
] {
|
||||
let layout = DisksLayout::from_volumes(&volumes).expect("URL topology should parse");
|
||||
for policy in [bounded_test_policy(), orchestrated_test_policy()] {
|
||||
let err = EndpointServerPools::create_server_endpoints_with("0.0.0.0:9000", &layout, Some(policy), None)
|
||||
.await
|
||||
.expect_err("startup must reject a topology with no local endpoints");
|
||||
assert_eq!(err.kind(), ErrorKind::InvalidInput);
|
||||
assert!(err.to_string().contains("no local storage endpoints"), "{err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_local_endpoint_host_accepts_only_a_canonical_host() {
|
||||
assert_eq!(
|
||||
@@ -2274,7 +2254,7 @@ mod test {
|
||||
|
||||
#[serial]
|
||||
#[tokio::test]
|
||||
async fn create_server_endpoints_infers_kubernetes_pod_host_without_peer_dns() {
|
||||
async fn create_server_endpoints_infers_kubernetes_host_after_literal_peer_without_dns() {
|
||||
let _kernel_hostname = force_kernel_hostname_for_test("rustfs-0");
|
||||
let local_host = "rustfs-0.rustfs-headless.ns.svc.cluster.local";
|
||||
|
||||
@@ -2288,14 +2268,16 @@ mod test {
|
||||
let (pools, setup_type) = EndpointServerPools::from_volumes(
|
||||
"0.0.0.0:9000",
|
||||
vec![
|
||||
"http://192.0.2.10:9000/data2".to_string(),
|
||||
format!("http://{local_host}:9000/data0"),
|
||||
"http://permanently-missing.invalid:9000/data1".to_string(),
|
||||
"http://192.0.2.11:9000/data3".to_string(),
|
||||
],
|
||||
)
|
||||
.await
|
||||
.expect("kernel hostname inference should avoid resolving the missing peer");
|
||||
|
||||
assert_eq!(local_flags(&pools.0[0].endpoints), vec![true, false]);
|
||||
assert_eq!(local_flags(&pools.0[0].endpoints), vec![false, true, false, false]);
|
||||
assert_eq!(setup_type, SetupType::DistErasure);
|
||||
},
|
||||
)
|
||||
@@ -2815,6 +2797,40 @@ mod test {
|
||||
assert!(err.to_string().contains("timed out after 1 attempts"));
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn startup_dns_deadline_stops_pending_and_later_lookups() {
|
||||
let timeout = Duration::from_secs(3);
|
||||
let deadline = DnsRetryDeadline::new(timeout, DNS_RETRY_MAX_DELAY);
|
||||
let lookups = std::cell::Cell::new(0);
|
||||
let resolve = async |_host: Host<&str>| {
|
||||
lookups.set(lookups.get() + 1);
|
||||
std::future::pending::<Result<HashSet<IpAddr>>>().await
|
||||
};
|
||||
|
||||
let err = tokio::time::timeout(
|
||||
timeout * 2,
|
||||
resolve_startup_host_with_retry(Host::Domain("node1"), "first endpoint", &deadline, &resolve),
|
||||
)
|
||||
.await
|
||||
.expect("a pending lookup must complete before the test deadline")
|
||||
.expect_err("a pending lookup must stop at the startup deadline");
|
||||
assert_eq!(err.kind(), ErrorKind::TimedOut);
|
||||
assert!(err.to_string().contains("first endpoint"));
|
||||
assert!(err.to_string().contains("startup DNS deadline elapsed"));
|
||||
assert_eq!(deadline.elapsed(), timeout);
|
||||
assert_eq!(lookups.get(), 1);
|
||||
|
||||
let err = tokio::time::timeout(
|
||||
timeout * 2,
|
||||
resolve_startup_host_with_retry(Host::Domain("node2"), "second endpoint", &deadline, &resolve),
|
||||
)
|
||||
.await
|
||||
.expect("a later lookup must complete before the test deadline")
|
||||
.expect_err("an exhausted startup budget must prevent a new lookup");
|
||||
assert!(err.to_string().contains("second endpoint"));
|
||||
assert_eq!(lookups.get(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_new_endpoints() {
|
||||
let test_cases = [
|
||||
|
||||
@@ -149,7 +149,7 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tokio::io::{AsyncRead, ReadBuf};
|
||||
use tokio::sync::{RwLock, mpsc, oneshot, watch};
|
||||
use tokio::sync::{RwLock, mpsc, oneshot};
|
||||
use tokio::task::JoinSet;
|
||||
|
||||
pub(in crate::set_disk) const EVENT_SET_DISK_READ: &str = "set_disk_read";
|
||||
@@ -3279,7 +3279,6 @@ fn rename_tail_cleanup_queue() -> &'static RenameTailCleanupQueue {
|
||||
}
|
||||
|
||||
const EVENT_SET_DISK_RENAME_ROLLBACK: &str = "set_disk_rename_rollback";
|
||||
const PUT_RENAME_POST_QUORUM_DISPATCH_GRACE: Duration = Duration::from_secs(1);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum RenameDispatchState {
|
||||
@@ -3306,22 +3305,12 @@ struct RenameBatchGroup {
|
||||
slots: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct RenameSlotPaths {
|
||||
src_bucket: String,
|
||||
src_object: String,
|
||||
dst_bucket: String,
|
||||
dst_object: String,
|
||||
}
|
||||
|
||||
impl RenameSlotPaths {
|
||||
fn new(src_bucket: &str, src_object: &str, dst_bucket: &str, dst_object: &str) -> Self {
|
||||
Self {
|
||||
src_bucket: src_bucket.to_owned(),
|
||||
src_object: src_object.to_owned(),
|
||||
dst_bucket: dst_bucket.to_owned(),
|
||||
dst_object: dst_object.to_owned(),
|
||||
}
|
||||
}
|
||||
src_bucket: Arc<String>,
|
||||
src_object: Arc<String>,
|
||||
dst_bucket: Arc<String>,
|
||||
dst_object: Arc<String>,
|
||||
}
|
||||
|
||||
struct RenameSlotContext {
|
||||
@@ -3331,22 +3320,20 @@ struct RenameSlotContext {
|
||||
scanner_token: Option<Uuid>,
|
||||
namespace_owner: Option<Arc<dyn Send + Sync>>,
|
||||
publication_scope: Option<crate::object_api::ScannerPublicationCommitScope>,
|
||||
paths: Arc<RenameSlotPaths>,
|
||||
paths: RenameSlotPaths,
|
||||
successful_completion_rank: Option<Arc<AtomicUsize>>,
|
||||
write_quorum: usize,
|
||||
dispatch_deadline: Option<disk::RenameDispatchDeadline>,
|
||||
}
|
||||
|
||||
struct RenameOutcomeProducerArgs {
|
||||
disks: Arc<Vec<Option<DiskStore>>>,
|
||||
file_infos: Arc<Vec<FileInfo>>,
|
||||
fence_tokens: Arc<Vec<Option<Uuid>>>,
|
||||
paths: Arc<RenameSlotPaths>,
|
||||
paths: RenameSlotPaths,
|
||||
namespace_owner: Option<Arc<dyn Send + Sync>>,
|
||||
publication_scope: Option<crate::object_api::ScannerPublicationCommitScope>,
|
||||
write_quorum: usize,
|
||||
allow_batch: bool,
|
||||
dispatch_deadline: Option<disk::RenameDispatchDeadline>,
|
||||
}
|
||||
|
||||
struct RenameOutcomeProducers {
|
||||
@@ -3840,7 +3827,6 @@ pub(in crate::set_disk) struct RenameDataFenceOptions<'a> {
|
||||
rollback_receipt: Option<RenameRollbackReceipt>,
|
||||
multipart_proof_authority: Option<crate::disk::multipart_source::ProofVerificationContext>,
|
||||
multipart_commit_owner: Option<Arc<MultipartLogicalGuards>>,
|
||||
bound_dispatch_after_quorum: bool,
|
||||
}
|
||||
|
||||
impl<'a> RenameDataFenceOptions<'a> {
|
||||
@@ -3856,15 +3842,9 @@ impl<'a> RenameDataFenceOptions<'a> {
|
||||
rollback_receipt: None,
|
||||
multipart_proof_authority: None,
|
||||
multipart_commit_owner: None,
|
||||
bound_dispatch_after_quorum: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::set_disk) fn with_quorum_bounded_dispatch(mut self, enabled: bool) -> Self {
|
||||
self.bound_dispatch_after_quorum = enabled;
|
||||
self
|
||||
}
|
||||
|
||||
pub(in crate::set_disk) fn with_multipart_commit_owner(mut self, owner: Arc<MultipartLogicalGuards>) -> Self {
|
||||
self.multipart_commit_owner = Some(owner);
|
||||
self
|
||||
@@ -4446,7 +4426,6 @@ impl SetDisks {
|
||||
disk::RenameDataGuards {
|
||||
scanner_publication_lease_token: context.scanner_token,
|
||||
namespace_owner: context.namespace_owner.clone(),
|
||||
dispatch_deadline: context.dispatch_deadline.clone(),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
@@ -4623,7 +4602,6 @@ impl SetDisks {
|
||||
publication_scope,
|
||||
write_quorum,
|
||||
allow_batch,
|
||||
dispatch_deadline,
|
||||
} = args;
|
||||
debug_assert!(!allow_batch || publication_scope.is_none());
|
||||
let disk_count = disks.len();
|
||||
@@ -4648,10 +4626,6 @@ impl SetDisks {
|
||||
continue;
|
||||
}
|
||||
let outcome_tx = outcome_tx.clone();
|
||||
let dispatch_deadline = dispatch_deadline
|
||||
.as_ref()
|
||||
.filter(|_| disk.as_ref().is_some_and(|disk| !disk.is_local()))
|
||||
.cloned();
|
||||
let context = RenameSlotContext {
|
||||
slot,
|
||||
disk,
|
||||
@@ -4662,7 +4636,6 @@ impl SetDisks {
|
||||
paths: paths.clone(),
|
||||
successful_completion_rank: successful_completion_rank.clone(),
|
||||
write_quorum,
|
||||
dispatch_deadline,
|
||||
};
|
||||
let resource_unit = resource_unit.clone();
|
||||
let producer = crate::disk::with_optional_resource_unit(resource_unit, async move {
|
||||
@@ -4680,7 +4653,6 @@ impl SetDisks {
|
||||
let group_disks = disks.clone();
|
||||
let group_tokens = fence_tokens.clone();
|
||||
let resource_unit = resource_unit.clone();
|
||||
let dispatch_deadline = dispatch_deadline.clone();
|
||||
let producer = crate::disk::with_optional_resource_unit(resource_unit, async move {
|
||||
let prepared = join_all(group.slots.into_iter().map(|slot| {
|
||||
let context = RenameSlotContext {
|
||||
@@ -4693,7 +4665,6 @@ impl SetDisks {
|
||||
paths: paths.clone(),
|
||||
successful_completion_rank: successful_completion_rank.clone(),
|
||||
write_quorum,
|
||||
dispatch_deadline: dispatch_deadline.clone(),
|
||||
};
|
||||
async move { (slot, Self::prepare_and_admit_rename_slot(context).await) }
|
||||
}))
|
||||
@@ -4765,7 +4736,6 @@ impl SetDisks {
|
||||
&paths.dst_bucket,
|
||||
&paths.dst_object,
|
||||
items,
|
||||
dispatch_deadline,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -4874,7 +4844,6 @@ impl SetDisks {
|
||||
rollback_receipt,
|
||||
multipart_proof_authority: _,
|
||||
multipart_commit_owner: _,
|
||||
bound_dispatch_after_quorum: _,
|
||||
} = fence_options;
|
||||
if let Some(file_info) = disks
|
||||
.iter()
|
||||
@@ -4895,13 +4864,19 @@ impl SetDisks {
|
||||
Arc::new(Self::scanner_publication_lease_tokens_for_disks(disks, scanner_publication_lease_tokens)?);
|
||||
Self::record_rename_batch_candidates(disks, &file_infos, &fanout_fence_tokens, src_bucket, dst_bucket, dst_object);
|
||||
let coordinator_disks = fanout_disks.clone();
|
||||
let paths = Arc::new(RenameSlotPaths::new(src_bucket, src_object, dst_bucket, dst_object));
|
||||
let src_bucket = Arc::new(src_bucket.to_string());
|
||||
let src_object = Arc::new(src_object.to_string());
|
||||
let dst_bucket = Arc::new(dst_bucket.to_string());
|
||||
let dst_object = Arc::new(dst_object.to_string());
|
||||
let (commit_tx, commit_rx) = oneshot::channel();
|
||||
|
||||
let coordinator_failure_receipt = rollback_receipt.clone();
|
||||
let early_ack_spawn_to_quorum_wait_started = rustfs_io_metrics::put_stage_timer();
|
||||
let tail_drain = tokio::spawn(crate::disk::with_detached_disk_io_context({
|
||||
let paths = paths.clone();
|
||||
let fanout_src_bucket = src_bucket.clone();
|
||||
let fanout_src_object = src_object.clone();
|
||||
let fanout_dst_bucket = dst_bucket.clone();
|
||||
let fanout_dst_object = dst_object.clone();
|
||||
async move {
|
||||
let allow_batch = scanner_publication_commit_scope.is_none();
|
||||
let RenameOutcomeProducers {
|
||||
@@ -4911,12 +4886,16 @@ impl SetDisks {
|
||||
disks: fanout_disks.clone(),
|
||||
file_infos: file_infos.clone(),
|
||||
fence_tokens: fanout_fence_tokens.clone(),
|
||||
paths: paths.clone(),
|
||||
paths: RenameSlotPaths {
|
||||
src_bucket: fanout_src_bucket.clone(),
|
||||
src_object: fanout_src_object.clone(),
|
||||
dst_bucket: fanout_dst_bucket.clone(),
|
||||
dst_object: fanout_dst_object.clone(),
|
||||
},
|
||||
namespace_owner: namespace_commit_guard.clone().map(|owner| owner as Arc<dyn Send + Sync>),
|
||||
publication_scope: scanner_publication_commit_scope,
|
||||
write_quorum,
|
||||
allow_batch,
|
||||
dispatch_deadline: None,
|
||||
});
|
||||
|
||||
let mut commit_tx = Some(commit_tx);
|
||||
@@ -5001,7 +4980,7 @@ impl SetDisks {
|
||||
}
|
||||
if let Some(commit_tx) = commit_tx.take() {
|
||||
#[cfg(test)]
|
||||
rename_fanout_barrier::wait_for_armed_rename_before_early_ack(&paths.dst_object).await;
|
||||
rename_fanout_barrier::wait_for_armed_rename_before_early_ack(&fanout_dst_object).await;
|
||||
let _ = commit_tx.send(snapshot_commit);
|
||||
}
|
||||
sent_commit = true;
|
||||
@@ -5019,7 +4998,7 @@ impl SetDisks {
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
rollback_fault_injection::after_fanout(&paths.dst_object);
|
||||
rollback_fault_injection::after_fanout(&fanout_dst_object);
|
||||
if rustfs_io_metrics::put_stage_metrics_enabled() {
|
||||
let fanout_success = errs.iter().filter(|err| err.is_none()).count();
|
||||
let fanout_error = errs.len().saturating_sub(fanout_success + fanout_panic);
|
||||
@@ -5042,7 +5021,7 @@ impl SetDisks {
|
||||
&errs,
|
||||
&dispatch_states,
|
||||
&data_dirs,
|
||||
(&paths.dst_bucket, &paths.dst_object),
|
||||
(&fanout_dst_bucket, &fanout_dst_object),
|
||||
RenameRollbackOwnership {
|
||||
receipt: rollback_receipt,
|
||||
namespace_commit_guard,
|
||||
@@ -5089,10 +5068,11 @@ impl SetDisks {
|
||||
let Some(disk) = disk.clone() else {
|
||||
continue;
|
||||
};
|
||||
let paths = paths.clone();
|
||||
let dst_bucket = fanout_dst_bucket.clone();
|
||||
let dst_object = fanout_dst_object.clone();
|
||||
backup_reclaims.push(tokio::spawn(async move {
|
||||
let backup_path = format!("{}/{rollback_dir}/{STORAGE_FORMAT_FILE_BACKUP}", paths.dst_object);
|
||||
disk.delete(&paths.dst_bucket, &backup_path, DeleteOptions::default()).await
|
||||
let backup_path = format!("{dst_object}/{rollback_dir}/{STORAGE_FORMAT_FILE_BACKUP}");
|
||||
disk.delete(&dst_bucket, &backup_path, DeleteOptions::default()).await
|
||||
}));
|
||||
}
|
||||
for result in join_all(backup_reclaims).await {
|
||||
@@ -5101,16 +5081,16 @@ impl SetDisks {
|
||||
Ok(Err(DiskError::FileNotFound | DiskError::VolumeNotFound)) => {}
|
||||
Ok(Err(err)) => {
|
||||
warn!(
|
||||
dst_bucket = %paths.dst_bucket,
|
||||
dst_object = %paths.dst_object,
|
||||
dst_bucket = %fanout_dst_bucket,
|
||||
dst_object = %fanout_dst_object,
|
||||
error = %err,
|
||||
"rollback backup reclamation failed after committed rename"
|
||||
);
|
||||
}
|
||||
Err(join_err) => {
|
||||
warn!(
|
||||
dst_bucket = %paths.dst_bucket,
|
||||
dst_object = %paths.dst_object,
|
||||
dst_bucket = %fanout_dst_bucket,
|
||||
dst_object = %fanout_dst_object,
|
||||
error = %join_err,
|
||||
"rollback backup reclamation task failed after committed rename"
|
||||
);
|
||||
@@ -5156,7 +5136,7 @@ impl SetDisks {
|
||||
let commit = match commit_rx.await {
|
||||
Ok(commit) => commit,
|
||||
Err(_) => {
|
||||
record_indeterminate_rename(disks, (dst_bucket, dst_object), coordinator_failure_receipt).await;
|
||||
record_indeterminate_rename(disks, (&dst_bucket, &dst_object), coordinator_failure_receipt).await;
|
||||
return Err(DiskError::Unexpected);
|
||||
}
|
||||
};
|
||||
@@ -5236,7 +5216,6 @@ impl SetDisks {
|
||||
rollback_receipt,
|
||||
multipart_proof_authority,
|
||||
multipart_commit_owner,
|
||||
bound_dispatch_after_quorum,
|
||||
} = fence_options;
|
||||
if let Some(file_info) = disks
|
||||
.iter()
|
||||
@@ -5260,15 +5239,28 @@ impl SetDisks {
|
||||
};
|
||||
let mut errs = vec![Some(DiskError::Unexpected); disks.len()];
|
||||
|
||||
let paths = Arc::new(RenameSlotPaths::new(src_bucket, src_object, dst_bucket, dst_object));
|
||||
let src_bucket = Arc::new(src_bucket.to_string());
|
||||
let src_object = Arc::new(src_object.to_string());
|
||||
let dst_bucket = Arc::new(dst_bucket.to_string());
|
||||
let dst_object = Arc::new(dst_object.to_string());
|
||||
|
||||
let disk_count = disks.len();
|
||||
let fanout_disks = Arc::new(disks.to_vec());
|
||||
let fanout_file_infos = Arc::new(file_infos);
|
||||
let fanout_fence_tokens =
|
||||
Arc::new(Self::scanner_publication_lease_tokens_for_disks(disks, scanner_publication_lease_tokens)?);
|
||||
Self::record_rename_batch_candidates(disks, &fanout_file_infos, &fanout_fence_tokens, src_bucket, dst_bucket, dst_object);
|
||||
let fanout_paths = paths.clone();
|
||||
Self::record_rename_batch_candidates(
|
||||
disks,
|
||||
&fanout_file_infos,
|
||||
&fanout_fence_tokens,
|
||||
src_bucket.as_str(),
|
||||
dst_bucket.as_str(),
|
||||
dst_object.as_str(),
|
||||
);
|
||||
let fanout_src_bucket = src_bucket.clone();
|
||||
let fanout_src_object = src_object.clone();
|
||||
let fanout_dst_bucket = dst_bucket.clone();
|
||||
let fanout_dst_object = dst_object.clone();
|
||||
let fanout_publication_scope = scanner_publication_commit_scope.clone();
|
||||
let logical_guards = multipart_commit_owner;
|
||||
let multipart_commit_owner = logical_guards
|
||||
@@ -5286,16 +5278,13 @@ impl SetDisks {
|
||||
// fan-out owner, even if the caller future is cancelled.
|
||||
let _fanout_publication_scope = fanout_publication_scope;
|
||||
let _namespace_commit_guard = fanout_namespace_commit_guard.clone();
|
||||
let allow_batch = !protected_multipart && scanner_publication_commit_scope.is_none();
|
||||
let (dispatch_deadline_tx, dispatch_deadline) = if bound_dispatch_after_quorum
|
||||
&& fanout_disks.iter().flatten().count() > write_quorum
|
||||
&& fanout_disks.iter().flatten().any(|disk| !disk.is_local())
|
||||
{
|
||||
let (tx, rx) = watch::channel(None);
|
||||
(Some(tx), Some(rx))
|
||||
} else {
|
||||
(None, None)
|
||||
let paths = RenameSlotPaths {
|
||||
src_bucket: fanout_src_bucket,
|
||||
src_object: fanout_src_object,
|
||||
dst_bucket: fanout_dst_bucket,
|
||||
dst_object: fanout_dst_object.clone(),
|
||||
};
|
||||
let allow_batch = !protected_multipart && scanner_publication_commit_scope.is_none();
|
||||
let RenameOutcomeProducers {
|
||||
outcomes: mut outcome_rx,
|
||||
mut tasks,
|
||||
@@ -5303,29 +5292,19 @@ impl SetDisks {
|
||||
disks: fanout_disks,
|
||||
file_infos: fanout_file_infos.clone(),
|
||||
fence_tokens: fanout_fence_tokens,
|
||||
paths: fanout_paths.clone(),
|
||||
paths,
|
||||
namespace_owner: fanout_namespace_owner,
|
||||
publication_scope: scanner_publication_commit_scope,
|
||||
write_quorum,
|
||||
allow_batch,
|
||||
dispatch_deadline,
|
||||
});
|
||||
let mut results = Vec::with_capacity(disk_count);
|
||||
let mut successful = 0;
|
||||
while let Some(outcome) = outcome_rx.recv().await {
|
||||
if let Some(tx) = dispatch_deadline_tx.as_ref()
|
||||
&& matches!(&outcome.completion, Ok(Ok(_)))
|
||||
{
|
||||
successful += 1;
|
||||
if successful == write_quorum {
|
||||
tx.send_replace(Some(tokio::time::Instant::now() + PUT_RENAME_POST_QUORUM_DISPATCH_GRACE));
|
||||
}
|
||||
}
|
||||
results.push(outcome);
|
||||
}
|
||||
while tasks.join_next().await.is_some() {}
|
||||
#[cfg(test)]
|
||||
rollback_fault_injection::after_fanout(&fanout_paths.dst_object);
|
||||
rollback_fault_injection::after_fanout(&fanout_dst_object);
|
||||
(results, fanout_file_infos)
|
||||
};
|
||||
let fanout_future = crate::disk::with_detached_disk_io_context(fanout_future);
|
||||
@@ -5359,7 +5338,7 @@ impl SetDisks {
|
||||
let (results, file_infos) = match fanout_result {
|
||||
Ok(result) => result,
|
||||
Err(_) => {
|
||||
record_indeterminate_rename(disks, (dst_bucket, dst_object), rollback_receipt).await;
|
||||
record_indeterminate_rename(disks, (&dst_bucket, &dst_object), rollback_receipt).await;
|
||||
return Err(DiskError::Unexpected);
|
||||
}
|
||||
};
|
||||
@@ -5492,7 +5471,7 @@ impl SetDisks {
|
||||
// Destination-only Undo cannot restore a consumed MPU head.
|
||||
// Only this failed owner can spend the original native caps.
|
||||
owner
|
||||
.failed_owned(disks, &file_infos, src_object, (dst_bucket, dst_object), namespace_commit_guard)
|
||||
.failed_owned(disks, &file_infos, &src_object, (&dst_bucket, &dst_object), namespace_commit_guard)
|
||||
.await;
|
||||
} else {
|
||||
rollback_failed_rename(
|
||||
@@ -5501,7 +5480,7 @@ impl SetDisks {
|
||||
&errs,
|
||||
&dispatch_states,
|
||||
&data_dirs,
|
||||
(dst_bucket, dst_object),
|
||||
(&dst_bucket, &dst_object),
|
||||
RenameRollbackOwnership {
|
||||
receipt: rollback_receipt,
|
||||
namespace_commit_guard,
|
||||
@@ -5547,10 +5526,11 @@ impl SetDisks {
|
||||
let Some(disk) = disk.clone() else {
|
||||
continue;
|
||||
};
|
||||
let paths = paths.clone();
|
||||
let dst_bucket = dst_bucket.clone();
|
||||
let dst_object = dst_object.clone();
|
||||
backup_reclaims.push(tokio::spawn(async move {
|
||||
let backup_path = format!("{}/{rollback_dir}/{STORAGE_FORMAT_FILE_BACKUP}", paths.dst_object);
|
||||
disk.delete(&paths.dst_bucket, &backup_path, DeleteOptions::default()).await
|
||||
let backup_path = format!("{dst_object}/{rollback_dir}/{STORAGE_FORMAT_FILE_BACKUP}");
|
||||
disk.delete(&dst_bucket, &backup_path, DeleteOptions::default()).await
|
||||
}));
|
||||
}
|
||||
for result in join_all(backup_reclaims).await {
|
||||
@@ -12838,66 +12818,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial(capacity_dirty_scope)]
|
||||
async fn rename_data_bounds_cold_connect_after_durable_quorum() {
|
||||
const DISKS: usize = 4;
|
||||
let bucket = "rename-connect-tail-bucket";
|
||||
let object = "rename-connect-tail-object";
|
||||
let (dirs, mut disks) = call_counter_local_disks(bucket, DISKS).await;
|
||||
prepare_rename_source_dirs(&dirs, &disks, "source").await;
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.expect("bind cold peer");
|
||||
// The TCP socket remains open, but there is no TLS server to finish the dial.
|
||||
let endpoint = crate::disk::endpoint::Endpoint {
|
||||
url: url::Url::parse(&format!("https://{}/data/rustfs0", listener.local_addr().expect("cold peer address")))
|
||||
.expect("cold peer URL"),
|
||||
is_local: false,
|
||||
pool_idx: 0,
|
||||
set_idx: 0,
|
||||
disk_idx: 3,
|
||||
};
|
||||
disks[DISKS - 1] = Some(
|
||||
crate::disk::new_disk(
|
||||
&endpoint,
|
||||
&crate::disk::DiskOption {
|
||||
cleanup: false,
|
||||
health_check: false,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("construct remote disk"),
|
||||
);
|
||||
let file_infos = rename_commit_fileinfos(object, DISKS, "bounded-connect-etag");
|
||||
let commit = temp_env::async_with_vars([(rustfs_config::ENV_INTERNODE_CONNECT_TIMEOUT_SECS, Some("15"))], async {
|
||||
tokio::time::timeout(
|
||||
Duration::from_secs(5),
|
||||
SetDisks::rename_data_owned_with_fence(
|
||||
&disks,
|
||||
(RUSTFS_META_TMP_BUCKET, "source"),
|
||||
file_infos,
|
||||
(bucket, object),
|
||||
false,
|
||||
RenameDataFenceOptions::new(3, None).with_quorum_bounded_dispatch(true),
|
||||
),
|
||||
)
|
||||
.await
|
||||
.expect("durable quorum must finish before the silent peer's dial deadline")
|
||||
.expect("three durable renames must satisfy write quorum")
|
||||
})
|
||||
.await;
|
||||
assert_eq!(commit.convergence, RenameConvergence::PartialCommit);
|
||||
assert!(commit.needs_immediate_heal());
|
||||
assert!(commit.tail_drain.is_none());
|
||||
for dir in dirs.iter().take(3) {
|
||||
let reopened = reopen_local_disk(dir).await;
|
||||
let stored = reopened
|
||||
.read_version("", bucket, object, "", &ReadOptions::default())
|
||||
.await
|
||||
.expect("quorum metadata survives reopening");
|
||||
assert_eq!(stored.metadata.get("etag").map(String::as_str), Some("bounded-connect-etag"));
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial(capacity_dirty_scope)]
|
||||
async fn rename_data_without_tail_handoff_waits_after_write_quorum() {
|
||||
|
||||
@@ -25,8 +25,7 @@ use super::super::{
|
||||
reduce_write_quorum_errs,
|
||||
};
|
||||
use crate::api::bucket::metadata_sys;
|
||||
use crate::disk::{DiskAPI, DiskStore, VolumeInfo};
|
||||
use futures::{Stream, StreamExt, stream::FuturesUnordered};
|
||||
use crate::disk::DiskAPI;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) enum BucketInfoQuorum {
|
||||
@@ -35,39 +34,6 @@ pub(crate) enum BucketInfoQuorum {
|
||||
HealCandidates,
|
||||
}
|
||||
|
||||
async fn stat_bucket_volume(disk: Option<DiskStore>, bucket: &str) -> crate::disk::error::Result<VolumeInfo> {
|
||||
match disk {
|
||||
Some(disk) => disk.stat_volume(bucket).await,
|
||||
None => Err(DiskError::DiskNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
async fn collect_bucket_presence(
|
||||
mut probes: impl Stream<Item = crate::disk::error::Result<()>> + Unpin,
|
||||
disk_count: usize,
|
||||
) -> Result<()> {
|
||||
let required = disk_count.div_ceil(2).max(1);
|
||||
let mut successes = 0;
|
||||
let mut errors = Vec::new();
|
||||
while let Some(result) = probes.next().await {
|
||||
match result {
|
||||
Ok(()) => {
|
||||
successes += 1;
|
||||
// The reducer favors success on ties, so the remaining disks
|
||||
// cannot change this decision. Presence doesn't use timestamps.
|
||||
if successes == required {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
Err(err) => errors.push(Some(err)),
|
||||
}
|
||||
}
|
||||
errors.resize_with(errors.len() + successes, || None);
|
||||
Err(reduce_read_quorum_errs(&errors, BUCKET_OP_IGNORED_ERRS, required)
|
||||
.unwrap_or(DiskError::ErasureReadQuorum)
|
||||
.into())
|
||||
}
|
||||
|
||||
impl SetDisks {
|
||||
/// Require proof from every configured disk before retiring a bucket
|
||||
/// generation whose visible volume was removed outside the storage API.
|
||||
@@ -77,9 +43,12 @@ impl SetDisks {
|
||||
return Err(Error::ErasureReadQuorum);
|
||||
}
|
||||
|
||||
let futures = disks
|
||||
.into_iter()
|
||||
.map(|disk| async move { stat_bucket_volume(disk, bucket).await.map(|_| ()) });
|
||||
let futures = disks.into_iter().map(|disk| async move {
|
||||
match disk {
|
||||
Some(disk) => disk.stat_volume(bucket).await.map(|_| ()),
|
||||
None => Err(DiskError::DiskNotFound),
|
||||
}
|
||||
});
|
||||
let results = join_all(futures).await;
|
||||
let mut volume_present = false;
|
||||
let mut first_unknown = None;
|
||||
@@ -101,32 +70,26 @@ impl SetDisks {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn check_bucket_presence_at_read_quorum(&self, bucket: &str) -> Result<()> {
|
||||
let disks = self.disk_inventory().await;
|
||||
let disk_count = disks.len();
|
||||
let probes = disks
|
||||
.into_iter()
|
||||
.map(|disk| async move { stat_bucket_volume(disk, bucket).await.map(|_| ()) })
|
||||
.collect::<FuturesUnordered<_>>();
|
||||
collect_bucket_presence(probes, disk_count).await
|
||||
}
|
||||
|
||||
pub(crate) async fn stat_bucket_with_quorum(&self, bucket: &str, quorum: BucketInfoQuorum) -> Result<BucketInfo> {
|
||||
let disks = self.disk_inventory().await;
|
||||
let disk_count = disks.len();
|
||||
let probes = disks.into_iter().map(|disk| stat_bucket_volume(disk, bucket));
|
||||
let results = join_all(probes).await;
|
||||
let mut first_info = None;
|
||||
let results = join_all(disks.into_iter().map(|disk| async move {
|
||||
match disk {
|
||||
Some(disk) => disk.stat_volume(bucket).await,
|
||||
None => Err(DiskError::DiskNotFound),
|
||||
}
|
||||
}))
|
||||
.await;
|
||||
let mut infos = Vec::with_capacity(results.len());
|
||||
let mut errs = Vec::with_capacity(results.len());
|
||||
for result in results {
|
||||
match result {
|
||||
Ok(info) => {
|
||||
if first_info.is_none() {
|
||||
first_info = Some(info);
|
||||
}
|
||||
infos.push(Some(info));
|
||||
errs.push(None);
|
||||
}
|
||||
Err(err) => {
|
||||
infos.push(None);
|
||||
errs.push(Some(err));
|
||||
}
|
||||
}
|
||||
@@ -145,7 +108,10 @@ impl SetDisks {
|
||||
return Err(err.into());
|
||||
}
|
||||
|
||||
first_info
|
||||
infos
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.next()
|
||||
.map(|info| BucketInfo {
|
||||
name: info.name,
|
||||
created: info.created,
|
||||
@@ -370,46 +336,3 @@ impl BucketOperations for SetDisks {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use futures::{FutureExt, stream};
|
||||
|
||||
#[test]
|
||||
fn bucket_presence_returns_with_a_silent_peer() {
|
||||
let probes = stream::iter([Err(DiskError::VolumeNotFound), Ok(()), Ok(())]).chain(stream::pending());
|
||||
|
||||
collect_bucket_presence(probes, 4)
|
||||
.now_or_never()
|
||||
.expect("read quorum must return before the fourth probe replies")
|
||||
.expect("two successes win even if both other disks report a missing volume");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn bucket_presence_preserves_absence_and_read_quorum_errors() {
|
||||
let probes = stream::iter([Ok(()), Err(DiskError::VolumeNotFound), Err(DiskError::DiskNotFound)]);
|
||||
assert!(
|
||||
collect_bucket_presence(probes.chain(stream::pending()), 4)
|
||||
.now_or_never()
|
||||
.is_none(),
|
||||
"the last disk can still prove either presence or absence"
|
||||
);
|
||||
|
||||
let missing = stream::iter([
|
||||
Ok(()),
|
||||
Err(DiskError::VolumeNotFound),
|
||||
Err(DiskError::DiskNotFound),
|
||||
Err(DiskError::VolumeNotFound),
|
||||
]);
|
||||
assert!(matches!(collect_bucket_presence(missing, 4).await, Err(Error::VolumeNotFound)));
|
||||
|
||||
let unavailable = stream::iter([
|
||||
Ok(()),
|
||||
Err(DiskError::VolumeNotFound),
|
||||
Err(DiskError::DiskNotFound),
|
||||
Err(DiskError::DiskNotFound),
|
||||
]);
|
||||
assert!(matches!(collect_bucket_presence(unavailable, 4).await, Err(Error::ErasureReadQuorum)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5927,14 +5927,6 @@ impl SetDisks {
|
||||
|| commit_decommission_object_lock_guard.is_some()
|
||||
|| commit_publication_guard.is_some();
|
||||
let commit_write_completion = opts.write_completion;
|
||||
let bound_rename_dispatch = commit_write_completion == crate::object_api::WriteCompletion::TailDrained
|
||||
&& commit_object_lock_guard.is_some()
|
||||
&& !is_meta_bucketname(bucket)
|
||||
&& !opts.data_movement
|
||||
&& !opts.replication_request
|
||||
&& !quota_mutation_fence
|
||||
&& commit_scanner_publication_scope.is_none()
|
||||
&& scanner_publication_lease_tokens.is_none();
|
||||
let commit_allows_early_ack = write_context.allows_early_ack(commit_write_completion)
|
||||
&& !(opts.data_movement && opts.has_decommission_capacity_reservation())
|
||||
&& commit_owns_namespace_guard
|
||||
@@ -6262,7 +6254,6 @@ impl SetDisks {
|
||||
commit_scanner_publication_lease_tokens.as_ref(),
|
||||
)
|
||||
.with_publication_scope(commit_scanner_publication_scope.clone())
|
||||
.with_quorum_bounded_dispatch(bound_rename_dispatch)
|
||||
.with_rollback_receipt(commit_rollback_receipt.clone())
|
||||
.with_namespace_commit_guard(
|
||||
(!is_meta_bucketname(&commit_bucket))
|
||||
|
||||
@@ -5035,27 +5035,37 @@ mod metadata_cache_tests {
|
||||
disk.make_volume(bucket).await.expect("bucket volume should be created");
|
||||
}
|
||||
let mut reader = PutObjReader::from_vec(vec![7u8; 1024]);
|
||||
set.put_object(bucket, object, &mut reader, &ObjectOptions::default())
|
||||
.await
|
||||
.expect("test object should be written");
|
||||
// A quorum-acknowledged PUT can leave a rename running on a healthy
|
||||
// disk. This test needs an error-free fanout to reach cache publication.
|
||||
set.put_object(
|
||||
bucket,
|
||||
object,
|
||||
&mut reader,
|
||||
&ObjectOptions {
|
||||
write_completion: crate::object_api::WriteCompletion::TailDrained,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("the fixture PUT should drain its commit fanout");
|
||||
|
||||
let barrier = MetadataCachePublishBarrier::install(bucket, object);
|
||||
let stale_generation = set
|
||||
.get_object_metadata_cache_generation(bucket, object)
|
||||
.expect("metadata cache generation should be active");
|
||||
let reader_set = Arc::clone(&set);
|
||||
let read = tokio::spawn(async move {
|
||||
reader_set
|
||||
.get_object_fileinfo(bucket, object, &ObjectOptions::default(), true, false)
|
||||
.await
|
||||
});
|
||||
barrier.wait_until_paused().await;
|
||||
let opts = ObjectOptions::default();
|
||||
let read = set.get_object_fileinfo(bucket, object, &opts, true, false);
|
||||
tokio::pin!(read);
|
||||
tokio::select! {
|
||||
() = barrier.wait_until_paused() => {}
|
||||
result = &mut read => match result {
|
||||
Ok(_) => panic!("metadata read returned without reaching cache publication"),
|
||||
Err(err) => panic!("metadata read failed before cache publication: {err}"),
|
||||
},
|
||||
}
|
||||
set.invalidate_get_object_metadata_cache(bucket, object).await;
|
||||
barrier.release();
|
||||
let snapshot = read
|
||||
.await
|
||||
.expect("metadata read task should not panic")
|
||||
.expect("metadata fanout should still return its selected FileInfo");
|
||||
let snapshot = read.await.expect("metadata fanout should still return its selected FileInfo");
|
||||
assert!(snapshot.owned.is_some());
|
||||
assert!(snapshot.has_valid_representation());
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::disk::{
|
||||
};
|
||||
use crate::error::is_err_bucket_not_found;
|
||||
use crate::runtime::sources as runtime_sources;
|
||||
use crate::set_disk::{BucketInfoQuorum, SetDisks, get_lock_acquire_timeout};
|
||||
use crate::set_disk::{BucketInfoQuorum, get_lock_acquire_timeout};
|
||||
use crate::storage_api_contracts::admin::DiskSetSelector;
|
||||
use crate::storage_api_contracts::bucket::{BUCKET_LIFECYCLE_LOCK_OBJECT, SRBucketDeleteOp};
|
||||
use crate::storage_api_contracts::namespace::NamespaceLocking as _;
|
||||
@@ -1702,47 +1702,65 @@ impl ECStore {
|
||||
|
||||
#[instrument(skip(self))]
|
||||
pub(crate) async fn get_bucket_info_from_sets(&self, bucket: &str, opts: &BucketOptions) -> Result<BucketInfo> {
|
||||
self.probe_bucket_sets(|set| async move { set.get_bucket_info(bucket, opts).await })
|
||||
self.get_bucket_info_from_sets_with_quorum(bucket, opts, BucketInfoQuorum::Write)
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn check_bucket_presence_at_read_quorum(&self, bucket: &str) -> Result<()> {
|
||||
self.probe_bucket_sets(|set| async move { set.check_bucket_presence_at_read_quorum(bucket).await })
|
||||
pub(crate) async fn get_bucket_info_from_sets_at_read_quorum(
|
||||
&self,
|
||||
bucket: &str,
|
||||
opts: &BucketOptions,
|
||||
) -> Result<BucketInfo> {
|
||||
self.get_bucket_info_from_sets_with_quorum(bucket, opts, BucketInfoQuorum::Read)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn probe_bucket_sets<T, F: Future<Output = Result<T>>>(&self, probe: impl Fn(Arc<SetDisks>) -> F) -> Result<T> {
|
||||
async fn get_bucket_info_from_sets_with_quorum(
|
||||
&self,
|
||||
bucket: &str,
|
||||
opts: &BucketOptions,
|
||||
quorum: BucketInfoQuorum,
|
||||
) -> Result<BucketInfo> {
|
||||
// One host may participate in several pools after expansion. Resolve the
|
||||
// namespace against each erasure set so disks from different pools can
|
||||
// never be combined into one bucket quorum.
|
||||
// Bucket validation is request-path IO. Keep the previous peer fanout's
|
||||
// latency shape by probing every set concurrently; scanner listings use
|
||||
// a separate bounded path below because they run continuously.
|
||||
let mut scoped_results = futures::future::join_all(self.bucket_sets().map(|(pool_index, set_index, set)| {
|
||||
let result = probe(set);
|
||||
async move { (pool_index, set_index, result.await) }
|
||||
let mut scoped_results = futures::future::join_all(self.bucket_sets().map(|(pool_index, set_index, set)| async move {
|
||||
let result = match quorum {
|
||||
BucketInfoQuorum::Read => set.stat_bucket_with_quorum(bucket, quorum).await,
|
||||
BucketInfoQuorum::Write | BucketInfoQuorum::HealCandidates => set.get_bucket_info(bucket, opts).await,
|
||||
};
|
||||
(pool_index, set_index, result)
|
||||
}))
|
||||
.await;
|
||||
scoped_results.sort_unstable_by_key(|(pool_index, set_index, _)| (*pool_index, *set_index));
|
||||
|
||||
let mut first_success = None;
|
||||
let mut first_info = None;
|
||||
let mut first_error = None;
|
||||
for (_, _, result) in scoped_results {
|
||||
match result {
|
||||
Ok(value) if first_success.is_none() => first_success = Some(value),
|
||||
Ok(info) if first_info.is_none() => first_info = Some(info),
|
||||
Ok(_) => {}
|
||||
Err(err) if is_err_strict_volume_not_found(&err) => {}
|
||||
Err(err) => return Err(err),
|
||||
Err(err) if first_error.is_none() => first_error = Some(err),
|
||||
Err(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
first_success.ok_or(Error::VolumeNotFound)
|
||||
if let Some(err) = first_error {
|
||||
return Err(err);
|
||||
}
|
||||
|
||||
first_info.ok_or(Error::VolumeNotFound)
|
||||
}
|
||||
|
||||
#[instrument(skip(self))]
|
||||
pub(super) async fn handle_get_bucket_info(&self, bucket: &str, opts: &BucketOptions) -> Result<BucketInfo> {
|
||||
let mut info = match self.get_bucket_info_from_sets(bucket, opts).await {
|
||||
Ok(info) => info,
|
||||
Err(Error::ErasureWriteQuorum) => return self.get_bucket_info_at_read_quorum(bucket).await,
|
||||
Err(Error::ErasureWriteQuorum) => return self.get_bucket_info_at_read_quorum(bucket, opts).await,
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
|
||||
@@ -1757,14 +1775,14 @@ impl ECStore {
|
||||
Ok(info)
|
||||
}
|
||||
|
||||
async fn get_bucket_info_at_read_quorum(&self, bucket: &str) -> Result<BucketInfo> {
|
||||
async fn get_bucket_info_at_read_quorum(&self, bucket: &str, opts: &BucketOptions) -> Result<BucketInfo> {
|
||||
// Lock order: bucket lifecycle -> internal metadata object read locks.
|
||||
// Keep create/delete from changing the namespace while a read quorum
|
||||
// confirms both physical presence and persisted bucket metadata.
|
||||
let guard = self.acquire_bucket_lifecycle_read_lock(bucket).await?;
|
||||
await_bucket_namespace_operation(Some(&guard), bucket, "bucket read quorum validation", async {
|
||||
let mut info = self
|
||||
.probe_bucket_sets(|set| async move { set.stat_bucket_with_quorum(bucket, BucketInfoQuorum::Read).await })
|
||||
.get_bucket_info_from_sets_with_quorum(bucket, opts, BucketInfoQuorum::Read)
|
||||
.await?;
|
||||
let (metadata, persisted) = metadata_sys::get_config_from_disk_with_presence_in(&self.ctx, bucket).await?;
|
||||
if !persisted {
|
||||
|
||||
@@ -8835,7 +8835,7 @@ mod tests {
|
||||
.update_metadata(
|
||||
&bucket,
|
||||
object,
|
||||
rustfs_filemeta::FileInfo {
|
||||
FileInfo {
|
||||
version_id: Some(version_id),
|
||||
metadata: retained_metadata.clone(),
|
||||
..Default::default()
|
||||
|
||||
@@ -100,7 +100,6 @@ mod multipart_copy_heal_tests {
|
||||
.collect::<Vec<_>>();
|
||||
let options = ObjectOptions {
|
||||
versioned: true,
|
||||
mod_time: Some(OffsetDateTime::from_unix_timestamp(1_700_000_000).expect("fixed native C timestamp")),
|
||||
write_completion: WriteCompletion::TailDrained,
|
||||
..Default::default()
|
||||
};
|
||||
@@ -134,7 +133,11 @@ mod multipart_copy_heal_tests {
|
||||
etag: part.etag,
|
||||
..Default::default()
|
||||
}],
|
||||
&options,
|
||||
&ObjectOptions {
|
||||
// Pin the committed timestamp without backdating the staged upload.
|
||||
mod_time: Some(OffsetDateTime::from_unix_timestamp(1_700_000_000).expect("fixed native C timestamp")),
|
||||
..options
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("actual native C quorum publication");
|
||||
|
||||
@@ -288,7 +288,7 @@ impl ECStore {
|
||||
RenameDataGuards {
|
||||
scanner_publication_lease_token: scanner_token,
|
||||
external_guard,
|
||||
..Default::default()
|
||||
namespace_owner: None,
|
||||
},
|
||||
);
|
||||
if scanner_token.is_some() {
|
||||
|
||||
@@ -21,13 +21,17 @@ pub(super) fn rules() -> Vec<Rule> {
|
||||
vec![
|
||||
Rule {
|
||||
evidence_fields: strings(["host"]),
|
||||
anchors: strings(["Create pool endpoints host"]),
|
||||
anchors: strings(["startup_endpoint_dns_failed", "Startup endpoint DNS resolution failed"]),
|
||||
..base(
|
||||
"endpoint-resolve-failed",
|
||||
P1Unavailable,
|
||||
"startup",
|
||||
"启动期端点主机名解析失败",
|
||||
all([contains("Create pool endpoints host"), contains("not found")]),
|
||||
any([
|
||||
field("event", "startup_endpoint_dns_failed"),
|
||||
contains("Startup endpoint DNS resolution failed"),
|
||||
all([contains("Create pool endpoints host"), contains("not found")]),
|
||||
]),
|
||||
"启动期端点主机名解析失败(DNS 未就绪/拼写错误/hosts 缺失)。",
|
||||
"容器/K8s 场景确认 DNS 就绪顺序;核对 volumes 参数拼写。",
|
||||
)
|
||||
|
||||
@@ -453,6 +453,15 @@ fn smoke_samples_hit_exact_rule_sets() {
|
||||
&["unknown-access-key"],
|
||||
);
|
||||
exact(&msg("HTTP transport failed: BrokenPipe while streaming response body"), &[]);
|
||||
exact(
|
||||
&Sample {
|
||||
fields: &[("event", "startup_endpoint_dns_failed"), ("host", "node5")],
|
||||
..msg("DNS deadline exhausted")
|
||||
},
|
||||
&["endpoint-resolve-failed"],
|
||||
);
|
||||
exact(&msg("Startup endpoint DNS resolution failed"), &["endpoint-resolve-failed"]);
|
||||
exact(&msg("retrying endpoint local-host detection after temporary DNS error"), &[]);
|
||||
// Internode auth failures legitimately hit both the internode rule and
|
||||
// the generic client signature rule.
|
||||
exact(
|
||||
|
||||
@@ -14,7 +14,6 @@ const LEADER_EPOCH: u64 = 11;
|
||||
const CHECKPOINT_OBJECTS: u64 = 1024;
|
||||
const CHECKPOINT_MIN_INTERVAL: Duration = Duration::from_secs(5);
|
||||
const PHASE_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
const FIRST_OBJECT: &str = "object-0000";
|
||||
|
||||
async fn checkpoint_plan(set: &Arc<SetDisks>, owner: &CancellationToken) -> ScannerBucketScanPlan {
|
||||
let buckets = vec![bucket_info(BUCKET)];
|
||||
@@ -56,15 +55,17 @@ async fn run_checkpoint_owner_case(lose_owner: bool) -> serde_json::Value {
|
||||
.make_bucket(BUCKET, &MakeBucketOptions::default())
|
||||
.await
|
||||
.expect("create checkpoint owner bucket");
|
||||
store
|
||||
.put_object(
|
||||
BUCKET,
|
||||
FIRST_OBJECT,
|
||||
&mut ScannerPutObjReader::from_vec(vec![1]),
|
||||
&ScannerObjectOptions::default(),
|
||||
)
|
||||
.await
|
||||
.expect("write a real object for the checkpoint fixture");
|
||||
for object in 0..=CHECKPOINT_OBJECTS {
|
||||
store
|
||||
.put_object(
|
||||
BUCKET,
|
||||
&format!("object-{object:04}"),
|
||||
&mut ScannerPutObjReader::from_vec(vec![1]),
|
||||
&ScannerObjectOptions::default(),
|
||||
)
|
||||
.await
|
||||
.expect("write real object for the periodic checkpoint threshold");
|
||||
}
|
||||
save_config(
|
||||
store.clone(),
|
||||
DATA_USAGE_BLOOM_NAME_PATH.as_str(),
|
||||
@@ -73,27 +74,10 @@ async fn run_checkpoint_owner_case(lose_owner: bool) -> serde_json::Value {
|
||||
.await
|
||||
.expect("persist the real global cycle fence");
|
||||
wait_for_namespace_commit_tails(store.as_ref()).await;
|
||||
let set = store.pools[0].disk_set[0].clone();
|
||||
let disk = scanner_set_disk_inventory(&set).await.pop().expect("checkpoint owner disk");
|
||||
let first_object_dir = disk
|
||||
.get_object_path_if_local(BUCKET, FIRST_OBJECT)
|
||||
.expect("checkpoint owner disk is local")
|
||||
.expect("first checkpoint fixture object path");
|
||||
// This case exercises metadata traversal and checkpoint publication. Seed
|
||||
// the other disk entries from real xl.meta without repeating the PUT path.
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let metadata = std::fs::read(first_object_dir.join(STORAGE_FORMAT_FILE)).expect("read real fixture metadata");
|
||||
let bucket_dir = first_object_dir.parent().expect("checkpoint fixture bucket directory");
|
||||
for object in 1..=CHECKPOINT_OBJECTS {
|
||||
let object_dir = bucket_dir.join(format!("object-{object:04}"));
|
||||
std::fs::create_dir(&object_dir).expect("create checkpoint fixture object directory");
|
||||
std::fs::write(object_dir.join(STORAGE_FORMAT_FILE), &metadata).expect("seed checkpoint fixture metadata");
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("seed disk entries for the periodic checkpoint threshold");
|
||||
record_dirty_usage_bucket(BUCKET);
|
||||
let dirty_before = dirty_usage_buckets_for_tests();
|
||||
let set = store.pools[0].disk_set[0].clone();
|
||||
let disk = scanner_set_disk_inventory(&set).await.pop().expect("checkpoint owner disk");
|
||||
let cache_name = path_join_buf(&[BUCKET, DATA_USAGE_CACHE_NAME]);
|
||||
let revisions_before = DataUsageCache::read_revisions(set.clone(), &cache_name)
|
||||
.await
|
||||
@@ -109,7 +93,7 @@ async fn run_checkpoint_owner_case(lose_owner: bool) -> serde_json::Value {
|
||||
let mut first_object = EcstoreLocalPublicationPause::install(
|
||||
&disk,
|
||||
BUCKET,
|
||||
&format!("{FIRST_OBJECT}/{STORAGE_FORMAT_FILE}"),
|
||||
"object-0000/xl.meta",
|
||||
EcstoreLocalPublicationStage::MetadataReadAfterOpen,
|
||||
)
|
||||
.expect("pause the first real object read");
|
||||
|
||||
+6
-14
@@ -26,7 +26,7 @@ use tracing::{error, info};
|
||||
use transform_stream::AsyncTryStream;
|
||||
use url::{Host, Url};
|
||||
|
||||
static LOCAL_IPS: LazyLock<Vec<IpAddr>> = LazyLock::new(get_local_ips_with_fallback);
|
||||
static LOCAL_IPS: LazyLock<HashSet<IpAddr>> = LazyLock::new(|| get_local_ips_with_fallback().into_iter().collect());
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct DnsCacheEntry {
|
||||
@@ -203,15 +203,10 @@ pub fn check_local_server_addr(server_addr: &str) -> std::io::Result<SocketAddr>
|
||||
/// checks if the given parameter correspond to one of
|
||||
/// the local IP of the current machine
|
||||
pub fn is_local_host(host: Host<&str>, port: u16, local_port: u16) -> std::io::Result<bool> {
|
||||
let local_set: HashSet<IpAddr> = LOCAL_IPS.iter().copied().collect();
|
||||
let is_local_host = match host {
|
||||
Host::Domain(domain) => {
|
||||
let ips = resolve_domain(domain)?.into_iter().collect::<Vec<_>>();
|
||||
|
||||
ips.iter().any(|ip| is_local_ip(&local_set, ip))
|
||||
}
|
||||
Host::Ipv4(ip) => is_local_ip(&local_set, &IpAddr::V4(ip)),
|
||||
Host::Ipv6(ip) => is_local_ip(&local_set, &IpAddr::V6(ip)),
|
||||
Host::Domain(domain) => resolve_domain(domain)?.iter().any(is_local_ip),
|
||||
Host::Ipv4(ip) => is_local_ip(&IpAddr::V4(ip)),
|
||||
Host::Ipv6(ip) => is_local_ip(&IpAddr::V6(ip)),
|
||||
};
|
||||
|
||||
if port > 0 {
|
||||
@@ -224,11 +219,8 @@ pub fn is_local_host(host: Host<&str>, port: u16, local_port: u16) -> std::io::R
|
||||
/// Whether `ip` belongs to this host: it is either configured on a local
|
||||
/// interface or, where the platform routes the full loopback space, a loopback
|
||||
/// address.
|
||||
fn is_local_ip(local_set: &HashSet<IpAddr>, ip: &IpAddr) -> bool {
|
||||
if local_set.contains(ip) {
|
||||
return true;
|
||||
}
|
||||
is_loopback_local(ip)
|
||||
pub fn is_local_ip(ip: &IpAddr) -> bool {
|
||||
LOCAL_IPS.contains(ip) || is_loopback_local(ip)
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
//! GetObjectLegalHold: the legal hold status an object's metadata stores.
|
||||
//!
|
||||
//! Responsible for: reading the stored status, `OFF` when none is stored, on a bucket with Object
|
||||
//! Lock enabled. A stored status outside the model's set is answered as stored.
|
||||
//! Responsible for: reading the stored status on a bucket with Object Lock enabled. Missing hold
|
||||
//! metadata produces `NoSuchObjectLockConfiguration`. Other statuses are answered as stored.
|
||||
//! Also writes lock metadata to the requested version and schedules metadata replication.
|
||||
//! NOT responsible for: authorization.
|
||||
//! Upstream: both edges. Downstream: the object store and the bucket's Object Lock configuration.
|
||||
@@ -154,9 +154,10 @@ impl ObjectMetaUsecase {
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// `MethodNotAllowed` for a Veeam SOSAPI system object; `InternalError` before the store is up
|
||||
/// or when the object cannot be read; `NoSuchBucket`; the Object Lock refusal of a bucket
|
||||
/// without Object Lock.
|
||||
/// `MethodNotAllowed` for a Veeam SOSAPI system object or an explicitly selected delete marker.
|
||||
/// `NoSuchBucket`, `NoSuchKey`, or `NoSuchVersion` for a missing resource.
|
||||
/// `InvalidRequest` if Object Lock is disabled and `NoSuchObjectLockConfiguration` if no hold
|
||||
/// status is stored for the object version. Storage failures can return `InternalError`.
|
||||
pub async fn execute_get_object_legal_hold(
|
||||
&self,
|
||||
envelope: RequestEnvelope,
|
||||
@@ -180,18 +181,17 @@ impl ObjectMetaUsecase {
|
||||
)
|
||||
.suppress_event();
|
||||
let store = self.store_outside_veeam_sosapi(bucket, key).await?;
|
||||
store
|
||||
.get_bucket_info(bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
let object_info = locked_object_info(&store, &envelope, bucket, key, version_id.clone()).await?;
|
||||
|
||||
let status = object_info
|
||||
.user_defined
|
||||
.get(AMZ_OBJECT_LOCK_LEGAL_HOLD_LOWER)
|
||||
.map_or(Status::OFF, |status| Status::custom(status.clone()));
|
||||
.filter(|status| !status.is_empty())
|
||||
.ok_or_else(|| S3Error::new(S3ErrorCode::NoSuchObjectLockConfiguration))?;
|
||||
let output = GetObjectLegalHoldOutput {
|
||||
legal_hold: Some(ObjectLockLegalHold { status: Some(status) }),
|
||||
legal_hold: Some(ObjectLockLegalHold {
|
||||
status: Some(Status::custom(status.clone())),
|
||||
}),
|
||||
};
|
||||
|
||||
let version_id = version_id.unwrap_or_else(|| Uuid::new_v4().to_string());
|
||||
|
||||
@@ -32,8 +32,8 @@ use crate::app::RequestEnvelope;
|
||||
use crate::app::object::shared::reject_veeam_sosapi_mutation;
|
||||
use crate::app::runtime_sources::{AppContext, current_object_store_handle_for_context};
|
||||
use crate::app::storage_api::object_meta_usecase::contract::ObjectOperations as _;
|
||||
use crate::app::storage_api::object_meta_usecase::validate_bucket_object_lock_enabled;
|
||||
use crate::app::storage_api::object_usecase::error::is_err_version_not_found;
|
||||
use crate::app::storage_api::object_meta_usecase::validate_bucket_object_lock_enabled_for_read;
|
||||
use crate::app::storage_api::object_usecase::error::{StorageError, is_err_object_not_found, is_err_version_not_found};
|
||||
use crate::app::storage_api::object_usecase::options::get_opts;
|
||||
use crate::app::storage_api::object_usecase::{ECStore, StorageObjectInfo as ObjectInfo};
|
||||
use crate::error::ApiError;
|
||||
@@ -72,26 +72,44 @@ async fn locked_object_info(
|
||||
key: &str,
|
||||
version_id: Option<String>,
|
||||
) -> S3Result<ObjectInfo> {
|
||||
validate_bucket_object_lock_enabled(bucket).await?;
|
||||
validate_bucket_object_lock_enabled_for_read(bucket).await?;
|
||||
let explicit_version = version_id.is_some();
|
||||
let opts = get_opts(bucket, key, version_id, None, envelope.headers())
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
store.get_object_info(bucket, key, &opts).await.map_err(|error| {
|
||||
if explicit_version && is_err_version_not_found(&error) {
|
||||
return ApiError::from(error).into();
|
||||
let code = match store.get_object_info(bucket, key, &opts).await {
|
||||
Ok(info) if !info.delete_marker => return Ok(info),
|
||||
// A single pool can return the marker snapshot, while multi-pool lookup can reject it.
|
||||
Ok(_) | Err(StorageError::MethodNotAllowed) => {
|
||||
if explicit_version {
|
||||
S3ErrorCode::MethodNotAllowed
|
||||
} else {
|
||||
S3ErrorCode::NoSuchKey
|
||||
}
|
||||
}
|
||||
error!(
|
||||
component = "storage",
|
||||
subsystem = "object",
|
||||
event = "object_info_load_failed",
|
||||
bucket = %bucket,
|
||||
object = %key,
|
||||
error = %error,
|
||||
"Failed to load object info"
|
||||
);
|
||||
s3_error!(InternalError, "{}", error.to_string())
|
||||
})
|
||||
Err(error) if is_err_object_not_found(&error) || is_err_version_not_found(&error) => {
|
||||
if explicit_version {
|
||||
S3ErrorCode::NoSuchVersion
|
||||
} else {
|
||||
S3ErrorCode::NoSuchKey
|
||||
}
|
||||
}
|
||||
Err(StorageError::BucketNotFound(_) | StorageError::VolumeNotFound) => S3ErrorCode::NoSuchBucket,
|
||||
Err(error) => {
|
||||
error!(
|
||||
component = "storage",
|
||||
subsystem = "object",
|
||||
event = "object_info_load_failed",
|
||||
bucket = %bucket,
|
||||
object = %key,
|
||||
error = %error,
|
||||
"Failed to load object info"
|
||||
);
|
||||
return Err(s3_error!(InternalError, "{}", error.to_string()));
|
||||
}
|
||||
};
|
||||
let message = ApiError::error_code_to_message(&code);
|
||||
Err(S3Error::with_message(code, message))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -181,9 +181,11 @@ impl ObjectMetaUsecase {
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// `MethodNotAllowed` for a Veeam SOSAPI system object; `InternalError` before the store is up,
|
||||
/// when the object cannot be read, or for a stored date outside the answerable range; the
|
||||
/// Object Lock refusal of a bucket without Object Lock.
|
||||
/// `MethodNotAllowed` for a Veeam SOSAPI system object or an explicitly selected delete marker.
|
||||
/// `NoSuchBucket`, `NoSuchKey`, or `NoSuchVersion` for an absent resource.
|
||||
/// `InvalidRequest` if Object Lock is disabled and `NoSuchObjectLockConfiguration` if no
|
||||
/// retention is stored for the object version. Storage failures and out-of-range dates can
|
||||
/// return `InternalError`.
|
||||
pub async fn execute_get_object_retention(
|
||||
&self,
|
||||
envelope: RequestEnvelope,
|
||||
@@ -220,14 +222,22 @@ impl ObjectMetaUsecase {
|
||||
}
|
||||
}
|
||||
|
||||
/// The retention `metadata` stores. An unparseable date is answered as absent, as before.
|
||||
/// Decode stored retention, preserving a legacy mode even if its date cannot be parsed.
|
||||
fn stored_retention(metadata: &HashMap<String, String>) -> S3Result<ObjectLockRetention> {
|
||||
let mode = metadata
|
||||
.get(AMZ_OBJECT_LOCK_MODE_LOWER)
|
||||
.map(|mode| Mode::custom(mode.clone()));
|
||||
let retain_until_date = metadata
|
||||
let mode = metadata.get(AMZ_OBJECT_LOCK_MODE_LOWER).filter(|mode| !mode.is_empty());
|
||||
let retain_until = metadata
|
||||
.get(AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE_LOWER)
|
||||
.and_then(|value| OffsetDateTime::parse(value, &Rfc3339).ok())
|
||||
.filter(|date| !date.is_empty());
|
||||
// PutObjectRetention clears both fields by storing empty strings.
|
||||
if mode.is_none() && retain_until.is_none() {
|
||||
return Err(S3Error::new(S3ErrorCode::NoSuchObjectLockConfiguration));
|
||||
}
|
||||
let parsed_date = match retain_until.map(|value| OffsetDateTime::parse(value, &Rfc3339)).transpose() {
|
||||
Ok(date) => date,
|
||||
Err(_) if mode.is_some() => None,
|
||||
Err(_) => return Err(S3Error::with_message(S3ErrorCode::InternalError, "Stored retention date is invalid")),
|
||||
};
|
||||
let retain_until_date = parsed_date
|
||||
.map(|date| {
|
||||
date.checked_to_offset(time::UtcOffset::UTC)
|
||||
.filter(|date| (0..=9999).contains(&date.year()))
|
||||
@@ -241,7 +251,7 @@ fn stored_retention(metadata: &HashMap<String, String>) -> S3Result<ObjectLockRe
|
||||
})
|
||||
.transpose()?;
|
||||
Ok(ObjectLockRetention {
|
||||
mode,
|
||||
mode: mode.map(|mode| Mode::custom(mode.clone())),
|
||||
retain_until_date,
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -1728,7 +1728,8 @@ pub(crate) mod object_meta_usecase {
|
||||
pub(crate) use crate::storage::storage_api::check_retention_for_modification;
|
||||
|
||||
pub(crate) use crate::storage::storage_api::ecfs_consumer::object_lock::{
|
||||
load_bucket_object_lock_config_state, validate_bucket_object_lock_enabled, validate_bucket_object_lock_enabled_state,
|
||||
load_bucket_object_lock_config_state, validate_bucket_object_lock_enabled, validate_bucket_object_lock_enabled_for_read,
|
||||
validate_bucket_object_lock_enabled_state,
|
||||
};
|
||||
pub(crate) use crate::storage::storage_api::ecstore_bucket::metadata::validate_tag_set_entries;
|
||||
pub(crate) use crate::storage::storage_api::ecstore_bucket::tagging::{
|
||||
|
||||
@@ -25,7 +25,9 @@ use crate::{
|
||||
startup_preflight::{StartupServerPreflightError, bootstrap_external_prefix_compat, init_startup_server_preflight},
|
||||
startup_server::{StartupHttpServers, StartupListenContext, init_startup_http_servers, init_startup_listen_context},
|
||||
startup_services::init_startup_runtime_services,
|
||||
startup_storage::{StartupStorageRuntime, init_startup_storage_foundation, init_startup_storage_runtime},
|
||||
startup_storage::{
|
||||
StartupEndpointDiscoveryTimeout, StartupStorageRuntime, init_startup_storage_foundation, init_startup_storage_runtime,
|
||||
},
|
||||
storage_api::server::http::ServerContextSlot,
|
||||
storage_api::startup::storage::bootstrap_instance_ctx,
|
||||
};
|
||||
@@ -129,12 +131,27 @@ fn run_process_on_current_thread(#[cfg(feature = "internode-transport")] build:
|
||||
} else {
|
||||
ExitCode::SUCCESS
|
||||
};
|
||||
drop(result);
|
||||
// block_on has left its entered scope; the startup thread owns teardown.
|
||||
drop(runtime);
|
||||
shutdown_process_runtime(runtime, result);
|
||||
exit_code
|
||||
}
|
||||
|
||||
fn shutdown_process_runtime(runtime: tokio::runtime::Runtime, result: Result<()>) {
|
||||
let endpoint_discovery_timed_out = result
|
||||
.as_ref()
|
||||
.err()
|
||||
.and_then(Error::get_ref)
|
||||
.is_some_and(|source| source.is::<StartupEndpointDiscoveryTimeout>());
|
||||
drop(result);
|
||||
|
||||
// The topology timed out before publishing disks or opening listeners. A
|
||||
// system DNS call may still be running on the blocking pool after cancellation.
|
||||
if endpoint_discovery_timed_out {
|
||||
runtime.shutdown_background();
|
||||
} else {
|
||||
drop(runtime);
|
||||
}
|
||||
}
|
||||
|
||||
fn format_fatal_stderr_message(context: &str, error: impl std::fmt::Display) -> String {
|
||||
format!("[FATAL] {context}: {error}")
|
||||
}
|
||||
@@ -2186,6 +2203,38 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn endpoint_discovery_timeout_does_not_wait_for_a_blocking_resolver() {
|
||||
std::thread::scope(|scope| {
|
||||
let (started, wait_for_start) = std::sync::mpsc::channel();
|
||||
let (release, wait_for_release) = std::sync::mpsc::channel::<()>();
|
||||
let (stopped, wait_for_stop) = std::sync::mpsc::channel();
|
||||
let (completed, wait_for_completion) = std::sync::mpsc::channel();
|
||||
scope.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("create owned startup runtime");
|
||||
runtime.spawn_blocking(move || {
|
||||
started.send(()).expect("report resolver start");
|
||||
let _ = wait_for_release.recv();
|
||||
completed.send(()).expect("report resolver completion");
|
||||
});
|
||||
wait_for_start.recv_timeout(Duration::from_secs(5)).expect("resolver started");
|
||||
let err = Error::new(std::io::ErrorKind::TimedOut, "startup DNS deadline elapsed");
|
||||
shutdown_process_runtime(runtime, Err(Error::other(StartupEndpointDiscoveryTimeout(err))));
|
||||
let _ = stopped.send(());
|
||||
});
|
||||
|
||||
let before_release = wait_for_stop.recv_timeout(Duration::from_secs(5));
|
||||
drop(release);
|
||||
wait_for_completion
|
||||
.recv_timeout(Duration::from_secs(5))
|
||||
.expect("resolver completed");
|
||||
before_release.expect("startup shutdown must return while the resolver is still blocked");
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_thread_propagates_panics() {
|
||||
let result = std::panic::catch_unwind(|| run_on_startup_thread(|| panic!("startup thread panic")));
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::storage_api::startup::storage::{
|
||||
};
|
||||
use rustfs_common::{GlobalReadiness, SystemStage};
|
||||
use std::{
|
||||
io::{Error, Result},
|
||||
io::{Error, ErrorKind, Result},
|
||||
net::SocketAddr,
|
||||
sync::Arc,
|
||||
};
|
||||
@@ -44,6 +44,10 @@ pub(crate) struct StartupStorageRuntime {
|
||||
pub(crate) shutdown_token: CancellationToken,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error(transparent)]
|
||||
pub(crate) struct StartupEndpointDiscoveryTimeout(pub(crate) Error);
|
||||
|
||||
pub(crate) async fn init_startup_storage_foundation(
|
||||
server_address: &str,
|
||||
volumes: &[String],
|
||||
@@ -72,7 +76,13 @@ pub(crate) async fn init_startup_storage_foundation(
|
||||
"Endpoint parsing failed"
|
||||
);
|
||||
})
|
||||
.map_err(Error::other)?;
|
||||
.map_err(|err| {
|
||||
if err.kind() == ErrorKind::TimedOut {
|
||||
Error::new(ErrorKind::TimedOut, StartupEndpointDiscoveryTimeout(err))
|
||||
} else {
|
||||
Error::other(err)
|
||||
}
|
||||
})?;
|
||||
ECStore::validate_startup_storage_class(&endpoint_pools)
|
||||
.inspect_err(|err| {
|
||||
error!(
|
||||
|
||||
@@ -546,6 +546,16 @@ pub(crate) async fn validate_bucket_object_lock_enabled(bucket: &str) -> S3Resul
|
||||
validate_bucket_object_lock_enabled_state(bucket, &state)
|
||||
}
|
||||
|
||||
pub(crate) async fn validate_bucket_object_lock_enabled_for_read(bucket: &str) -> S3Result<()> {
|
||||
// Metadata authority already distinguishes a missing bucket from a missing
|
||||
// lock configuration. Warm reads need no separate namespace quorum probe.
|
||||
let Some(result) = metadata_sys::find_object_lock_config_state(bucket).await.transpose() else {
|
||||
return Err(ApiError::from(StorageError::BucketNotFound(bucket.to_owned())).into());
|
||||
};
|
||||
let state = map_bucket_object_lock_config_state(bucket, result)?;
|
||||
validate_bucket_object_lock_enabled_state(bucket, &state)
|
||||
}
|
||||
|
||||
pub(crate) fn validate_bucket_object_lock_enabled_state(bucket: &str, state: &ObjectLockConfigState) -> S3Result<()> {
|
||||
match state {
|
||||
ObjectLockConfigState::Configured { config, .. } if config.object_lock_enabled.as_deref() == Some("Enabled") => Ok(()),
|
||||
|
||||
@@ -245,7 +245,8 @@ pub(crate) mod ecfs_consumer {
|
||||
|
||||
pub(crate) mod object_lock {
|
||||
pub(crate) use super::super::super::{
|
||||
load_bucket_object_lock_config_state, validate_bucket_object_lock_enabled, validate_bucket_object_lock_enabled_state,
|
||||
load_bucket_object_lock_config_state, validate_bucket_object_lock_enabled,
|
||||
validate_bucket_object_lock_enabled_for_read, validate_bucket_object_lock_enabled_state,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -356,6 +356,7 @@ async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_ad
|
||||
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;
|
||||
object_meta::seed_object_lock_matrix().await;
|
||||
create_bucket_in_the_store(object_misc::MATRIX_BUCKET).await;
|
||||
object_misc::seed_restore_object(object_misc::MATRIX_BUCKET, false).await;
|
||||
object_misc::seed_select_matrix().await;
|
||||
|
||||
@@ -34,6 +34,7 @@ use std::collections::HashMap;
|
||||
/// The object every call names.
|
||||
const KEY: &str = "object-meta";
|
||||
pub(super) const MATRIX_BUCKET: &str = "object-meta-matrix";
|
||||
const LOCKED_KEY: &str = "object-meta-protected";
|
||||
|
||||
pub(crate) const MATRIX: &[MatrixRow] = &[
|
||||
MatrixRow {
|
||||
@@ -114,18 +115,16 @@ fn put_object_acl<'a>(client: &'a Client, _bucket: &'a str) -> BoxFuture<'a, Out
|
||||
}
|
||||
|
||||
fn get_object_legal_hold<'a>(client: &'a Client, _bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
let bucket = MATRIX_BUCKET;
|
||||
Box::pin(async move {
|
||||
let bucket = locked_bucket(bucket).await;
|
||||
outcome(client.get_object_legal_hold().bucket(&bucket).key(KEY).send().await)
|
||||
let bucket = format!("{MATRIX_BUCKET}-locked");
|
||||
outcome(client.get_object_legal_hold().bucket(bucket).key(LOCKED_KEY).send().await)
|
||||
})
|
||||
}
|
||||
|
||||
fn get_object_retention<'a>(client: &'a Client, _bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
let bucket = MATRIX_BUCKET;
|
||||
Box::pin(async move {
|
||||
let bucket = locked_bucket(bucket).await;
|
||||
outcome(client.get_object_retention().bucket(&bucket).key(KEY).send().await)
|
||||
let bucket = format!("{MATRIX_BUCKET}-locked");
|
||||
outcome(client.get_object_retention().bucket(bucket).key(LOCKED_KEY).send().await)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -190,16 +189,30 @@ async fn locked_bucket(bucket: &str) -> String {
|
||||
versioning_enabled: true,
|
||||
..Default::default()
|
||||
};
|
||||
// A second call finds the bucket made by the first.
|
||||
let _ = get_global_app_context()
|
||||
get_global_app_context()
|
||||
.expect("embedded server context")
|
||||
.object_store()
|
||||
.make_bucket(&locked, &options)
|
||||
.await;
|
||||
.await
|
||||
.expect("create Object Lock bucket");
|
||||
put_object_in_the_store(&locked, KEY, HashMap::new()).await;
|
||||
locked
|
||||
}
|
||||
|
||||
pub(super) async fn seed_object_lock_matrix() {
|
||||
let bucket = locked_bucket(MATRIX_BUCKET).await;
|
||||
put_object_in_the_store(
|
||||
&bucket,
|
||||
LOCKED_KEY,
|
||||
HashMap::from([
|
||||
("x-amz-object-lock-legal-hold".to_owned(), "OFF".to_owned()),
|
||||
("x-amz-object-lock-mode".to_owned(), "GOVERNANCE".to_owned()),
|
||||
("x-amz-object-lock-retain-until-date".to_owned(), "2035-01-02T00:00:00Z".to_owned()),
|
||||
]),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Writes `key` with `metadata` as stored user metadata.
|
||||
async fn put_object_in_the_store(bucket: &str, key: &str, metadata: HashMap<String, String>) {
|
||||
let options = ObjectOptions {
|
||||
@@ -252,45 +265,99 @@ async fn object_metadata_answers_as_stored(server: rustfs::embedded::RustFSServe
|
||||
.expect_err("XML grants are refused");
|
||||
assert_eq!(refusal(&refused), (Some("NotImplemented".to_owned()), Some(501)));
|
||||
|
||||
let unlocked = client
|
||||
.get_object_legal_hold()
|
||||
.bucket(BUCKET)
|
||||
.key(KEY)
|
||||
.send()
|
||||
.await
|
||||
.expect_err("no Object Lock");
|
||||
assert_eq!(refusal(&unlocked), (Some("InvalidRequest".to_owned()), Some(400)));
|
||||
let unlocked = client
|
||||
.get_object_retention()
|
||||
.bucket(BUCKET)
|
||||
.key(KEY)
|
||||
.send()
|
||||
.await
|
||||
.expect_err("no Object Lock");
|
||||
assert_eq!(refusal(&unlocked), (Some("InvalidRequest".to_owned()), Some(400)));
|
||||
for (bucket, code, status) in [(BUCKET, "InvalidRequest", 400), ("object-meta-absent", "NoSuchBucket", 404)] {
|
||||
let retention = client.get_object_retention().bucket(bucket).key(KEY).send().await;
|
||||
let hold = client.get_object_legal_hold().bucket(bucket).key(KEY).send().await;
|
||||
let expected = (Some(code.to_owned()), Some(status));
|
||||
assert_eq!(refusal(&retention.expect_err("lock query refused")), expected, "retention for {bucket}");
|
||||
assert_eq!(refusal(&hold.expect_err("lock query refused")), expected, "legal hold for {bucket}");
|
||||
}
|
||||
|
||||
let locked = locked_bucket(BUCKET).await;
|
||||
let missing = client
|
||||
put_object_in_the_store(
|
||||
&locked,
|
||||
"cleared",
|
||||
HashMap::from([
|
||||
("x-amz-object-lock-mode".to_owned(), String::new()),
|
||||
("x-amz-object-lock-retain-until-date".to_owned(), String::new()),
|
||||
]),
|
||||
)
|
||||
.await;
|
||||
for (key, code, status) in [
|
||||
("missing", "NoSuchKey", 404),
|
||||
(KEY, "NoSuchObjectLockConfiguration", 404),
|
||||
("cleared", "NoSuchObjectLockConfiguration", 404),
|
||||
] {
|
||||
let retention = client.get_object_retention().bucket(&locked).key(key).send().await;
|
||||
let hold = client.get_object_legal_hold().bucket(&locked).key(key).send().await;
|
||||
let expected = (Some(code.to_owned()), Some(status));
|
||||
assert_eq!(refusal(&retention.expect_err("no retention")), expected, "retention for {key}");
|
||||
assert_eq!(refusal(&hold.expect_err("no legal hold")), expected, "legal hold for {key}");
|
||||
}
|
||||
|
||||
put_object_in_the_store(
|
||||
&locked,
|
||||
"explicit-off",
|
||||
HashMap::from([("x-amz-object-lock-legal-hold".to_owned(), "OFF".to_owned())]),
|
||||
)
|
||||
.await;
|
||||
put_object_in_the_store(
|
||||
&locked,
|
||||
"unreadable-retention",
|
||||
HashMap::from([("x-amz-object-lock-retain-until-date".to_owned(), "invalid date".to_owned())]),
|
||||
)
|
||||
.await;
|
||||
let unreadable = client
|
||||
.get_object_retention()
|
||||
.bucket(&locked)
|
||||
.key("missing")
|
||||
.key("unreadable-retention")
|
||||
.send()
|
||||
.await
|
||||
.expect_err("a missing key");
|
||||
assert_eq!(refusal(&missing), (Some("InternalError".to_owned()), Some(500)));
|
||||
.expect_err("an unreadable date alone cannot produce a retention response");
|
||||
assert_eq!(refusal(&unreadable), (Some("InternalError".to_owned()), Some(500)));
|
||||
|
||||
let hold = client
|
||||
.get_object_legal_hold()
|
||||
.bucket(&locked)
|
||||
.key(KEY)
|
||||
.key("explicit-off")
|
||||
.send()
|
||||
.await
|
||||
.expect("the default hold");
|
||||
.expect("an explicit OFF hold");
|
||||
assert_eq!(
|
||||
hold.legal_hold().and_then(|hold| hold.status()).map(|status| status.as_str()),
|
||||
Some("OFF")
|
||||
);
|
||||
|
||||
let deleted = client
|
||||
.delete_object()
|
||||
.bucket(&locked)
|
||||
.key(KEY)
|
||||
.send()
|
||||
.await
|
||||
.expect("create a delete marker");
|
||||
let marker = deleted.version_id().expect("delete marker version");
|
||||
for (version_id, code, status) in [(None, "NoSuchKey", 404), (Some(marker.to_owned()), "MethodNotAllowed", 405)] {
|
||||
let retention = client
|
||||
.get_object_retention()
|
||||
.bucket(&locked)
|
||||
.key(KEY)
|
||||
.set_version_id(version_id.clone())
|
||||
.send()
|
||||
.await
|
||||
.expect_err("a marker has no retention");
|
||||
let hold = client
|
||||
.get_object_legal_hold()
|
||||
.bucket(&locked)
|
||||
.key(KEY)
|
||||
.set_version_id(version_id)
|
||||
.send()
|
||||
.await
|
||||
.expect_err("a marker has no legal hold");
|
||||
let expected = (Some(code.to_owned()), Some(status));
|
||||
assert_eq!(refusal(&retention), expected);
|
||||
assert_eq!(refusal(&hold), expected);
|
||||
}
|
||||
|
||||
// Values outside the model's sets, as a replicated or migrated object may hold them.
|
||||
let stored = HashMap::from([
|
||||
("x-amz-object-lock-legal-hold".to_owned(), "on".to_owned()),
|
||||
@@ -328,6 +395,7 @@ async fn object_metadata_answers_as_stored(server: rustfs::embedded::RustFSServe
|
||||
.await
|
||||
.expect_err("retention for a missing version");
|
||||
assert_eq!(refusal(&missing_retention), (Some("NoSuchVersion".to_owned()), Some(404)));
|
||||
assert_eq!(missing_retention.message(), Some("The specified version does not exist."));
|
||||
|
||||
let missing_hold = client
|
||||
.get_object_legal_hold()
|
||||
@@ -338,6 +406,7 @@ async fn object_metadata_answers_as_stored(server: rustfs::embedded::RustFSServe
|
||||
.await
|
||||
.expect_err("legal hold for a missing version");
|
||||
assert_eq!(refusal(&missing_hold), (Some("NoSuchVersion".to_owned()), Some(404)));
|
||||
assert_eq!(missing_hold.message(), Some("The specified version does not exist."));
|
||||
|
||||
let missing = client
|
||||
.get_object_tagging()
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
25|crates/ecstore/src/erasure/coding/erasure.rs
|
||||
3|crates/ecstore/src/layout/disks_layout.rs
|
||||
2|crates/ecstore/src/layout/endpoint.rs
|
||||
17|crates/ecstore/src/layout/endpoints.rs
|
||||
14|crates/ecstore/src/layout/endpoints.rs
|
||||
1|crates/ecstore/src/layout/format.rs
|
||||
1|crates/ecstore/src/layout/pool_space.rs
|
||||
1|crates/ecstore/src/layout/set_layout.rs
|
||||
|
||||
Reference in New Issue
Block a user