mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 16:37:07 +00:00
2ebf8bc138
* refactor(ecstore): drop the client shim, import rustfs-s3-client directly Completes the migration window opened by the rustfs-s3-client extraction (rustfs/backlog#1842 PR3): every consumer now imports the client crate directly and the crate::client shim is deleted. - All in-crate crate::client:: paths (tier warm backends, tier core, lifecycle tier_sweeper, replication storage boundary, set_disk) now import rustfs_s3_client::* directly; crates/ecstore/src/client/mod.rs and the lib.rs mod client declaration are gone. - The two server-side modules historically misfiled under client/ move to their real homes: object_api_utils.rs to crates/ecstore/src/object_api/ (it builds engine-side object readers/writers), and object_handlers_common.rs to crates/ecstore/src/bucket/lifecycle/ (it is the lifecycle noncurrent-version cleanup helper). The latter now routes its replication calls through the lifecycle replication_sink boundary (schedule_delete wrapper and the sink's ReplicationObjectBridge re-export), as the lifecycle guard requires. - The ecstore public facade drops api::client: object_api_utils is exposed as api::object_api_utils, and the rustfs crate takes admin_handler_utils (AdminError) from rustfs-s3-client directly (new dependency). - Guard updates: the migration guard no longer pins mod client in ecstore's lib.rs or the admin_handler_utils facade module (it pins the new api::object_api_utils facade instead), and the module-lint register follows object_api_utils.rs to its new path. Verification: cargo check -p rustfs-ecstore --all-targets and -p rustfs; cargo fmt --all; tier/transition/lifecycle-focused nextest (626 passed) and the decommission/rebalance/heal families in a filtered run (603 passed; the full-suite parallel run only fails on this machine's known decommission/rebalance baseline flakes, which pass in filtered reruns and fail identically on pristine origin/main); layer/migration/s3s/logging/error-format/doc-path guard scripts all pass. * docs(architecture): record the S3 client extraction and reword invariant 4 (#6669) Closes the documentation step of rustfs/backlog#1842. ARCHITECTURE.md invariant 4 now states the serving-vs-consuming distinction the adversarial ruling asked for: ecstore must not serve HTTP/S3 wire types, while consuming remote S3 endpoints is a legitimate engine capability that lives in the extracted rustfs-s3-client crate. The violation note is updated from the pre-extraction snapshot (58 files, embedded client) to the current ratcheted state (shrink-only S3S_ECSTORE_FILES_BASELINE in scripts/check_s3s_footprint.sh, object_lock converted first), and the crate map gains s3-client. ecstore-module-split-plan.md gets the client-directory entry the plan was missing: a Current Shape row and a completed-extraction section describing the pure-move + shim + direct-import sequence and the re-homing of the two misfiled server-side modules.
123 lines
5.6 KiB
Rust
123 lines
5.6 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// #730: object API readers keep staged compatibility paths during facade migration.
|
|
|
|
pub mod object_api_utils;
|
|
|
|
use crate::bucket::metadata_sys::get_versioning_config;
|
|
use crate::bucket::replication::{
|
|
DeleteReplicationConfigSnapshot, ReplicateDecision, ReplicationState, ReplicationStatusType, VersionPurgeStatusType,
|
|
replication_status_from_filemeta, replication_statuses_map, version_purge_status_from_filemeta, version_purge_statuses_map,
|
|
};
|
|
use crate::bucket::versioning::VersioningApi as _;
|
|
use crate::config::storageclass;
|
|
use crate::error::{Error, Result};
|
|
use crate::io_support::rio::{HardLimitReader, HashReader};
|
|
use crate::storage_api_contracts::{
|
|
lifecycle::{ExpirationOptions, TransitionedObject},
|
|
range::HTTPRangeSpec,
|
|
};
|
|
use crate::store::utils::clean_metadata;
|
|
use crate::{bucket::lifecycle::bucket_lifecycle_audit::LcAuditEvent, bucket::lifecycle::lifecycle::TransitionOptions};
|
|
use bytes::Bytes;
|
|
use http::{HeaderMap, HeaderValue};
|
|
use rustfs_filemeta::{FileInfo, MetaCacheEntriesSorted, ObjectPartInfo, RestoreStatusOps as _, parse_restore_obj_status};
|
|
use rustfs_rio::Checksum;
|
|
use rustfs_utils::CompressionAlgorithm;
|
|
use rustfs_utils::http::headers::AMZ_OBJECT_TAGGING;
|
|
use rustfs_utils::http::{AMZ_BUCKET_REPLICATION_STATUS, AMZ_RESTORE, AMZ_STORAGE_CLASS};
|
|
use rustfs_utils::path::decode_dir_object;
|
|
use std::collections::HashMap;
|
|
use std::fmt::Debug;
|
|
use std::io::Cursor;
|
|
use std::pin::Pin;
|
|
use std::sync::Arc;
|
|
use std::task::{Context, Poll};
|
|
use time::OffsetDateTime;
|
|
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
|
|
use tracing::warn;
|
|
use uuid::Uuid;
|
|
|
|
pub const ERASURE_ALGORITHM: &str = "rs-vandermonde";
|
|
pub const BLOCK_SIZE_V2: usize = 1024 * 1024; // 1M
|
|
pub(crate) const ENCRYPTED_PART_LAYOUT_CANDIDATE_SUFFIX: &str = "encrypted-part-layout-quorum-candidate-v1";
|
|
pub(crate) const ENCRYPTED_PART_LAYOUT_QUORUM_SUFFIX: &str = "encrypted-part-layout-quorum-v1";
|
|
/// Marker naming the fixed-8-KiB v2 frame layout of a single-part encrypted
|
|
/// object. The value is the object's `data_dir` token, exactly like the part
|
|
/// layout markers above: any path that re-homes this metadata onto other
|
|
/// ciphertext or a new object identity (copy, replication re-encryption, data
|
|
/// movement) mints a new `data_dir`, invalidating the marker so the read falls
|
|
/// back to the conservative full path instead of trusting a stale layout.
|
|
pub(crate) const ENCRYPTED_FRAME_LAYOUT_FIXED8K_SUFFIX: &str = "encrypted-frame-layout-fixed8k-v1";
|
|
pub(crate) const ENV_RUSTFS_ENCRYPTED_RANGE_SEEK: &str = "RUSTFS_ENCRYPTED_RANGE_SEEK";
|
|
pub(crate) const DEFAULT_RUSTFS_ENCRYPTED_RANGE_SEEK: bool = true;
|
|
|
|
pub(crate) fn has_encrypted_part_layout_marker(metadata: &HashMap<String, String>, suffix: &str, expected: &str) -> bool {
|
|
let mut value = None;
|
|
for (key, candidate) in metadata {
|
|
if !rustfs_utils::http::has_internal_suffix(key, suffix) {
|
|
continue;
|
|
}
|
|
if candidate.is_empty() || value.is_some_and(|current| current != candidate) {
|
|
return false;
|
|
}
|
|
value = Some(candidate);
|
|
}
|
|
value.is_some_and(|value| value == expected)
|
|
}
|
|
|
|
pub(crate) fn legacy_encrypted_range_seek_enabled() -> bool {
|
|
// RUSTFS_COMPAT_TODO(backlog-1316): keep the rolling-upgrade kill switch. Remove after the minimum supported release uses the marker protocol.
|
|
// On by default (backlog-1316 Phase A): every misfit direction falls back to the
|
|
// conservative full read — MPUs created without a candidate marker, completions
|
|
// that cannot revalidate the candidate against the data_dir under the uploadId
|
|
// lock, and reads whose quorum marker disagrees with the current data_dir all
|
|
// serve the full-object path. RUSTFS_ENCRYPTED_RANGE_SEEK=false is the kill switch.
|
|
#[cfg(test)]
|
|
{
|
|
rustfs_utils::get_env_bool(ENV_RUSTFS_ENCRYPTED_RANGE_SEEK, DEFAULT_RUSTFS_ENCRYPTED_RANGE_SEEK)
|
|
}
|
|
#[cfg(not(test))]
|
|
{
|
|
static CACHED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
|
*CACHED.get_or_init(|| rustfs_utils::get_env_bool(ENV_RUSTFS_ENCRYPTED_RANGE_SEEK, DEFAULT_RUSTFS_ENCRYPTED_RANGE_SEEK))
|
|
}
|
|
}
|
|
|
|
mod body_cache_hook;
|
|
mod encryption;
|
|
mod hook_slot;
|
|
mod object_mutation_hook;
|
|
mod readers;
|
|
mod types;
|
|
|
|
#[cfg(test)]
|
|
pub(crate) use body_cache_hook::clear_get_object_body_cache_hook;
|
|
pub use body_cache_hook::{
|
|
GetObjectBodyCacheHook, GetObjectBodyCacheHookLookup, get_object_body_cache_plaintext_len, lookup_get_object_body_cache_hook,
|
|
register_get_object_body_cache_hook, unregister_get_object_body_cache_hook,
|
|
};
|
|
pub(crate) use body_cache_hook::{
|
|
get_object_body_cache_hook, get_object_body_cache_hook_suppressed, without_get_object_body_cache_hook,
|
|
};
|
|
pub use encryption::{
|
|
EncryptionResolutionError, EncryptionResolutionErrorKind, ObjectEncryptionResolver, ReadEncryptionMaterial,
|
|
ReadEncryptionMode, ReadEncryptionRequest,
|
|
};
|
|
pub(crate) use object_mutation_hook::notify_object_mutation;
|
|
pub use object_mutation_hook::{ObjectMutationHook, register_object_mutation_hook, unregister_object_mutation_hook};
|
|
pub use readers::*;
|
|
pub use types::*;
|