diff --git a/rustfs/src/admin/handlers/site_replication.rs b/rustfs/src/admin/handlers/site_replication.rs index 34155a7264..06b9862e15 100644 --- a/rustfs/src/admin/handlers/site_replication.rs +++ b/rustfs/src/admin/handlers/site_replication.rs @@ -8617,18 +8617,14 @@ impl Operation for SiteReplicationRepairHandler { .to_string(), None => Uuid::new_v4().to_string(), }; - let response = execute_site_replication_repair(SiteReplicationRepairExecutionRequest { + let (status, headers, body) = execute_site_replication_repair(SiteReplicationRepairExecutionRequest { local_peer, preflight_token: supplied_token.to_string(), operation_id, signing_key, }) .await?; - // The repair executor still answers with the s3s response type; the - // router reads the status from the output tuple, so only the tuple and - // the headers carry over to the owned response. - let (status, body) = response.output; - Ok(AdminResponse::with_headers(status, body.into(), response.headers)) + Ok(AdminResponse::with_headers(status, body, headers)) } } diff --git a/rustfs/src/app/bucket_usecase/listing.rs b/rustfs/src/app/bucket_usecase/listing.rs index e1b6cea62b..0e3b85d3c4 100644 --- a/rustfs/src/app/bucket_usecase/listing.rs +++ b/rustfs/src/app/bucket_usecase/listing.rs @@ -18,7 +18,7 @@ use super::*; use crate::app::storage_api::bucket_usecase::contract::list::ListOperations as _; use crate::app::storage_api::s3::dto::{ CommonPrefix, DeleteMarkerEntry, EncodingType, ListObjectVersionsInput, ListObjectVersionsOutput, ListObjectsV2Input, - ListObjectsV2Output, MetadataEntry, Object, ObjectStorageClass, ObjectVersion, ObjectVersionStorageClass, Timestamp, + ListObjectsV2Output, MetadataEntry, Object, ObjectStorageClass, ObjectVersion, ObjectVersionStorageClass, Owner, Timestamp, UserMetadata, }; use crate::app::storage_api::s3::xml::{SerResult, SerializeContent}; @@ -373,6 +373,15 @@ async fn collect_list_objects_metadata_permissions( Ok(permissions) } +/// List metadata XML still carries the legacy owner shape. The id and display name are the owned identity. +fn legacy_list_owner() -> Owner { + let owner = super::rustfs_owner(); + Owner { + display_name: owner.display_name, + id: owner.id, + } +} + fn build_list_object_versions_metadata_output( object_infos: ListObjectVersionsInfo, bucket: &str, @@ -380,7 +389,7 @@ fn build_list_object_versions_metadata_output( encoding_type: Option<&EncodingType>, permissions: &HashMap, ) -> ListObjectVersionsMetadataOutput { - let owner = rustfs_owner(); + let owner = legacy_list_owner(); let common_prefixes = object_infos .prefixes .into_iter() @@ -508,7 +517,7 @@ fn build_list_objects_v2_metadata_output( fetch_owner: bool, permissions: &HashMap, ) -> ListObjectsV2MetadataOutput { - let owner = rustfs_owner(); + let owner = legacy_list_owner(); let contents = object_infos .objects diff --git a/rustfs/src/connect/diagnostics/trace_runtime.rs b/rustfs/src/connect/diagnostics/trace_runtime.rs index cec7fdfe1b..a9ed81763c 100644 --- a/rustfs/src/connect/diagnostics/trace_runtime.rs +++ b/rustfs/src/connect/diagnostics/trace_runtime.rs @@ -2461,9 +2461,8 @@ mod tests { let addr = listener.local_addr().unwrap(); let server = tokio::spawn(async move { let (socket, _) = listener.accept().await.unwrap(); - let fallback = tower::service_fn(|_| async { - Ok::<_, Infallible>(Response::new(crate::storage_api::server::http::rpc::Body::empty())) - }); + let fallback = + tower::service_fn(|_| async { Ok::<_, Infallible>(Response::new(rustfs_s3_types::Body::empty())) }); server_http1::Builder::new() .serve_connection( TokioIo::new(socket), diff --git a/rustfs/src/server/http/tests/production_batch_lock_rpc_tests.rs b/rustfs/src/server/http/tests/production_batch_lock_rpc_tests.rs index 9ddb12e938..e1545dd32d 100644 --- a/rustfs/src/server/http/tests/production_batch_lock_rpc_tests.rs +++ b/rustfs/src/server/http/tests/production_batch_lock_rpc_tests.rs @@ -264,7 +264,7 @@ async fn receiver() { let counts = Arc::new(RpcCounts::default()); let (faults, _) = watch::channel(Fault::default()); let node = InterceptedService::new(NodeServiceServer::new(make_server()), check_auth); - let fallback = tower::service_fn(|_| async { Ok::<_, Infallible>(Response::new(storage::rpc::Body::empty())) }); + let fallback = tower::service_fn(|_| async { Ok::<_, Infallible>(Response::new(rustfs_s3_types::Body::empty())) }); let production = hybrid( InternodeRpcService::new(fallback), RpcRequestPathService::new(Routes::new(node).prepare()), diff --git a/rustfs/src/site_replication/mod.rs b/rustfs/src/site_replication/mod.rs index bc38269394..556a0a0571 100644 --- a/rustfs/src/site_replication/mod.rs +++ b/rustfs/src/site_replication/mod.rs @@ -56,9 +56,9 @@ use crate::runtime_sources::{ current_deployment_id, current_endpoints_handle, current_iam_handle, current_object_store_handle, current_region, }; use crate::storage_api::site_replication::s3::{ - Body, PersistedLifecycleConfiguration, PersistedLifecycleRule, PersistedOptionalReplicationStatus, + PersistedLifecycleConfiguration, PersistedLifecycleRule, PersistedOptionalReplicationStatus, PersistedReplicationConfiguration, PersistedReplicationDestination, PersistedReplicationRule, PersistedReplicationStatus, - PersistedSourceSelectionCriteria, S3Response, Status, VersioningConfiguration, + PersistedSourceSelectionCriteria, Status, VersioningConfiguration, }; #[cfg(test)] use crate::storage_api::site_replication::save_config as save_admin_config; @@ -135,15 +135,15 @@ pub(crate) const LOG_SUBSYSTEM_SITE_REPLICATION: &str = "site_replication"; pub(crate) const EVENT_ADMIN_SITE_REPLICATION_STATE: &str = "admin_site_replication_state"; -/// Layer-local mirror of `crate::admin::utils::json_response` (the repair +/// Layer-local mirror of `crate::admin::utils::owned_json_response` (the repair /// executor answers the admin HTTP surface but must not import upward from -/// the infra layer). -fn json_response(status: StatusCode, value: &T) -> S3Result> { +/// the infra layer). The tuple is status, headers, and body. +fn json_response(status: StatusCode, value: &T) -> S3Result<(StatusCode, HeaderMap, rustfs_s3_types::Body)> { let data = serde_json::to_vec(value) .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("failed to serialize response: {e}")))?; let mut headers = HeaderMap::new(); headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); - Ok(S3Response::with_headers((status, Body::from(data)), headers)) + Ok((status, headers, rustfs_s3_types::Body::from(data))) } // The admin layer's runtime-source wrappers apply fallbacks on top of diff --git a/rustfs/src/site_replication/repair.rs b/rustfs/src/site_replication/repair.rs index 79dcbe5adc..8b31034b3d 100644 --- a/rustfs/src/site_replication/repair.rs +++ b/rustfs/src/site_replication/repair.rs @@ -708,7 +708,7 @@ pub(crate) fn admit_site_replication_repair_operation( pub(crate) async fn execute_site_replication_repair( request: SiteReplicationRepairExecutionRequest, -) -> S3Result> { +) -> S3Result<(StatusCode, HeaderMap, rustfs_s3_types::Body)> { let store = current_object_store_handle().ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string()))?; with_config_object_write_lock( @@ -724,7 +724,7 @@ pub(crate) async fn execute_site_replication_repair( pub(crate) async fn execute_site_replication_repair_locked( request: SiteReplicationRepairExecutionRequest, -) -> S3Result> { +) -> S3Result<(StatusCode, HeaderMap, rustfs_s3_types::Body)> { let state = load_site_replication_state().await?; if !state.enabled() || state.service_account_access_key.is_empty() { return Err(s3_error!(InvalidRequest, "site replication is not configured")); diff --git a/rustfs/src/site_replication/transport.rs b/rustfs/src/site_replication/transport.rs index 87cb64995b..afac3a0dd9 100644 --- a/rustfs/src/site_replication/transport.rs +++ b/rustfs/src/site_replication/transport.rs @@ -668,7 +668,7 @@ impl<'a> PeerAdminRequest<'a> { } let signed = sign_v4( request - .body(Body::empty()) + .body(rustfs_s3_types::Body::empty()) .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("build peer request failed: {e}")))?, payload.as_ref().map(|(payload, _)| payload.len() as i64).unwrap_or(0), self.access_key, diff --git a/rustfs/src/storage/s3_api/common.rs b/rustfs/src/storage/s3_api/common.rs index 3ecef88381..ef01ce8b99 100644 --- a/rustfs/src/storage/s3_api/common.rs +++ b/rustfs/src/storage/s3_api/common.rs @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(test)] -use s3s::dto::Initiator; -use s3s::dto::Owner; +use rustfs_gateway_types::dto::Owner; // Stable owner identity used in S3 response payloads (for example ACL, ListBuckets, and multipart listings). // RustFS currently does not maintain a persistent per-tenant canonical owner ID, so we keep a deterministic @@ -31,9 +29,10 @@ pub(crate) fn rustfs_owner() -> Owner { } #[cfg(test)] -pub(crate) fn rustfs_initiator() -> Initiator { - Initiator { - id: Some(RUSTFS_OWNER_ID.to_owned()), - display_name: Some(RUSTFS_OWNER_DISPLAY_NAME.to_owned()), +pub(crate) fn rustfs_initiator() -> rustfs_gateway_types::dto::Initiator { + let owner = rustfs_owner(); + rustfs_gateway_types::dto::Initiator { + id: owner.id, + display_name: owner.display_name, } } diff --git a/rustfs/src/storage/s3_api/multipart.rs b/rustfs/src/storage/s3_api/multipart.rs index 21420da8ab..c30a8251a1 100644 --- a/rustfs/src/storage/s3_api/multipart.rs +++ b/rustfs/src/storage/s3_api/multipart.rs @@ -40,10 +40,26 @@ pub(crate) struct ListMultipartUploadsParams { pub max_uploads: usize, } +#[cfg(test)] +fn legacy_owner(owner: rustfs_gateway_types::dto::Owner) -> s3s::dto::Owner { + s3s::dto::Owner { + display_name: owner.display_name, + id: owner.id, + } +} + +#[cfg(test)] +fn legacy_initiator(initiator: rustfs_gateway_types::dto::Initiator) -> s3s::dto::Initiator { + s3s::dto::Initiator { + display_name: initiator.display_name, + id: initiator.id, + } +} + #[cfg(test)] pub(crate) fn build_list_parts_output(res: ListPartsInfo) -> ListPartsOutput { - let owner = rustfs_owner(); - let initiator = rustfs_initiator(); + let owner = legacy_owner(rustfs_owner()); + let initiator = legacy_initiator(rustfs_initiator()); let transformed_parts = rustfs_utils::http::contains_key_str(&res.user_defined, rustfs_utils::http::SUFFIX_COMPRESSION) || res .user_defined @@ -213,8 +229,8 @@ mod tests { assert_eq!(parts[0].part_number, Some(1)); assert_eq!(parts[0].size, Some(11)); assert_eq!(parts[0].e_tag, Some(to_s3s_xml_etag("etag-1"))); - assert_eq!(output.owner, Some(rustfs_owner())); - assert_eq!(output.initiator, Some(rustfs_initiator())); + assert_eq!(output.owner, Some(super::legacy_owner(rustfs_owner()))); + assert_eq!(output.initiator, Some(super::legacy_initiator(rustfs_initiator()))); } #[test] diff --git a/rustfs/src/storage_api.rs b/rustfs/src/storage_api.rs index b0ab66760e..50a6139db1 100644 --- a/rustfs/src/storage_api.rs +++ b/rustfs/src/storage_api.rs @@ -239,8 +239,6 @@ pub(crate) mod server { pub(crate) mod rpc { pub(crate) use crate::storage::storage_api::rpc_consumer::InternodeRpcService; - #[cfg(test)] - pub(crate) use s3s::Body; } pub(crate) mod tonic_service { @@ -376,7 +374,6 @@ pub(crate) mod site_replication { }; #[cfg(test)] pub(crate) use rustfs_gateway_types::persistence::{PersistedLifecycleExpiration, PersistedTransition}; - pub(crate) use s3s::{Body, S3Response}; } }