mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 22:33:22 +00:00
refactor: segment admin storage contracts by domain (#3914)
This commit is contained in:
@@ -16,7 +16,8 @@ use crate::admin::auth::authenticate_request;
|
||||
use crate::admin::router::{AdminOperation, Operation, S3Router};
|
||||
use crate::admin::runtime_sources::{resolve_action_credentials, resolve_object_store_handle};
|
||||
use crate::admin::storage_api::bucket::versioning_sys::BucketVersioningSys;
|
||||
use crate::admin::storage_api::contract::{BucketOperations, BucketOptions, StorageAdminApi};
|
||||
use crate::admin::storage_api::contract::admin::StorageAdminApi;
|
||||
use crate::admin::storage_api::contract::bucket::{BucketOperations, BucketOptions};
|
||||
use crate::auth::get_condition_values;
|
||||
use crate::server::{ADMIN_PREFIX, RemoteAddr};
|
||||
use http::{HeaderMap, HeaderValue};
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::admin::storage_api::bucket::{
|
||||
quota::BucketQuota,
|
||||
target::BucketTargets,
|
||||
};
|
||||
use crate::admin::storage_api::contract::{BucketOperations, BucketOptions, MakeBucketOptions};
|
||||
use crate::admin::storage_api::contract::bucket::{BucketOperations, BucketOptions, MakeBucketOptions};
|
||||
use crate::admin::storage_api::error::StorageError;
|
||||
use crate::{
|
||||
admin::runtime_sources::resolve_object_store_handle,
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::admin::storage_api::config::{
|
||||
RUSTFS_META_BUCKET, STORAGE_CLASS_SUB_SYS, delete_admin_config, read_admin_config, read_admin_config_without_migrate,
|
||||
save_admin_config, save_admin_server_config,
|
||||
};
|
||||
use crate::admin::storage_api::contract::ListOperations as _;
|
||||
use crate::admin::storage_api::contract::list::ListOperations as _;
|
||||
use crate::admin::utils::{encode_compatible_admin_payload, is_compat_admin_request, read_compatible_admin_body};
|
||||
use crate::auth::{check_key_valid, get_session_token};
|
||||
use crate::error::ApiError;
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::admin::runtime_sources::resolve_object_store_handle;
|
||||
use crate::admin::storage_api::access::spawn_traced;
|
||||
use crate::admin::storage_api::bucket::is_reserved_or_invalid_bucket;
|
||||
use crate::admin::storage_api::bucket::utils::is_valid_object_prefix;
|
||||
use crate::admin::storage_api::contract::HealOperations as _;
|
||||
use crate::admin::storage_api::contract::heal::HealOperations as _;
|
||||
use crate::server::ADMIN_PREFIX;
|
||||
use crate::server::RemoteAddr;
|
||||
use bytes::Bytes;
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
use crate::admin::router::{ADMIN_OBJECT_ZIP_DOWNLOADS_PATH, AdminOperation, Operation, S3Router};
|
||||
use crate::admin::runtime_sources::{resolve_action_credentials, resolve_object_store_handle, resolve_region};
|
||||
use crate::admin::storage_api::access::{ReqInfo, authorize_request};
|
||||
use crate::admin::storage_api::contract::{
|
||||
BucketOperations, BucketOptions, ListOperations as _, ObjectIO as _, ObjectOperations as _,
|
||||
};
|
||||
use crate::admin::storage_api::contract::bucket::{BucketOperations, BucketOptions};
|
||||
use crate::admin::storage_api::contract::list::ListOperations as _;
|
||||
use crate::admin::storage_api::contract::object::{ObjectIO as _, ObjectOperations as _};
|
||||
use crate::admin::storage_api::object::StorageObjectOptions as ObjectOptions;
|
||||
use crate::auth::{check_key_valid, get_session_token};
|
||||
use crate::error::ApiError;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::admin::storage_api::contract::{BucketOperations, BucketOptions, StorageAdminApi};
|
||||
use crate::admin::storage_api::contract::admin::StorageAdminApi;
|
||||
use crate::admin::storage_api::contract::bucket::{BucketOperations, BucketOptions};
|
||||
use crate::admin::storage_api::error::StorageError;
|
||||
use crate::admin::storage_api::rebalance::{
|
||||
DiskStat, RebalSaveOpt, RebalanceCleanupWarnings, RebalanceMeta, RebalanceStopPropagationRecord,
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::admin::storage_api::bucket::metadata_sys::get_replication_config;
|
||||
use crate::admin::storage_api::bucket::replication::BucketStats;
|
||||
use crate::admin::storage_api::bucket::target::BucketTarget;
|
||||
use crate::admin::storage_api::bucket::target_sys::{BucketTargetError, BucketTargetSys};
|
||||
use crate::admin::storage_api::contract::{BucketOperations, BucketOptions};
|
||||
use crate::admin::storage_api::contract::bucket::{BucketOperations, BucketOptions};
|
||||
use crate::admin::storage_api::error::StorageError;
|
||||
use crate::admin::utils::read_compatible_admin_body;
|
||||
use crate::auth::{check_key_valid, get_session_token};
|
||||
|
||||
@@ -34,7 +34,7 @@ use crate::admin::storage_api::bucket::target_sys::BucketTargetSys;
|
||||
use crate::admin::storage_api::bucket::utils::{deserialize, serialize};
|
||||
use crate::admin::storage_api::bucket::{AdminReplicationConfigExt as _, AdminVersioningConfigExt as _};
|
||||
use crate::admin::storage_api::config::{delete_admin_config, read_admin_config, save_admin_config};
|
||||
use crate::admin::storage_api::contract::{
|
||||
use crate::admin::storage_api::contract::bucket::{
|
||||
BucketOperations, BucketOptions, DeleteBucketOptions, MakeBucketOptions, SRBucketDeleteOp,
|
||||
};
|
||||
use crate::admin::storage_api::error::Error as StorageError;
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::admin::runtime_sources::{
|
||||
resolve_server_config,
|
||||
};
|
||||
use crate::admin::storage_api::access::{ReqInfo, authorize_request, spawn_traced};
|
||||
use crate::admin::storage_api::contract::{BucketOperations, BucketOptions};
|
||||
use crate::admin::storage_api::contract::bucket::{BucketOperations, BucketOptions};
|
||||
use crate::auth::{check_key_valid, get_session_token};
|
||||
use crate::error::ApiError;
|
||||
use crate::license::license_check;
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::admin::runtime_sources::{
|
||||
resolve_object_store_handle, resolve_object_store_handle_for_context,
|
||||
};
|
||||
use crate::admin::storage_api::config::{STORAGE_CLASS_SUB_SYS, read_admin_config_without_migrate, storageclass};
|
||||
use crate::admin::storage_api::contract::StorageAdminApi;
|
||||
use crate::admin::storage_api::contract::admin::StorageAdminApi;
|
||||
use crate::admin::storage_api::runtime::ECStore;
|
||||
use rustfs_audit::reload_audit_config;
|
||||
use rustfs_config::audit::{AUDIT_MQTT_SUB_SYS, AUDIT_REDIS_DEFAULT_CHANNEL, AUDIT_WEBHOOK_SUB_SYS};
|
||||
|
||||
@@ -469,10 +469,27 @@ pub(crate) mod config {
|
||||
}
|
||||
|
||||
pub(crate) mod contract {
|
||||
pub(crate) use super::storage_contracts::{
|
||||
BucketOperations, BucketOptions, DeleteBucketOptions, HealOperations, ListOperations, MakeBucketOptions, ObjectIO,
|
||||
ObjectOperations, SRBucketDeleteOp, StorageAdminApi,
|
||||
};
|
||||
pub(crate) mod admin {
|
||||
pub(crate) use super::super::storage_contracts::StorageAdminApi;
|
||||
}
|
||||
|
||||
pub(crate) mod bucket {
|
||||
pub(crate) use super::super::storage_contracts::{
|
||||
BucketOperations, BucketOptions, DeleteBucketOptions, MakeBucketOptions, SRBucketDeleteOp,
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) mod heal {
|
||||
pub(crate) use super::super::storage_contracts::HealOperations;
|
||||
}
|
||||
|
||||
pub(crate) mod list {
|
||||
pub(crate) use super::super::storage_contracts::ListOperations;
|
||||
}
|
||||
|
||||
pub(crate) mod object {
|
||||
pub(crate) use super::super::storage_contracts::{ObjectIO, ObjectOperations};
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod error {
|
||||
|
||||
@@ -409,6 +409,8 @@ pin_project! {
|
||||
#[pin]
|
||||
inner: ReaderStream<R>,
|
||||
remaining: usize,
|
||||
emitted: usize,
|
||||
expected: usize,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,6 +432,8 @@ where
|
||||
Self {
|
||||
inner: ReaderStream::with_capacity(reader, capacity),
|
||||
remaining,
|
||||
emitted: 0,
|
||||
expected: remaining,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -466,13 +470,32 @@ where
|
||||
bytes.truncate(*this.remaining);
|
||||
}
|
||||
*this.remaining -= bytes.len();
|
||||
#[cfg(feature = "tracing-chunk-debug")]
|
||||
{
|
||||
*this.emitted += bytes.len();
|
||||
tracing::debug!(
|
||||
emitted = *this.emitted,
|
||||
expected = *this.expected,
|
||||
chunk_len = bytes.len(),
|
||||
"GetObject ReaderStream emitted bytes"
|
||||
);
|
||||
}
|
||||
if bytes.is_empty() {
|
||||
Poll::Ready(None)
|
||||
} else {
|
||||
Poll::Ready(Some(Ok(bytes)))
|
||||
}
|
||||
}
|
||||
Poll::Ready(Some(Err(err))) => Poll::Ready(Some(Err(Box::new(err)))),
|
||||
Poll::Ready(Some(Err(err))) => {
|
||||
#[cfg(feature = "tracing-chunk-debug")]
|
||||
tracing::error!(
|
||||
emitted = *this.emitted,
|
||||
expected = *this.expected,
|
||||
error = %err,
|
||||
"GetObject ReaderStream returned error"
|
||||
);
|
||||
Poll::Ready(Some(Err(Box::new(err))))
|
||||
}
|
||||
Poll::Ready(None) => Poll::Ready(None),
|
||||
Poll::Pending => Poll::Pending,
|
||||
}
|
||||
@@ -1734,25 +1757,6 @@ impl DefaultObjectUsecase {
|
||||
);
|
||||
}
|
||||
let handoff_start = get_stage_metrics_enabled.then(std::time::Instant::now);
|
||||
#[cfg(feature = "tracing-chunk-debug")]
|
||||
let stream = {
|
||||
let mut emitted = 0usize;
|
||||
GetObjectReaderStream::new(reader, stream_buffer_size, expected).inspect(move |item| match item {
|
||||
Ok(bytes) => {
|
||||
emitted += bytes.len();
|
||||
tracing::debug!(emitted, expected, chunk_len = bytes.len(), "GetObject ReaderStream emitted bytes");
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(
|
||||
emitted,
|
||||
expected,
|
||||
error = %err,
|
||||
"GetObject ReaderStream returned error"
|
||||
);
|
||||
}
|
||||
})
|
||||
};
|
||||
#[cfg(not(feature = "tracing-chunk-debug"))]
|
||||
let stream = GetObjectReaderStream::new(reader, stream_buffer_size, expected);
|
||||
let blob = StreamingBlob::new(stream);
|
||||
if let Some(handoff_start) = handoff_start {
|
||||
|
||||
Reference in New Issue
Block a user