diff --git a/crates/ecstore/src/bucket/mod.rs b/crates/ecstore/src/bucket/mod.rs index 44aa3f5c7..54e6ae834 100644 --- a/crates/ecstore/src/bucket/mod.rs +++ b/crates/ecstore/src/bucket/mod.rs @@ -16,9 +16,12 @@ pub mod bandwidth; pub mod bucket_target_sys; pub mod error; pub mod lifecycle; +#[path = "../metadata/bucket.rs"] pub mod metadata; +#[path = "../metadata/bucket_sys.rs"] pub mod metadata_sys; #[cfg(test)] +#[path = "../metadata/bucket_test.rs"] mod metadata_test; pub mod migration; mod msgp_decode; diff --git a/crates/ecstore/src/cluster/mod.rs b/crates/ecstore/src/cluster/mod.rs index d44510e38..98ff9084b 100644 --- a/crates/ecstore/src/cluster/mod.rs +++ b/crates/ecstore/src/cluster/mod.rs @@ -13,6 +13,7 @@ // limitations under the License. mod control_plane; +pub(crate) mod rpc; pub use control_plane::{ ClusterControlPlane, ClusterControlPlaneSnapshot, ClusterDriveMembership, ClusterEndpointType, ClusterLocalNodeStorage, diff --git a/crates/ecstore/src/rpc/client.rs b/crates/ecstore/src/cluster/rpc/client.rs similarity index 100% rename from crates/ecstore/src/rpc/client.rs rename to crates/ecstore/src/cluster/rpc/client.rs diff --git a/crates/ecstore/src/rpc/context_propagation.rs b/crates/ecstore/src/cluster/rpc/context_propagation.rs similarity index 100% rename from crates/ecstore/src/rpc/context_propagation.rs rename to crates/ecstore/src/cluster/rpc/context_propagation.rs diff --git a/crates/ecstore/src/rpc/http_auth.rs b/crates/ecstore/src/cluster/rpc/http_auth.rs similarity index 100% rename from crates/ecstore/src/rpc/http_auth.rs rename to crates/ecstore/src/cluster/rpc/http_auth.rs diff --git a/crates/ecstore/src/rpc/internode_data_transport.rs b/crates/ecstore/src/cluster/rpc/internode_data_transport.rs similarity index 100% rename from crates/ecstore/src/rpc/internode_data_transport.rs rename to crates/ecstore/src/cluster/rpc/internode_data_transport.rs diff --git a/crates/ecstore/src/cluster/rpc/mod.rs b/crates/ecstore/src/cluster/rpc/mod.rs new file mode 100644 index 000000000..b7e860bcb --- /dev/null +++ b/crates/ecstore/src/cluster/rpc/mod.rs @@ -0,0 +1,38 @@ +// 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. + +pub(crate) mod client; +pub(crate) mod context_propagation; +pub(crate) mod http_auth; +pub(crate) mod internode_data_transport; +pub(crate) mod peer_rest_client; +pub(crate) mod peer_s3_client; +pub(crate) mod remote_disk; +pub(crate) mod remote_locker; +pub(crate) mod runtime_sources; + +pub use client::{ + TonicInterceptor, gen_tonic_signature_interceptor, node_service_time_out_client, node_service_time_out_client_no_auth, +}; +pub use http_auth::{TONIC_RPC_PREFIX, build_auth_headers, gen_signature_headers, verify_rpc_signature}; +#[cfg(test)] +pub(crate) use internode_data_transport::TcpHttpInternodeDataTransport; +pub use internode_data_transport::build_internode_data_transport_from_env; +pub use peer_rest_client::{ + PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PeerRestClient, SERVICE_SIGNAL_REFRESH_CONFIG, SERVICE_SIGNAL_RELOAD_DYNAMIC, +}; +pub(crate) use peer_s3_client::heal_bucket_local_on_disks; +pub use peer_s3_client::{LocalPeerS3Client, PeerS3Client, S3PeerSys}; +pub use remote_disk::RemoteDisk; +pub use remote_locker::RemoteClient; diff --git a/crates/ecstore/src/rpc/peer_rest_client.rs b/crates/ecstore/src/cluster/rpc/peer_rest_client.rs similarity index 100% rename from crates/ecstore/src/rpc/peer_rest_client.rs rename to crates/ecstore/src/cluster/rpc/peer_rest_client.rs diff --git a/crates/ecstore/src/rpc/peer_s3_client.rs b/crates/ecstore/src/cluster/rpc/peer_s3_client.rs similarity index 100% rename from crates/ecstore/src/rpc/peer_s3_client.rs rename to crates/ecstore/src/cluster/rpc/peer_s3_client.rs diff --git a/crates/ecstore/src/rpc/remote_disk.rs b/crates/ecstore/src/cluster/rpc/remote_disk.rs similarity index 100% rename from crates/ecstore/src/rpc/remote_disk.rs rename to crates/ecstore/src/cluster/rpc/remote_disk.rs diff --git a/crates/ecstore/src/rpc/remote_locker.rs b/crates/ecstore/src/cluster/rpc/remote_locker.rs similarity index 100% rename from crates/ecstore/src/rpc/remote_locker.rs rename to crates/ecstore/src/cluster/rpc/remote_locker.rs diff --git a/crates/ecstore/src/rpc/runtime_sources.rs b/crates/ecstore/src/cluster/rpc/runtime_sources.rs similarity index 100% rename from crates/ecstore/src/rpc/runtime_sources.rs rename to crates/ecstore/src/cluster/rpc/runtime_sources.rs diff --git a/crates/ecstore/src/bucket/metadata.rs b/crates/ecstore/src/metadata/bucket.rs similarity index 100% rename from crates/ecstore/src/bucket/metadata.rs rename to crates/ecstore/src/metadata/bucket.rs diff --git a/crates/ecstore/src/bucket/metadata_sys.rs b/crates/ecstore/src/metadata/bucket_sys.rs similarity index 100% rename from crates/ecstore/src/bucket/metadata_sys.rs rename to crates/ecstore/src/metadata/bucket_sys.rs diff --git a/crates/ecstore/src/bucket/metadata_test.rs b/crates/ecstore/src/metadata/bucket_test.rs similarity index 100% rename from crates/ecstore/src/bucket/metadata_test.rs rename to crates/ecstore/src/metadata/bucket_test.rs diff --git a/crates/ecstore/src/set_disk/metadata.rs b/crates/ecstore/src/metadata/set_disk.rs similarity index 100% rename from crates/ecstore/src/set_disk/metadata.rs rename to crates/ecstore/src/metadata/set_disk.rs diff --git a/crates/ecstore/src/rpc/mod.rs b/crates/ecstore/src/rpc/mod.rs index 623cae896..3c9d686b2 100644 --- a/crates/ecstore/src/rpc/mod.rs +++ b/crates/ecstore/src/rpc/mod.rs @@ -12,27 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -mod client; -mod context_propagation; -mod http_auth; -mod internode_data_transport; -mod peer_rest_client; -mod peer_s3_client; -mod remote_disk; -mod remote_locker; -mod runtime_sources; - -pub use client::{ - TonicInterceptor, gen_tonic_signature_interceptor, node_service_time_out_client, node_service_time_out_client_no_auth, -}; -pub use http_auth::{TONIC_RPC_PREFIX, build_auth_headers, gen_signature_headers, verify_rpc_signature}; #[cfg(test)] -pub(crate) use internode_data_transport::TcpHttpInternodeDataTransport; -pub use internode_data_transport::build_internode_data_transport_from_env; -pub use peer_rest_client::{ - PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PeerRestClient, SERVICE_SIGNAL_REFRESH_CONFIG, SERVICE_SIGNAL_RELOAD_DYNAMIC, +pub(crate) use crate::cluster::rpc::TcpHttpInternodeDataTransport; +pub(crate) use crate::cluster::rpc::heal_bucket_local_on_disks; +pub use crate::cluster::rpc::{ + LocalPeerS3Client, PEER_RESTSIGNAL, PEER_RESTSUB_SYS, PeerRestClient, PeerS3Client, RemoteClient, RemoteDisk, S3PeerSys, + SERVICE_SIGNAL_REFRESH_CONFIG, SERVICE_SIGNAL_RELOAD_DYNAMIC, TONIC_RPC_PREFIX, TonicInterceptor, build_auth_headers, + build_internode_data_transport_from_env, gen_signature_headers, gen_tonic_signature_interceptor, + node_service_time_out_client, node_service_time_out_client_no_auth, verify_rpc_signature, }; -pub(crate) use peer_s3_client::heal_bucket_local_on_disks; -pub use peer_s3_client::{LocalPeerS3Client, PeerS3Client, S3PeerSys}; -pub use remote_disk::RemoteDisk; -pub use remote_locker::RemoteClient; +pub(crate) use crate::cluster::rpc::{client, context_propagation, internode_data_transport, runtime_sources}; diff --git a/crates/ecstore/src/set_disk/mod.rs b/crates/ecstore/src/set_disk/mod.rs index 1e93d8fc2..1cdbcd77f 100644 --- a/crates/ecstore/src/set_disk/mod.rs +++ b/crates/ecstore/src/set_disk/mod.rs @@ -303,6 +303,7 @@ static OBJECT_LOCK_DIAG_ENABLED: OnceLock = OnceLock::new(); mod heal; mod list; mod lock; +#[path = "../metadata/set_disk.rs"] mod metadata; mod multipart; mod read; diff --git a/docs/architecture/migration-progress.md b/docs/architecture/migration-progress.md index a8652037d..a0b4c4a55 100644 --- a/docs/architecture/migration-progress.md +++ b/docs/architecture/migration-progress.md @@ -5,18 +5,20 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block ## Current Context - Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660) -- Branch: `overtrue/arch-ecstore-cluster-control-plane-layout` +- Branch: `overtrue/arch-ecstore-cluster-rpc-metadata-layout` - Baseline: completed `C-011/C-012/C-013/API-055/API-059/API-079/API-080/API-081/API-082/API-083/API-084/API-085/API-086/API-087/API-088/API-089/API-090/API-091/API-092/API-093/API-094/API-095/API-096/API-097/API-098/API-099/API-100/API-101/API-102/API-103/API-104/API-105/API-106/API-107/API-108/API-109/API-110/API-111/API-112/API-113/API-114/API-115/API-116/API-117/API-118/API-119/API-120/API-121/API-122/API-123/API-124/API-125/API-126/API-127/API-128/API-129/API-130/API-131/API-132/API-133/API-134/API-135/API-136/API-137/API-138/API-139/API-140/API-141/API-142/API-143/API-144/API-145/API-146/API-147/API-148/API-149/API-150/API-151/API-152/API-153/API-154/API-155/API-156/API-157/API-158/API-159/API-160/API-161/API-162/API-163/API-164/API-165/API-166/API-167/API-168/API-169/API-170/API-171/API-172/API-173/API-174/API-175/API-176/API-177/API-178/API-179/API-180/API-181/API-182/API-183/API-184/API-185/API-186/API-187/API-188/API-189/API-190/API-191/API-192/API-193/API-194/API-195/API-196/API-197/API-198/API-199/API-200/API-201/API-202/API-203/API-204/API-205/API-206/API-207/API-208/API-209/API-210/API-211/API-212/API-213/API-214/API-215/API-216/API-217/API-218/API-219/API-220/API-221/API-222/API-223/API-224/API-225/API-226/API-227/API-228/API-229/API-230/API-231/API-232/API-233/API-234/API-235/API-236/API-237/API-238/API-239/API-240/API-241/API-242/API-243/API-244/API-245/API-246/API-247/API-248/API-249/API-250/API-251/API-252/API-253/API-254/CTX-002`. - Current baseline also includes API-255 from PR #3923, API-256 from PR #3925, and CFG-009 from PR #3927. -- Current phase PR: E-028/E-CLUSTER-001 ECStore cluster control-plane owner layout. -- Based on: E-027 branch while PR #3930 is pending; rebase onto `origin/main` - after E-017 through E-027 merge before opening this PR. +- Current phase PR: E-029/E-030 ECStore cluster RPC and metadata owner layout. +- Based on: E-028 batch branch while PR #3931 is pending; rebase onto + `origin/main` after E-019 through E-028 merge before opening this PR. - PR type for this branch: `pure-move`. -- Runtime behavior changes: none expected for E-028; production changes are a - module file move that keeps the existing `cluster` facade paths. -- Rust code changes: move ECStore cluster control-plane implementation under - the `cluster/control_plane` owner module without function-body changes. +- Runtime behavior changes: none expected for E-029/E-030; production changes + are module file moves that keep the existing `rpc`, `bucket::metadata`, + `bucket::metadata_sys`, and `set_disk::metadata` facade paths. +- Rust code changes: move ECStore RPC implementation files under the + `cluster/rpc` owner directory and move bucket/set-disk metadata support files + under the `metadata` owner directory without function-body changes. - CI/script changes: reject restoring ECStore root `store.rs`, `set_disk.rs`, `store_list_objects.rs`, `store_utils.rs`, `store_init.rs`, `disks_layout.rs`, `endpoints.rs`, `storage_api_contracts.rs`, @@ -25,7 +27,10 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block `data_movement_backpressure.rs`, `admin_server_info.rs`, `data_usage.rs`, `get_diagnostics.rs`, `global.rs`, `runtime_sources.rs`, `bitrot.rs`, `compress.rs`, `rio.rs`, `error.rs`, `rebalance.rs`, `pools.rs`, - `sets.rs`, `pools_test.rs`, or `store_test.rs`; + `sets.rs`, `pools_test.rs`, or `store_test.rs`, keep the ECStore cluster root + module as a re-export-only owner facade, reject restoring ECStore root RPC + support files, keep the ECStore root RPC module as a re-export-only facade, + and reject restoring old bucket/set-disk metadata owner paths; lock completed config model ownership against restoring old `rustfs_ecstore::config` model/accessor compatibility paths, and lock ECStore public facades against re-exporting the moved server-config symbols; @@ -70,8 +75,10 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block root runtime global modules after E-024, and reject restoring ECStore root I/O support modules after E-025, and reject restoring ECStore root error and rebalance facade modules after E-026, and reject restoring ECStore root core - runtime/test modules after E-027, and keep the ECStore cluster root module as - a re-export-only owner facade after E-028. + runtime/test modules after E-027, keep the ECStore cluster root module as a + re-export-only owner facade after E-028, reject restoring ECStore root RPC + support files after E-029, and reject restoring old bucket/set-disk metadata + owner paths after E-030. ## Phase 0 Tasks diff --git a/scripts/check_architecture_migration_rules.sh b/scripts/check_architecture_migration_rules.sh index 4c784d147..de2ca31f1 100755 --- a/scripts/check_architecture_migration_rules.sh +++ b/scripts/check_architecture_migration_rules.sh @@ -141,6 +141,9 @@ ECSTORE_ROOT_IO_SUPPORT_MODULE_HITS_FILE="${TMP_DIR}/ecstore_root_io_support_mod ECSTORE_ROOT_ERROR_REBALANCE_MODULE_HITS_FILE="${TMP_DIR}/ecstore_root_error_rebalance_module_hits.txt" ECSTORE_ROOT_CORE_RUNTIME_MODULE_HITS_FILE="${TMP_DIR}/ecstore_root_core_runtime_module_hits.txt" ECSTORE_CLUSTER_ROOT_IMPL_HITS_FILE="${TMP_DIR}/ecstore_cluster_root_impl_hits.txt" +ECSTORE_ROOT_RPC_SUPPORT_MODULE_HITS_FILE="${TMP_DIR}/ecstore_root_rpc_support_module_hits.txt" +ECSTORE_ROOT_RPC_IMPL_HITS_FILE="${TMP_DIR}/ecstore_root_rpc_impl_hits.txt" +ECSTORE_OLD_METADATA_OWNER_PATH_HITS_FILE="${TMP_DIR}/ecstore_old_metadata_owner_path_hits.txt" ALL_STORAGE_COMPAT_SELF_FACADE_PATH_HITS_FILE="${TMP_DIR}/all_storage_compat_self_facade_path_hits.txt" RUSTFS_LOCAL_COMPAT_OWNER_SELF_PATH_HITS_FILE="${TMP_DIR}/rustfs_local_compat_owner_self_path_hits.txt" RUSTFS_ROOT_COMPAT_RELATIVE_CONSUMER_HITS_FILE="${TMP_DIR}/rustfs_root_compat_relative_consumer_hits.txt" @@ -2945,6 +2948,49 @@ if [[ -s "$ECSTORE_CLUSTER_ROOT_IMPL_HITS_FILE" ]]; then report_failure "ECStore cluster root module must only re-export control-plane owner symbols: $(paste -sd '; ' "$ECSTORE_CLUSTER_ROOT_IMPL_HITS_FILE")" fi +( + cd "$ROOT_DIR" + { + [[ -e crates/ecstore/src/rpc/client.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/client.rs' + [[ -e crates/ecstore/src/rpc/context_propagation.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/context_propagation.rs' + [[ -e crates/ecstore/src/rpc/http_auth.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/http_auth.rs' + [[ -e crates/ecstore/src/rpc/internode_data_transport.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/internode_data_transport.rs' + [[ -e crates/ecstore/src/rpc/peer_rest_client.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/peer_rest_client.rs' + [[ -e crates/ecstore/src/rpc/peer_s3_client.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/peer_s3_client.rs' + [[ -e crates/ecstore/src/rpc/remote_disk.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/remote_disk.rs' + [[ -e crates/ecstore/src/rpc/remote_locker.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/remote_locker.rs' + [[ -e crates/ecstore/src/rpc/runtime_sources.rs ]] && printf '%s\n' 'crates/ecstore/src/rpc/runtime_sources.rs' + true + } +) >"$ECSTORE_ROOT_RPC_SUPPORT_MODULE_HITS_FILE" + +if [[ -s "$ECSTORE_ROOT_RPC_SUPPORT_MODULE_HITS_FILE" ]]; then + report_failure "ECStore RPC support modules must stay under the cluster/rpc owner directory: $(paste -sd '; ' "$ECSTORE_ROOT_RPC_SUPPORT_MODULE_HITS_FILE")" +fi + +rg -n --with-filename '^(pub(?:\(crate\))? )?(struct|enum|fn|trait) |^mod ' \ + "${ROOT_DIR}/crates/ecstore/src/rpc/mod.rs" \ + >"$ECSTORE_ROOT_RPC_IMPL_HITS_FILE" || true + +if [[ -s "$ECSTORE_ROOT_RPC_IMPL_HITS_FILE" ]]; then + report_failure "ECStore root rpc module must only re-export cluster/rpc owner symbols: $(paste -sd '; ' "$ECSTORE_ROOT_RPC_IMPL_HITS_FILE")" +fi + +( + cd "$ROOT_DIR" + { + [[ -e crates/ecstore/src/bucket/metadata.rs ]] && printf '%s\n' 'crates/ecstore/src/bucket/metadata.rs' + [[ -e crates/ecstore/src/bucket/metadata_sys.rs ]] && printf '%s\n' 'crates/ecstore/src/bucket/metadata_sys.rs' + [[ -e crates/ecstore/src/bucket/metadata_test.rs ]] && printf '%s\n' 'crates/ecstore/src/bucket/metadata_test.rs' + [[ -e crates/ecstore/src/set_disk/metadata.rs ]] && printf '%s\n' 'crates/ecstore/src/set_disk/metadata.rs' + true + } +) >"$ECSTORE_OLD_METADATA_OWNER_PATH_HITS_FILE" + +if [[ -s "$ECSTORE_OLD_METADATA_OWNER_PATH_HITS_FILE" ]]; then + report_failure "ECStore metadata modules must stay under the metadata owner directory: $(paste -sd '; ' "$ECSTORE_OLD_METADATA_OWNER_PATH_HITS_FILE")" +fi + cat >"$ECSTORE_COMPAT_PASSTHROUGH_EXPECTED_FILE" <<'EOF' EOF sort -o "$ECSTORE_COMPAT_PASSTHROUGH_EXPECTED_FILE" "$ECSTORE_COMPAT_PASSTHROUGH_EXPECTED_FILE"