Compare commits

..

163 Commits

Author SHA1 Message Date
overtrue aca434fdfc test(server): pin legacy HeadBucket answers by name and the extension routes the stack leaves to the router 2026-11-13 10:42:36 +08:00
overtrue 4c569451e1 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-13 10:13:02 +08:00
overtrue f83b964f2c fix(admin): claim main's extension routes in the shared route predicate 2026-11-13 10:13:02 +08:00
overtrue 117c9dc197 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-13 10:04:02 +08:00
overtrue 46f750c6c9 fix(storage): take HeadBucket's bucket under the floor at the legacy edge
The seam's input conversion holds a bucket name to the AWS grammar until
rustfs/gateway#1610, so HeadBucket's legacy edge builds its gateway input
with stored_bucket_name and sends only the output through the seam.
2026-11-13 10:03:56 +08:00
overtrue 1f8970ba1b Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack
# Conflicts:
#	.config/make/pre-commit.mak
#	.github/workflows/ci.yml
#	rustfs/src/app/bucket_usecase.rs
#	scripts/ci_gate.py
2026-11-13 09:34:06 +08:00
overtrue 0c44fd3bb8 feat(server): stamp the assembled S3 stack from the built service
The startup line names the stack the mounted service answers with,
read from that service. The refusal matrix collects every caller served
where it must be refused.
2026-11-13 08:40:59 +08:00
overtrue 4cb724e64b ci: bump the plan contract for the gateway-stack lane 2026-11-13 05:27:19 +08:00
overtrue e8ee409f6b Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-13 05:24:42 +08:00
overtrue 08e88f87eb test(server): fail an embedded test that cannot start a server
A dotted quad the address parser refuses is representable but not
outside the AWS grammar, so it is checked on its own.
2026-11-13 05:24:39 +08:00
overtrue 0525b3dc04 ci: guard debug-only features with cargo metadata
check_connect_release_boundary.py is parameterised over (feature,
message, source, allowed enablers) and reads feature closures from cargo
metadata, so a feature enabled through a multi-line array or another
feature is seen. The shell guard is removed.
2026-11-13 05:04:21 +08:00
overtrue b8225fb52d test(server): run a per-family refusal matrix on both stacks
Each migration family keeps its matrix rows in its own module of the one
embedded test binary; a completeness test holds the rows equal to the
served operations.
2026-11-13 05:04:21 +08:00
overtrue a1868cf6bb refactor(server): route by the legacy router's own claim, gated on the feature
One control-plane predicate is shared by the router, the request-id layer
and the stack selection, so with the gateway selected no S3 request
reaches the legacy S3 implementation. The stack wrapper and its type
alias exist only with gateway-stack: a default build mounts the legacy
service unchanged.
2026-11-13 05:04:20 +08:00
overtrue a2acae3944 refactor(server): serve gateway operations through one trait and one table
Every served operation is one impl Served with no default authorize, and
the only Handler impl is the blanket one over it: shared access phase,
the operation's own authorization, the count, the use case, one error
mapping. Ten family ROWS concatenate into the table that registers the
handlers and is the whole early gate. The decision-core authorizer, the
policy source and the per-row prose are gone. HeadBucket is served.
2026-11-13 05:04:20 +08:00
overtrue 4713e21231 fix(app): list every stored bucket under the gateway floor
ListBuckets materialises stored names under a policy that adds no rule
above the gateway's floor, so names RustFS creates and the AWS grammar
refuses (a-s3alias, sthree-x, x--ol-s3, x--x-s3, xn--abc) are listed on
both stacks. HeadBucket's use case takes the gateway DTOs, and both
legacy edges reach their use cases through one generic seam helper.
2026-11-13 05:04:09 +08:00
overtrue 95fc8b7b01 refactor(storage): share the access phase and bucket authorization between edges
The legacy check now runs resolve_req_info, AccessMarkers and
admit_operation over the signature verdict it reads once. HeadBucket's
hook is authorize_bucket_request, generic over AuthorizationRequest, and
the ListBuckets IAM preparation is generic again instead of taking a
struct of copied request facts.
2026-11-13 05:04:08 +08:00
overtrue 2873de8de9 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-13 03:54:37 +08:00
overtrue 6cba2bd002 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack
Conflicts resolved by hand, both sides kept. scripts/ci_gate.py: CODE_JOBS carries workspace-clippy (#9345) and test-and-lint-gateway-stack; main moved the plan contract to 4 for its own job-set change, so the marker for this job set is 5 in ci_gate.py and in the classify-changes fallback. rustfs/src/storage/ecfs.rs: #9319 dropped the metrics import, the gateway ListBuckets seam import stays.
2026-11-12 23:52:56 +08:00
overtrue 7c8e4c7711 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-12 22:07:41 +08:00
overtrue e8847f6f1d test(gateway): assert the store-fault answer names nothing
The 500 answer to a credential-store fault is checked to carry neither the looked-up key, nor a secret, nor a reason for the failed lookup. The test comment records that the earlier pin answered 403.
2026-11-12 04:13:20 +08:00
overtrue ee7523bab6 test(gateway): expect 500 for a credential-store fault on the new pin
The gateway's RustFS authenticator preset now answers a credential-store fault as 500 InternalError (rustfs/gateway#1585, ledger R-068), which is what the legacy stack answers. The two tests that pinned the old 403 InvalidAccessKeyId now expect the fault answer; the assembly itself is unchanged.
2026-11-12 04:12:06 +08:00
overtrue ca8769d7c2 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-12 01:16:40 +08:00
overtrue 83f3fbf2cd Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack 2026-11-12 00:46:17 +08:00
overtrue f56477eb53 Merge remote-tracking branch 'origin/main' into gw/T2.5-gateway-stack
# Conflicts:
#	rustfs/src/storage/access.rs
#	rustfs/src/storage/storage_api.rs
2026-11-11 22:58:00 +08:00
overtrue 2f55ddb595 Merge remote-tracking branch 'origin/gw/T1.8-access-envelope' into gw/T2.5-gateway-stack
# Conflicts:
#	.config/make/pre-commit.mak
#	.config/test-count-baseline.txt
#	Cargo.lock
#	Cargo.toml
#	crates/gateway-adapter/Cargo.toml
#	crates/gateway-adapter/src/lib.rs
2026-11-11 20:53:15 +08:00
overtrue 44e147e8eb test(gateway): sign the probe request with a declared payload token
The probe request carried no x-amz-content-sha256 and was answered 400 before it reached the handler. It now declares an unsigned payload, and a probe that is not reached reports the answer it got.
2026-11-11 20:01:29 +08:00
overtrue dd760dfa56 fix(app): drop the PutObjectInput re-export main now provides 2026-11-11 19:37:21 +08:00
overtrue 7be29ee088 Merge remote-tracking branch 'origin/main' into gw/T1.8-access-envelope 2026-11-11 19:22:52 +08:00
overtrue 70a0267d01 Merge remote-tracking branch 'origin/gw/T1.8-access-envelope' into gw/T2.5-gateway-stack 2026-11-11 18:03:26 +08:00
overtrue 28ac9de62a fix(auth): keep the test-only credentials rebuild out of the lib build 2026-11-11 17:39:55 +08:00
overtrue da6c626f2a fix(gateway): refuse an empty handed-over secret at the gateway edge
RequestCredentials no longer represents an absent secret as an empty string. The gateway edge maps the new constructor result, and a signed ListBuckets request is shown to reach its handler without the caller's secret, where a reader of it fails closed.
2026-11-11 17:35:13 +08:00
overtrue e2fee7cb2b Merge remote-tracking branch 'origin/gw/T1.8-access-envelope' into gw/T2.5-gateway-stack
# Conflicts:
#	rustfs/src/app/context/envelope.rs
2026-11-11 17:12:17 +08:00
overtrue a115748cda fix(auth): make an absent caller secret unrepresentable as a key
RequestCredentials::secret_key now returns Option<&str>: None when the edge kept the secret, and an empty handed-over secret is refused at construction. Secret comparisons go through secret_key_matches, which never matches an absent secret, and readers that need the value fail closed with an internal error.
2026-11-11 17:08:17 +08:00
overtrue 1f7f5b8532 fix(table-catalog): restore owned request lines the main merge reverted
The merge onto main replaced two lines with main's text: the warehouse location check again wrapped an already owned request in legacy_request_view, and an error conversion was re-added. Restore the branch's version of the file.
2026-11-11 16:44:45 +08:00
overtrue 0721822cfa Merge remote-tracking branch 'origin/gw/T1.8-access-envelope' into gw/T2.5-gateway-stack 2026-11-11 16:03:45 +08:00
overtrue 0b7fd7a367 Merge remote-tracking branch 'origin/gw/T2.5-gateway-stack' into gw/T2.5-gateway-stack 2026-11-11 15:55:44 +08:00
Chris An f3b0806547 fix(gateway): reconcile squashed foundation with main
Merge main after the foundation squash, preserving gateway branch changes
and importing the unchanged scanner prefix fix from main.

Verified exact tree preservation outside the two scanner files, whitespace,
release-boundary guard and self-test, footprint guard, and logging guard.
Rust compile, fmt and scoped tests unavailable locally: no Rust toolchain.
Test-count guard could not run because cargo metadata is unavailable.
2026-11-11 02:55:06 -05:00
overtrue 1fbcacb2b6 test(auth): cover multipart staging in the owned/legacy decision matrix 2026-11-11 15:53:57 +08:00
overtrue 7729e8c337 Merge remote-tracking branch 'origin/gw/T1.8-access-envelope' into gw/T2.5-gateway-stack
# Conflicts:
#	rustfs/src/storage/storage_api.rs
2026-11-11 15:53:25 +08:00
overtrue a537b6ea98 Merge remote-tracking branch 'origin/gw/T2.1-adapter-foundation' into gw/T2.5-gateway-stack 2026-11-11 15:53:11 +08:00
overtrue 3805f2970e Merge remote-tracking branch 'origin/main' into gw/T1.8-access-envelope 2026-11-11 15:42:39 +08:00
overtrue 62f0385769 Merge remote-tracking branch 'origin/gateway/integration' into gw/T1.8-access-envelope 2026-11-11 15:42:39 +08:00
overtrue c312102bab docs(gateway-adapter): state what install guarantees about the provider handle 2026-11-11 15:41:18 +08:00
overtrue 35e6c8077d Merge remote-tracking branch 'origin/main' into gw/T2.1-adapter-foundation 2026-11-11 15:40:56 +08:00
overtrue 007c3b204b Merge remote-tracking branch 'origin/gateway/integration' into gw/T2.1-adapter-foundation 2026-11-11 15:40:56 +08:00
overtrue 1c3fe4747e refactor(server): box the route facts a deferred question carries
A question the table answers by itself is one byte; one that asks the core carries the request facts. Boxing them keeps the common, decided case small.
2026-11-11 15:00:12 +08:00
overtrue 032566507a test(auth): report every decision mismatch in the parity matrix 2026-11-11 14:35:50 +08:00
overtrue 42ab123d69 Merge remote-tracking branch 'origin/gateway/integration' into gw/T2.5-gateway-stack 2026-11-11 14:25:05 +08:00
overtrue 22f6c668da feat(server): wire the owned authorization core into the gateway stack
The route stage's decision core is now the owned authorization entry point: a RouteDecidable row resolves the caller with the function the legacy access check uses and asks authorize_owned_request about the request as it arrived. The host attaches the request line for it, since the gateway hands an authorizer the headers and the query but neither the method nor the target. A core that cannot answer stays Indeterminate.

The gateway stack refuses to start while Keystone is enabled: the pinned gateway admits a request that carries only X-Auth-Token as anonymous, while the RustFS code behind it reads the Keystone identity (rustfs/gateway#1586).

The embedded tests now observe the S3 request counter through the whole stack: one served ListBuckets is counted once under the label the legacy stack uses, and a request refused by authentication once under no operation. The two tests that pin how a failed credential lookup is answered name ledger entry R-068 and rustfs/gateway#1585.
2026-11-11 14:24:59 +08:00
overtrue 9829661a98 Merge remote-tracking branch 'origin/gw/T1.8-access-envelope' into gw/T2.5-gateway-stack
# Conflicts:
#	rustfs/src/storage/access.rs
#	rustfs/src/storage/storage_api.rs
2026-11-11 14:23:10 +08:00
overtrue ee3ef73630 test(gateway): pin how the gateway answers an unavailable credential backend
The pinned gateway's SigV4 authenticator answers a credential provider fault exactly as an unknown access key, so an unavailable IAM or a withdrawn root is 403 InvalidAccessKeyId, not a 5xx as on the legacy stack. The two tests asserted the 5xx this stack cannot answer; they now pin the observed refusal and that nothing is served, and the root rotation test checks the new key is known to the next request.
2026-11-11 13:48:59 +08:00
rustfs-cla-assistant[bot] 4c7cc8a943 Merge remote-tracking branch 'origin/main' into gateway/integration 2026-11-11 05:25:16 +00:00
overtrue 42ee5b151b test(auth): satisfy clippy on the parity test facade 2026-11-11 13:12:38 +08:00
overtrue 3cda284b4c test(auth): owned and legacy entry points reach the same decisions
Decision-level parity over IAM allow and explicit deny, owner, anonymous on private and public buckets, bucket-policy explicit deny, aws:SourceIp from the peer and from a verified client, and one allow and one deny per body-derived input (legal hold, tagging, retention mode and retain-until, resolved copy source, POST form fields).
2026-11-11 12:36:59 +08:00
overtrue fb053dfb85 test(auth): read storage-private parity facts through test accessors
The parity tests moved to the app layer can no longer read ObjectTagConditions and TableDataPlanePublicationGuards fields directly; parity_test_support exposes read-only accessors instead. Drop an unused import.
2026-11-11 12:32:50 +08:00
overtrue 9707aa4f1f ci(gateway): lint and test the gateway stack on every code change
The gateway-stack feature leg becomes its own job on the pull-request path and joins the Test and Lint aggregate, instead of a leg of the nightly-only feature matrix. Operation slices put their handler tests, their authorization census and their end-to-end refusal tests behind the feature, so a leg that ran only on dispatch would let them rot.

The job set changed, so the plan contract marker moves to 4: a plan from a base planner that predates this job is refused and the full matrix runs.
2026-11-11 12:23:02 +08:00
overtrue 197e682488 refactor(server): install the IAM adapters as one pair
The adapter crate now installs its credential provider and policy source together through IamAdapters::install, and takes the live root as a closure. The assembly passes a closure over the root credentials the legacy stack reads, and keeps refusing a missing or too-short configured root.
2026-11-11 12:09:55 +08:00
overtrue 0e0744cb49 Merge remote-tracking branch 'origin/gw/T2.1-adapter-foundation' into gw/T2.5-gateway-stack 2026-11-11 12:08:08 +08:00
overtrue 20872bba63 fix(gateway-adapter): effective secret length and unsplittable pair
Address the confirmation review of the T2.1 adapters
(rustfs/backlog#2760).

- One rule for every secret: its length after trailing NUL bytes are
  removed must be at least MIN_SECRET_KEY_LEN. HMAC zero-pads its key,
  so trailing NULs add nothing; interior NULs count. Applied to the root
  secret, the STS signing key and every looked-up credential.
- IamAdapters keeps both halves private and hands them to a builder
  together through the consuming install(builder, make_authenticator);
  compile-fail doctests show a mixed pair cannot be assembled.
- Any Fn() -> Option<Arc<RootCredentials>> is a RootSource, so the
  binary reads its live root accessor directly; RootCell is now a
  test-only helper.
2026-11-11 12:06:45 +08:00
overtrue 30d8aee534 feat(server): read the live root for the gateway stack on every request
The assembly builds both adapters over one live root source that reads the root credentials where the legacy stack reads them, per request, so a root change reaches both stacks at once. A missing or too-short configured root fails the assembly instead of starting a server without a root.
2026-11-11 11:55:23 +08:00
overtrue 05e6fd2085 Merge remote-tracking branch 'origin/gateway/integration' into gw/T2.5-gateway-stack 2026-11-11 11:52:39 +08:00
overtrue 3f861328d8 Merge remote-tracking branch 'origin/gw/T2.1-adapter-foundation' into gw/T2.5-gateway-stack 2026-11-11 11:52:39 +08:00
overtrue 210e1b214e fix(server): keep the empty Buckets element on the legacy ListBuckets
The compatibility seam writes a listing without buckets as an absent member, where the legacy edge has always answered an empty element. Clients index the answer by it, so the legacy edge restores it. Also drops a re-export the removed legacy output builder was the last user of.
2026-11-11 11:52:39 +08:00
Chris An 55d931353f ci(s3-tests): add reference parity lane against pinned 1.0.5 (#9288) 2026-11-10 22:50:17 -05:00
overtrue 0e1e2e0003 fix(gateway-adapter): share live root and refuse short secrets
Address the security review of the T2.1 adapters (rustfs/backlog#2760).

- Add RootCredentials (validated: root secret and STS signing key at
  least MIN_SECRET_KEY_LEN bytes), the RootSource trait and the settable
  RootCell. IamAdapters::new is now the only constructor of
  IamCredentials and IamPolicySource, so both read one live root source
  per request; no root source answers unavailable.
- A looked-up identity whose secret is shorter than 8 bytes is NotFound
  in the credential provider and DISABLED_PRINCIPAL in the policy
  source, whatever the lookup reports as valid.
- STS claims are read with the STS signing key from the root source
  instead of assuming it equals the root secret.
- Cover the off-status-alone branch, the OIDC owner exclusion, service
  accounts of root, the name live groups are read under, and another
  session's token.
2026-11-11 11:36:11 +08:00
overtrue b3e60a8882 test(auth): move owned parity tests to the app layer
Owned-versus-legacy parity, hoist and fail-closed tests now live in app/owned_authorization_test.rs beside the envelope's facts impl, so storage names no app type in test code either. Private storage steps are reached through a test-only parity_test_support module. Also fix the S3Error conversion CI reported in prepare_owned_authorization.
2026-11-11 11:26:52 +08:00
overtrue e6a1f542a1 Merge remote-tracking branch 'origin/gateway/integration' into gw/T1.8-access-envelope
# Conflicts:
#	.config/test-count-baseline.txt
2026-11-11 10:59:13 +08:00
overtrue 662781e45b Merge remote-tracking branch 'origin/gateway/integration' into gw/T2.5-gateway-stack 2026-11-11 10:59:06 +08:00
overtrue 7aceffc68c ci(gateway): keep gateway-stack out of release builds and lint it
The gateway stack refuses to compile without debug assertions, and a static guard keeps the feature, and any feature that enables it, out of the default and full feature lists and out of every release input. The feature matrix gains a gateway-stack leg for its lints and tests.
2026-11-11 10:58:56 +08:00
overtrue e0b53cc8d9 feat(server): serve ListBuckets on the gateway stack behind a feature
With the gateway-stack feature built in and RUSTFS_S3_STACK=gateway, the S3 service under the middleware is the rustfs-gateway service: the RustFS profile, SigV4 verification against RustFS IAM, an authorizer backed by an explicit per-operation table, explicit deadlines, and one registered handler. Every other S3 operation is answered 501, and admin, console, STS, health and profiling routes stay on the legacy router until they are migrated.

The stack is selected once at startup. An assembly failure fails startup, and a binary without the feature keeps refusing the selection.
2026-11-11 10:58:56 +08:00
overtrue db370e3241 refactor(app): move ListBuckets use case onto the request envelope
The use case takes a RequestEnvelope and the gateway's ListBucketsInput and returns the gateway's ListBucketsOutput, so both S3 stacks call one implementation. The legacy s3s method converts through the compatibility seam and calls it.

The per-request part of the legacy access check (caller resolution, the upload-size capability scoping and the license check) moves into two functions over owned facts, which the legacy check now calls and the gateway handlers will call too.
2026-11-11 10:58:56 +08:00
overtrue ffe6bc86d3 fix(auth): keep owned authorization in the app layer and fail closed
Move the RequestEnvelope impl of AuthorizationRequest and the owned entry points into the app layer so storage depends only on the request-facts trait (layer guard). The owned entry points now hoist signed x-amz-meta-* query parameters like the legacy edge and refuse actions whose decision needs a request-body input the envelope does not carry. Revert unrelated TODO rewording and redact PostObjectPolicyHeaders debug output.
2026-11-11 10:53:07 +08:00
Chris An fc09148f08 chore(gateway): record ignored microbenchmarks merged from main (#9290)
chore(gateway): record the ignored microbenchmarks merged from main

main added three throughput microbenchmarks that are ignored by design
(#9217): one each in rustfs-checksums, rustfs-rio and rustfs-utils. The
test-count ratchet treats a higher ignored count as a failure until the
row is raised, so raise those three rows to 1 and tighten the test rows
to the merged tree with --update.
2026-11-10 21:30:34 -05:00
rustfs-cla-assistant[bot] c9e1464a2a Merge remote-tracking branch 'origin/main' into gateway/integration 2026-11-11 02:06:08 +00:00
overtrue 5d6358a0a5 Merge remote-tracking branch 'origin/gateway/integration' into gw/T2.5-gateway-stack 2026-11-11 09:58:48 +08:00
Chris An 0e3028d29e ci(gateway): make the test-count ratchet a floor, not exact (#9278)
ci(gateway): make the test-count ratchet a floor instead of an exact baseline

Tests below a row still fail; tests above it, a member without a row and ignores below the row now pass with a note. Ignores above a row still fail. Adds contract tests wired into make script-tests.
2026-11-10 20:53:06 -05:00
overtrue dde2169c83 feat(gateway-adapter): add IAM-backed PolicySource
Add IamPolicySource, the gateway PolicySource answered by RustFS IAM
(rustfs/backlog#2760, policy half). One snapshot per request carries a
RustfsPrincipal: principal kind, account, effective username, parent
user, credential groups, live group memberships, token claims and
is_owner.

- Anonymous callers get an empty snapshot without asking IAM.
- IAM not ready, not initialized or failing is PolicyError::unavailable,
  never an empty snapshot.
- Unknown, disabled and session-kind-mismatched principals are refused
  with constant labels; unreadable tokens are malformed.
- Claims are read from the stored token (root secret for STS, the
  account's own secret for service accounts), and is_owner mirrors the
  legacy has_root_access rule.
- RustfsPrincipal holds no secret or session token and has no Debug.
2026-11-11 09:43:47 +08:00
overtrue 0b586c37e9 refactor(auth): share authorization core with owned entry points
Extract the policy decision behind authorize_request into a core that both the legacy s3s request and the RustFS-owned RequestEnvelope feed, and move the zip-create and table-catalog admin callers to the owned entry points (authorize_owned_request, authorize_owned_internal_object_request). Request-body policy inputs added on main since the candidate base (POST form headers, copy source, legal hold and tagging bodies) become named envelope fields so both edges reach the same decision. Refs rustfs/backlog#2749.
2026-11-11 09:40:02 +08:00
Chris An 365014a385 feat(scripts): add junit_diff.py for dual-stack JUnit comparison (#9275) 2026-11-10 19:55:24 -05:00
overtrue 7946b094f9 feat(gateway-adapter): add IAM-backed CredentialProvider
Add the ring-2 crate rustfs-gateway-adapter with IamCredentials, the
gateway CredentialProvider answered by RustFS IAM (rustfs/backlog#2760,
credentials half; PolicySource is deferred).

- Pin rustfs-gateway at the existing gateway rev with
  default-features = false so the server crate stays out of the build.
- IamKeyLookup is a narrow IAM trait implemented for IamSys so the
  adapter is testable without an in-memory IAM backend.
- Root credentials are injected at construction and resolve before IAM
  is ready.
- Mapping: keystone: prefix -> NotFound (deliberate change from the
  legacy empty secret); IAM not ready or not initialized -> Unavailable;
  unknown key or NoSuch{User,ServiceAccount,TempAccount,Account} ->
  NotFound; other IAM errors -> Backend; invalid or "off" principals
  resolve disabled; STS credentials carry a SessionBinding, and an STS
  credential without an expiry is a Backend fault rather than a
  never-ending session.
- No authorization in lookup; no Debug on secret-holding types; IAM
  error text is dropped after classification.
2026-11-11 07:19:17 +08:00
overtrue 443e8afee1 chore(gateway): merge main into integration
# Conflicts:
#	crates/ecstore/src/disk/local/delete_recovery.rs
#	crates/ecstore/src/store/bucket.rs
2026-11-10 21:40:26 +08:00
overtrue 782e3e5209 chore(gateway): merge main into integration 2026-11-10 08:28:05 +08:00
overtrue cfffb1700e chore(gateway): update test-count baseline after main sync
Main #9241 removed the node pool-metadata readiness cache with 8 tests
and added 6, so the rustfs row drops from 6440 to 6438. The ecstore and
s3select rows rise for tests added by #9237, #9239 and #9241.
2026-11-09 10:21:53 +08:00
rustfs-cla-assistant[bot] cd62f3ba4f Merge remote-tracking branch 'origin/main' into gateway/integration 2026-11-09 02:07:05 +00:00
overtrue 7bc419e368 chore(gateway): merge main into integration
# Conflicts:
#	.config/e2e-full-selection.txt
#	crates/ecstore/src/disk/local/delete_recovery.rs
2026-11-09 00:50:02 +08:00
overtrue 7269243de7 chore(gateway): merge main into integration
Port main's changes into integration's relocated code: the XML compatibility
body bound and presigned-guard tests into legacy_compat, the policy-condition
fixes (#9150, #9159, #9163) into auth facts and the owned admin request API,
and record native publications on main's new fused delete-recovery paths.
2026-11-08 22:26:59 +08:00
overtrue c4a7423f99 fix(ecstore): create parents before admitted truncate opens
Align the heal tests with removal-disabled preservation and local-only outcome
fields, and refresh the e2e-full selection for the synced tests.
2026-10-31 08:38:51 +08:00
overtrue 2db4ed244a fix(ecstore): scope the merged direct-writer test hook to test builds 2026-10-31 06:40:49 +08:00
overtrue 93a61df1cf chore(gateway): merge main into integration
Keep native publication recording in main's native_io helpers and resource
writers, and adapt merged tests to the owned Body, Bytes write input, and
fallible find_disk.
2026-10-31 06:15:49 +08:00
overtrue feec0e9e4a test(s3select): use the owned JSON input types in merged planner tests 2026-10-31 03:08:13 +08:00
overtrue 38baeeb11d chore(gateway): merge main into integration
Record native publications on the paths main's commit-fusion work opened
directly: the lazy truncate writer and the fused delete-recovery activation
and receipt renames. Keep extract_params_header in the shared audit builder.
2026-10-31 01:40:30 +08:00
overtrue 1af039c972 chore(gateway): merge main into integration 2026-10-30 20:14:52 +08:00
overtrue a2fc7c13b4 chore(gateway): merge main into integration 2026-10-30 18:41:32 +08:00
overtrue dbe01e5cb1 chore(gateway): raise test-count rows for tests merged from main 2026-10-30 14:35:18 +08:00
overtrue ffc27fa6db chore(gateway): merge main into integration 2026-10-30 14:29:25 +08:00
overtrue 7e8edab0d3 chore(gateway): merge main into integration 2026-10-30 11:23:05 +08:00
overtrue 22057ad4c5 chore(gateway): merge main into integration 2026-10-30 07:08:33 +08:00
overtrue 279a88ab56 chore(gateway): merge main into integration 2026-10-29 20:19:36 +08:00
overtrue b4abe64ada chore(gateway): merge main into integration
Sync main 84e24e767 into gateway/integration. Ports main-side additions to
the integration boundaries: the tier deletion diagnostics admin handlers move
to the owned admin request/response types, and the new lifecycle rule checks
in ecstore use the persisted lifecycle types instead of s3s DTOs. Keeps the
gateway git source in deny.toml while dropping the smithy-rs pin main retired,
and refreshes the test-count baseline for the merged tree.
2026-10-29 16:01:13 +08:00
overtrue add363f084 chore(gateway): merge main into integration
Sync main 9601a7c4b into gateway/integration. Ports main-side additions to the
owned admin boundary (plugin delegation/attempt handlers, notification target
edit tests), drops a new ecstore s3s::dto reference in favour of the persisted
lifecycle filter, and refreshes the e2e selection digests and test-count
baseline for the merged tree.
2026-10-29 07:31:24 +08:00
overtrue 1f2dbe36e5 test(ecstore): pin native history on cancellation under the cancellable queue
main moved the local write path onto the disk blocking queue, which skips an
operation once its waiter is dropped, so a borrowed write cancelled while it is
queued no longer creates its file. The integration-only native publication
test still expected the queued open to run. Assert the new execution model
instead (the open never runs) while keeping its safety claims: the Started
record is taken before queueing and the cancelled publication never regrants
native history.
2026-10-27 22:08:04 +08:00
overtrue 67fbafa13e chore(gateway): merge main into integration
Source: main 4e48c390e7
Target: gateway/integration 1000860cb8

Conflicts resolved, keeping both sides:
- crates/ecstore/src/disk/{fs,local}.rs: main's batched rollback writes,
  unified blocking write path and relocated open_file, with integration's
  native publication records restored at each publication point and the
  publication_history field kept beside main's multipart proof authority.
- crates/ecstore/src/set_disk/ops/multipart.rs: union of the imports.
- rustfs/src/storage/rpc/node_service.rs: main's MRF lifecycle reader
  capability branch; the heal capability keeps integration's restore
  copy-back probe.
- rustfs/src/admin/handlers/{audit,event,plugins_instances}.rs: main's
  target_read inventory snapshot on integration's owned request boundary;
  the new event.rs inventory test now builds owned requests.
- scripts/check_s3s_footprint.sh: integration's baseline-file version.
- .config/e2e-{full,smoke}-selection.txt: digests recomputed over the
  union of both heads' CI listings (full 700 darwin / 708 linux, smoke 232).

Also migrated main's new rebalance delete-all expiry test to the persisted
lifecycle types integration uses in ecstore, and raised the test-count
baseline to the merged counts (every decrease comes from main).
2026-10-27 08:38:17 +08:00
Chris An 1000860cb8 refactor(admin): drop the legacy target descriptor JSON response helper (#8968)
`target_descriptor::build_json_response` returned the s3s response and
had no production caller left once the event, audit and plugin instance
handlers moved to `owned_build_json_response`; it survived only for the
legacy/owned equivalence test. Remove it, give the owned helper its own
documentation, and make the test assert the owned response directly:
status, `application/json`, the echoed `x-request-id` when present and
only then, and the body bytes. The file no longer imports s3s, so the
footprint baseline drops from 66 to 65 files.
2026-10-27 00:15:37 +08:00
Chris An b783f404ad refactor(admin): migrate identity and cluster handlers to owned requests (#8966)
* refactor(admin): migrate identity and cluster handlers to owned requests

Move the T1.12 batch 4 admin handlers (user, service_account, oidc, tier,
system, pools, quota, kms_dynamic, kms_backup, rebalance, module_switch,
bucket_meta, cluster_snapshot, realtime, bucket_recovery, profile) from the
s3s request/response types to the owned AdminRequest/AdminResponse
boundary. All 90 impl Operation blocks now take AdminRequest and return
AdminResponse; handler logic, authorization order, error codes and response
bytes are unchanged. The handlers use the shared owned helpers
(owned_json_response, owned_admin_json_response, authorize_profile_envelope,
the envelope-form runtime sources and audit constructors) instead of local
copies.

profile.rs drops the s3s forms of authorize_profile_request and
profile_not_implemented_response now that profile_admin.rs is on the
envelope gate too; profile_not_implemented_response answers with an
AdminResponse. The realtime metrics stream moves from the s3s ByteStream
adapter to Body::from_stream, and the rebalance idle-404 document still
renders through s3s::S3Error::to_http_response with its body converted at
the edge.

The idp_compat delegators ImportIamV2 and AddServiceAccountLdap move to the
owned trait as well: with their targets on both traits, the method-call
delegation became ambiguous between the owned impl and the router blanket
impl, so they now take the owned request directly.

KmsAdminAudit::from_request loses its last production caller with this batch
and is deleted; its comparison test now asserts the envelope facts directly.

Lower the s3s footprint baseline to the measured 68 files.

Part of rustfs/backlog#2788 (rustfs/backlog#2734 T1.12).

* refactor(admin): remove the legacy admin helpers batch 4 superseded

Batch 4 moved the last production callers of the s3s-typed admin helpers
to their owned forms, which left `admin_json_response`, `json_response`,
`authenticate_request`, `authorize_admin_request`, `object_store_from_req`
and `object_store_from_extensions` unused, along with the `Body`,
`S3Request` and `S3Response` re-exports of the admin `s3` facade. Remove
them. The owned forms keep their documentation; the behavior tests of the
removed `json_response` now exercise `owned_json_response`, and the
compat-prefix test asserts the owned response directly.

Two tests existed only to compare a removed legacy helper with its owned
twin (`owned_json_response_matches_the_legacy_shape`) or to cover the
removed legacy gate (`authorize_admin_request_without_credentials_is_rejected`);
they go with the helpers, and the owned equivalents stay. The rustfs
test-count row drops from 5957 to 5955 and the s3s footprint from 68 to 66
files.
2026-10-26 22:23:47 +08:00
Chris An 11a991c777 refactor(admin): complete the owned admin request boundary (#8949)
* refactor(admin): complete the owned admin request boundary

Every type implementing the owned admin `Operation` now serves the legacy
router through one blanket impl that converts the s3s request and response
at that single edge, so handlers register with `AdminOperation(&Handler {})`
and need no adapter statics; `LegacyAdminAdapter` is removed.

`AdminRequest` gains the accessors handlers read today (`remote_addr`,
`client_info`, `request_context`, `req_info`, `req_info_mut`,
`install_req_info`, `envelope_mut`, `take_body`), the request helpers gain
envelope forms (`authenticate_envelope_credentials`,
`object_store_from_envelope`, the table-catalog `*_from_envelope` helpers,
`KmsAdminAudit::from_envelope`, `AccountAuditContext::from_envelope`,
`CallerIdentity::resolve_envelope`), `read_compatible_admin_body` accepts
either body type, and the owned `Body` gains `store_all_limited` and
`Default`. `admin::operation::test_support::TestRequest` builds owned
requests for handler tests. Unused accessors carry a per-method dead-code
expectation that each migrating handler batch removes.

No handler behavior changes; the remaining migrations follow in batches.

* chore(admin): add the T1.12 admin handler codemod

The script rewrites an admin handler file from the s3s request and response
types to the owned boundary (imports, signatures, request field and helper
calls, body access, response construction, and test request literals) and
leaves a TODO comment at every site it cannot rewrite mechanically. It is
idempotent and is removed once T1.12 completes.

* refactor(admin): migrate replication and KMS handlers to owned requests (#8951)

Move the T1.12 batch 2 admin handlers (site_replication, kms_keys, event,
replication, diagnostics, on_demand_migration, audit, account, kms_rekey,
kms_key_lifecycle, object_data_cache, tls_debug, integrity) from the s3s
request/response types to the owned AdminRequest/AdminResponse boundary.
Handler logic, authorization order, error codes and response bytes are
unchanged; the request/response plumbing now goes through the envelope
accessors and helpers introduced by the owned boundary.

The shared response helpers (utils::json_response, utils::empty_response,
handlers::admin_json_response, target_descriptor::build_json_response,
profile::authorize_profile_request) and the site replication repair
executor still answer with the s3s types, so the migrated files carry
owned-boundary forms of those helpers and convert the repair response at
its call edge. The streaming console-log body and the two devnull drains
move from the s3s byte stream to the owned Body stream/frame API.

Drop the dead_code expectations for the owned accessors and envelope
helpers this batch starts using, and lower the s3s footprint baseline to
the measured 99 files.

Part of rustfs/backlog#2788 (rustfs/backlog#2734 T1.12).

* refactor(admin): add owned forms of the shared admin response helpers

Handler batches were copying `json_response`, `empty_response`,
`admin_json_response`, and `build_json_response` into each migrated file
because the shared helpers still return the s3s response. Provide owned
forms next to each legacy helper (`owned_json_response`,
`owned_empty_response`, `owned_admin_json_response`,
`owned_build_json_response`, `authorize_profile_envelope`) with parity
tests against the legacy shape, derive `Debug` for `AdminResponse` so
tests can use `expect_err`, and fix three codemod rules: strip owned
string conversions in test credentials, annotate non-literal URI parses,
and leave a rebound request parameter immutable.

* refactor(admin): use the shared owned response helpers in batch 2 (#8954)

Replace the per-file owned-boundary copies of json_response,
empty_response, admin_json_response, build_json_response and
authorize_profile_request in the batch 2 admin handlers with the shared
owned_* helpers and authorize_profile_envelope that the boundary branch
now provides, and restore expect_err in the handler tests now that
AdminResponse implements Debug; the `.err().expect(..)` stand-ins were
failing the base branch's clippy step (clippy::err_expect under
-D warnings). The site replication repair call edge
keeps its conversion because the repair executor still answers with the
s3s response type.

Drop the dead_code expectations on the shared owned helpers this batch
now uses in non-test code.

Part of rustfs/backlog#2788 (rustfs/backlog#2734 T1.12).

* fix(admin): preserve legacy body limit error responses

* refactor(admin): move policy, ILM and batch 3 handlers to owned requests (#8956)

Batch 3 of T1.12 (rustfs/backlog#2788, parent rustfs/backlog#2734) moves
14 admin handler files to AdminRequest/AdminResponse and the owned
Operation trait: ilm_transition, policies, idp_compat, config_admin,
plugins_instances, profile_admin, group, heal, object_zip_download,
kms_key_metadata, durability, inspect_archive, sts and
gateway_key_inventory. Handler logic, authorization order, error codes
and response bytes are unchanged; test request literals use
test_support::TestRequest.

The handlers use the shared owned helpers (owned_json_response,
owned_admin_json_response, owned_build_json_response,
authorize_profile_envelope). The dead_code expectations on the
AdminRequest accessors and RequestEnvelope::uri_mut they now exercise
are removed. The legacy target_descriptor::build_json_response keeps
only its equivalence test caller and carries the matching expectation
until it retires.

object_zip_download builds the s3s request the S3 gate still reads from
the owned request facts; heal authenticates through
authenticate_envelope_credentials; the trace, inspect-archive and zip
bodies use Body::from_stream. extract_plugin_instance_filters takes the
URI so extensions.rs keeps calling it, and the two idp_compat
delegations stay on the legacy trait until their delegates migrate.

The s3s footprint baseline drops from 99 to 90 files.

* test(admin): anchor the replication diff body contract on the call

The source-contract test looked for `let body = read_compatible_admin_body(`
on one line; rustfmt wrapped that binding after the handler moved to the
owned request boundary, so the marker was no longer found. Anchor on the
call itself so formatting cannot change what the contract checks.

* refactor(admin): migrate table catalog and batch 1 to owned requests (#8955)

* fix(admin): preserve catalog body limit response bytes
2026-10-26 17:04:02 +08:00
Chris An 3f2b6f690a refactor(admin): migrate health and prefix usage to owned requests (#8887)
* refactor(admin): add owned health router boundary

* refactor(admin): migrate prefix usage to owned request
2026-10-26 07:34:31 +08:00
overtrue 88b626e7a0 chore(gateway): merge main into integration
Source: main 0f24511535
Target: gateway/integration 8cf6187ff4

Resolve the e2e-full selection digest conflict by recomputing both
platform digests over the merged nextest listing (685 darwin / 693
linux): main adds two rpc_fault_proxy unit tests, integration keeps its
dual-stack differential and anonymous-access additions. Raise the rustfs
test-count baseline row to the merged count (5932).
2026-10-25 09:58:02 +08:00
overtrue 8cf6187ff4 chore(gateway): merge main into integration 2026-10-25 01:50:03 +08:00
Chris a0a0cee9eb refactor(auth): derive policy conditions from AuthzFacts (#8442)
* refactor(auth): extract authorization facts

* test(e2e): update smoke selection baseline

* test(e2e): update full selection baseline
2026-10-24 16:56:01 +09:00
overtrue 80fff4b5c5 Merge gateway/integration (#8844) into the main sync
Only the s3s footprint baseline conflicted; s3_error_lines tightens to 289.
2026-10-24 09:30:22 +08:00
Chris d91dfcedd2 refactor(s3): migrate private multipart validation errors (#8844) 2026-10-24 09:17:48 +09:00
overtrue 79c4fedf8c Merge gateway/integration into the main sync
Brings in #8825, #8831, #8836 and #8839. Conflicts were import lists and test blocks (both sides kept), plus the new restore_copyback request flag next to main's data-movement field. Main replaced completed_multipart_object_part with prepare_complete_multipart_parts, so the stale import is dropped.

Main's xl.meta fast-path scanner (inspect_v2_object_slice) predates #8836 and classified a transitioned version with a pending v1 restore copyback as having no physical data dir, which made find_unshared_data_dir_for_version drop the copyback data dir. The scanner now reads the copyback marker with get_consistent_bytes semantics (both aliases, ASCII case-insensitive, empty or conflicting values count as absent), and uses_data_dir keeps main's allocation-free transition check plus #8836's copyback exclusion. find_unshared_data_dir_for_version_keeps_pending_copyback_data_dir failed on the plain merge and passes now.
2026-10-24 07:51:55 +08:00
Chris 73c846e09c refactor(storage): migrate option errors to domain types (#8839) 2026-10-24 05:50:10 +09:00
Chris 6938c467d0 fix(ecstore): finalize restore metadata after local copy-back (#8836)
* fix(ecstore): finalize restore metadata after local copy-back

* test(ecstore): ratchet added restore finalization cases

* fix(ecstore): keep restore copyback compatible with older peers

* fix(ecstore): gate restore copyback on fleet compatibility

* fix(ecstore): retain transition identity during restore copyback

* fix(ecstore): route committed restore copyback locally

* fix restore copyback cleanup

* fix(ecstore): honor restore probe test fallback
2026-10-24 02:34:29 +09:00
Chris 5323df7049 fix(protocols): clear clippy failures after T1.5 merge (#8831)
fix(protocols): clear clippy failures after merge
2026-10-23 17:37:26 +09:00
Chris 55b6fbd260 refactor(protocols): move StorageBackend to gateway types (#8825)
* refactor(protocols): move storage backend to gateway types

* test: update e2e test count baseline

* fix: preserve copy source keys and unknown lengths

* test: update protocols test count baseline

* fix(protocols): preserve typed SFTP backend errors

* test(protocols): use gateway list input in policy tests
2026-10-23 15:46:28 +09:00
overtrue dd677cc121 Merge main into gateway/integration
Picks up main through 44a73b0be. Conflicts: rustfs/src/error.rs keeps the rustfs-s3-types ApiError conversion and drops the helper main's #8816 replaced; scripts/check_s3s_footprint.sh keeps the integration script, whose baseline lives in .config (main only retuned a constant the integration script does not have). Main's new tests use the rustfs-s3-types error code in admin replication and reach s3s::BodySizeLimitExceeded through the app's test-only s3 facade, so the s3s file count stays at 118; s3_error_lines tightens to 302. The test-count baseline is regenerated; the e2e selections are unchanged.
2026-10-23 08:40:02 +08:00
overtrue 0c2f327974 Merge gateway/integration into the main sync
Brings in #8812 and #8818 from gateway/integration. #8812 predates main's heal error classifier (#8778); its two retryable variants (TooManyOpenFiles, OutdatedXLMeta) move into the classifier's transient arms for storage and disk errors, and its test is kept.
2026-10-23 07:22:20 +08:00
overtrue df42cf1ce8 test(e2e): use a non-default region for the differential negative control
Since main's region-aware CreateBucket and GetBucketLocation (#8739, #8743), us-east-1 answers an empty LocationConstraint and 200 for an owned re-create, so the control no longer reported its own region. Also refresh the e2e-full linux selection from the CI listing (682 tests).
2026-10-23 07:21:19 +08:00
Chris d290d46b34 test: reserve nextest capacity for progress probes (#8818) 2026-10-23 06:12:31 +09:00
Chris 0d297ed8cd fix(heal): retry transient metadata conflicts (#8812)
* fix(heal): retry transient metadata conflicts

* chore: update heal test count baseline
2026-10-23 01:47:55 +09:00
overtrue b8dffa2f1d Merge main into gateway/integration
Picks up the 20 main commits since 62b6f5f3f. The one conflict is the tier free-version recovery test setup: it keeps the integration-only fixture isolation (background recovery disabled while the fixture starts) and main's mock tier registration (#8804 skips scans with no tier). The e2e selections are unchanged by these commits; the test-count baseline is regenerated.
2026-10-22 20:17:09 +08:00
overtrue 62b6f5f3fc Merge main into gateway/integration
The scheduled sync has stopped on conflicts since 2026-10-19. Resolved by keeping both sides: main's restructured delete-rollback path in disk/local.rs with the integration-only native-publication record, main's per-instance region with the rustfs-s3-types Region, main's new lifecycle, rebalance and admin code ported to the persisted lifecycle types and rustfs-s3-types errors, both sides' new scanner tests, and the union of the access_consumer imports. The e2e smoke, full (darwin) and repl-nightly selections and the test-count baseline are regenerated from the merged tree.
2026-10-22 10:14:41 +09:00
Chris be0986115c refactor(s3select): run queries on gateway DTO request shapes (#8794)
* refactor(s3select): run queries on an engine request built from gateway DTO shapes

Part of T1.5 (rustfs/backlog#2746), batch 2.

* fix(s3select): keep the select request conversion in the app layer

The layer guard forbids app -> storage; the conversion moves from storage/s3_compat/select.rs to app/select_request.rs unchanged.
2026-10-22 08:16:48 +09:00
Chris 1bd91c8dad refactor(s3-client): move remote error codes and DTO enums off s3s (#8783)
Part of T1.5 (rustfs/backlog#2746), batch 1.
2026-10-22 06:15:04 +09:00
Chris dcb22bd4d5 refactor(ecstore): move bucket configs onto gateway persisted types (#8709)
* refactor(ecstore): move bucket configs onto gateway persisted types

Finish the ECStore batch of T1.4 (rustfs/backlog#2745). The remaining
eleven bucket configuration families (Website, CORS, Tagging, Versioning,
ObjectLock, Encryption, Notification, Logging, Accelerate, RequestPayment,
PublicAccessBlock) now read and write their stored XML through the
rustfs-gateway-types persistence and cors_tagging codecs instead of the
s3s codec, so the legacy s3s bucket-config codec and its
s3gate-metadata-xml compat marker are removed.

- ecstore: BucketConfigXml is implemented by the gateway codec for every
  family; metadata, metadata_sys, versioning, object lock, replication and
  lifecycle consumers take the persisted types. Region moves to
  rustfs_s3_types::Region, and the ETag conversion to s3s moves to the
  rustfs edge with its tests. Only warm_backend.rs and warm_backend_s3.rs
  still reference s3s, held for T1.5 (rustfs/backlog#2746).
- scanner: object lock cache, item actions and data usage use the
  persisted types.
- rustfs: the legacy S3 edge converts each family between s3s DTOs and the
  persisted types in storage/storage_api.rs by writing one codec's XML and
  reading it with the other; Tagging converts field by field.
- Bump the rustfs-gateway-types pin to 21283e87.

The 39 persisted-byte goldens are unchanged and pass, so a document the
old codec wrote reads back and re-encodes to the same bytes. s3s footprint:
files 181 -> 146, ecstore_files 28 -> 2, s3_error_lines unchanged.

* test(app): prepare the PutBucketEncryption config from the request

The uninitialized-store test passed an empty persisted configuration, which the use case now validates before it reaches the store check, so it answered MalformedXML instead of InternalError. Convert the request's configuration the way the S3 edge does.

* style(app): format the PutBucketEncryption test
2026-10-21 23:51:23 +09:00
Chris fa17718444 refactor(admin): move error types to rustfs-s3-types (#8440)
* refactor(protocols): move error types to rustfs-s3-types by codemod

T1.2 batch 3 (rustfs/backlog#2743): s3select-api, s3select-query and
the error items of protocols move off s3s by scripts/codemods, run with
--hold crates/protocols/src/sftp/errors.rs. That file stays on s3s: it
downcasts the backend error, whose runtime type is still s3s::S3Error.

- rustfs/src/protocols/client.rs: the two webdav session methods now
  return rustfs_s3_types::S3Result and convert the s3s error with From.
- codemod: a child module that calls s3_error! through `use super::*`
  gets its own `use rustfs_s3_types::s3_error;` once its parent imports
  that macro by name; otherwise it is listed as GLOB.
- s3-types: a table test pins code, status and the s3s error the legacy
  edge renders for every variant a moved call site names.
- s3_error_lines 1585 -> 1584 (a lifecycle comment reworded).

* refactor(admin): move error types to rustfs-s3-types (WIP, no build)

T1.2 batch 4 (rustfs/backlog#2743), work in progress: rustfs check
still fails with 16 errors (listed in the PR body).

- codemod: --facade PATH treats a crate-local re-export of s3s's error
  items like s3s for the four names (9 new self-tests, 9 mutants red).
- codemod output for rustfs/src/admin and rustfs/src/site_replication
  (--facade crate::storage_api::site_replication::s3); 6 glob children
  get an explicit rustfs_s3_types::s3_error import.
- admin/router.rs: the Operation trait returns rustfs_s3_types::S3Result.
- error.rs: From<ApiError> builds the rustfs-s3-types error; the s3s
  conversion is derived from it.

* fix(admin): convert error types at the s3s boundary

Batch 4 of T1.2 left the admin and site_replication modules returning
rustfs_s3_types::S3Error while their callers and callees on the storage
and auth side still speak s3s::S3Error. Convert at each edge with the
existing From impls in rustfs-s3-types (compat_s3s.rs) instead of
changing any code, message or status:

- admin/auth.rs, admin/handlers/object_zip_download.rs,
  admin/handlers/table_catalog/mod.rs: map the s3s result returned by
  check_key_valid / authorize_request / authorize_internal_object_request
  into the admin error type with .map_err(Into::into).
- storage/ecfs.rs: the s3s-facing side maps the admin site_replication
  gate results the other way.
- admin/handlers/pools.rs: ApiError.code stays s3s::S3ErrorCode, so the
  rustfs code is converted with .into() when the struct is built, in
  production and in the two tests that build or compare it.
- admin/handlers/heal.rs, admin/runtime_sources.rs: the router returns
  s3s errors (S3Route impl); the expected rustfs code is converted with
  .into() before the comparison.
- admin/handlers/table_catalog/mod.rs: iceberg_rest_error takes
  &'static str so the Cow<'static, str> custom code borrows it; every
  caller already passes an ICEBERG_ERROR_* constant or a &'static str.
- admin/handlers/quota.rs: drop a now same-type .into() after s3_error!.
- storage_api.rs, site_replication/mod.rs: drop re-exports and an import
  that no longer have users (clippy -D warnings).

cargo check -p rustfs --all-targets and cargo clippy -p rustfs
--all-targets -- -D warnings are clean; the s3s footprint baseline is
unchanged at files=172, s3_error_lines=303, ecstore_files=28.

Refs rustfs/backlog#2743, rustfs/backlog#2734.
2026-10-21 22:50:27 +09:00
overtrue 99abffc57a refactor(lifecycle): replace s3s domain types with Gateway DTOs
Keep lifecycle rules, restore requests, Object Lock, and scanner cached tags in domain types. Convert at the existing HTTP boundary while preserving legacy XML, scanner cache bytes, date ordering, and tombstones.

Linux test validation before the final import-path-only adjustment:

cargo nextest run -p rustfs-ecstore bucket_config_goldens
39 passed; 6211 skipped by selector.

cargo nextest run --lib -p rustfs -E 'test(/test_zero_rule_lifecycle_tombstone_recognition/) | test(/test_local_lifecycle_staleness_axis_selection/) | test(/test_lifecycle_staleness_preserves_legacy_submillisecond_axis/) | test(/test_merge_incoming_lifecycle/) | test(/test_lifecycle_expiry_statement_matrix/) | test(/test_lifecycle_expiry_subset_xml/) | test(/put_bucket_lifecycle_validation_errors_keep_their_s3_code/) | test(/execute_put_bucket_lifecycle_configuration_rejects_missing_configuration/) | test(/execute_restore_object_rejects_missing_restore_request/) | test(/execute_restore_object_rejects_select_type/) | test(/execute_restore_object_maps_failures_to_typed_s3_errors/) | test(/execute_restore_object_returns_internal_error_when_store_uninitialized/) | test(/restore_request_conversion_preserves_legacy_output_values/) | test(/restore_request_conversion_preserves_presence_and_raw_enums/) | test(/restore_request_conversion_distinguishes_absent_and_empty_containers/)'
25 passed; 5318 skipped by selector.

cargo nextest run --profile ci -p rustfs-ecstore -p rustfs-lifecycle -p rustfs-replication -p rustfs-scanner
7872 passed; 21 skipped under the existing CI profile.

Previously verified mutation controls: 39 production faults, 41 RED/GREEN pairs.

cargo clippy --locked -p rustfs -p rustfs-ecstore -p rustfs-lifecycle -p rustfs-scanner --all-targets -- -D warnings
Passed in 40m 45s before the import-path adjustment, then in 1m 59s on
the final source with warnings denied. The final adjustment imports the
existing helper through the object domain facade; fmt and the architecture
check also passed.

Part of rustfs/backlog#2745. The remaining ecstore configuration families follow separately.
2026-10-17 07:03:41 +08:00
overtrue fc061c7930 fix(ecstore): retry tier commit intent lock contention
Retry transient namespace lock timeouts within the existing three-attempt
CAS budget. Reload and verify the original mutation identity after
contention, and preserve the final typed error when attempts are exhausted.
Cover save/read contention, exhausted retries, replacement identities and
CAS reconciliation without changing the existing timeout or lock policy.

Validation:
- cargo nextest run --locked -p rustfs-ecstore --features test-util --lib -E 'test(tier_mutation)' --test-threads 1 --no-fail-fast: 52 passed.
- cargo nextest run --locked -p rustfs-ecstore --features test-util --lib -E 'test(intent_advance_) | test(=services::tier::tier::tests::caller_cancellation_after_durable_prepare_does_not_hide_the_mutation)' --test-threads 1 --no-fail-fast: 5 passed.
- cargo clippy --locked -p rustfs-ecstore --all-targets -- -D warnings: passed.
- cargo clippy --locked -p rustfs-ecstore --all-targets --features test-util -- -D warnings: passed.
- 27 mutation pairs failed at the intended assertions and passed after restoring the production code.
- bash scripts/check_test_count_ratchet.sh --update, then bash scripts/check_test_count_ratchet.sh: 52 crates, 22013 tests, 165 ignored; ecstore increases from 6581 to 6585.
2026-10-17 01:19:11 +08:00
overtrue d86bf1360f fix(ecstore): recover delete batches with missing versions
Treat an explicit non-null version as a no-op when it is absent from both recovery sources. Keep rejecting missing null versions, delete-marker mismatches and conflicting local generations.

Add returning-disk and partial-receipt regressions, extend journal boundary checks, and regenerate the ecstore test-count baseline. Production faults exercise the 24 added assertion sites and 7 semantic checks: 33 faults failed at the expected sites and passed after full restoration.

Validation (LANG=en_US.UTF-8, one build job):

cargo nextest run --locked -p rustfs-ecstore --lib -E 'test(delete_recovery) | test(quorum_delete_cleanup_coordinator_binds_single_and_batch) | test(crash_delete_retry_batch_reclaims_inline_and_reserved_external)' --test-threads 1 --no-fail-fast
Summary [  34.580s] 69 tests run: 69 passed, 6058 skipped; exit 0

cargo clippy --locked -p rustfs-ecstore --all-targets -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 5m 37s; exit 0

All 19 final Quick Checks completed with exit 0:

- shellcheck --version && actionlint
- cargo fmt --all --check
- ./scripts/check_unsafe_code_allowances.sh
- ./scripts/check_layer_dependencies.sh
- ./scripts/check_architecture_migration_rules.sh
- ./scripts/check_logging_guardrails.sh
- ./scripts/check_error_other_format_ratchet.sh
- ./scripts/check_no_tokio_io_uring.sh
- ./scripts/check_extension_schema_boundaries.sh
- ./scripts/check_body_cache_whitelist.sh
- ./scripts/check_s3s_footprint.sh
- ./scripts/check_test_count_ratchet.sh
- ./scripts/check_fips_wording.sh
- ./scripts/check_embedded_secrets.sh
- make script-tests
- python3 ./scripts/test_object_generation_protocol_model.py
- python3 ./scripts/check_test_wiring.py
- ./scripts/check_no_planning_docs.sh
- ./scripts/check_uring_lane_lib_only.sh

test-count ratchet OK: 52 crates, 22009 tests, 165 ignored match .config/test-count-baseline.txt
PASS: cold stampede script self-test
model: states=51023, transitions=167520, terminal=732, chosen_candidates=2
multi-slot round schedules: 640
OK: e2e modules, runner selection, fuzz matrices, profiles, scheduled alerts, and Quick Checks are wired
2026-10-16 17:32:35 +08:00
overtrue f6097d1df2 fix(ci): restore integration test compilation
Gate the diagnostic test import with its feature, initialize the conditional
MetadataWriteStore fields explicitly, and decode the scanner replication fixture
through its existing cache boundary. Preserve the original fixture and assertions.

Validation was run on tree 544acb80c0 at 6003d4b8.
LANG=en_US.UTF-8; no source changes follow validation.

Quick checks: 19/19 passed.
- shellcheck --version && actionlint: exit 0
- cargo fmt --all --check: exit 0
- ./scripts/check_unsafe_code_allowances.sh: exit 0
- ./scripts/check_layer_dependencies.sh: exit 0
- ./scripts/check_architecture_migration_rules.sh: exit 0
- ./scripts/check_logging_guardrails.sh: exit 0
- ./scripts/check_error_other_format_ratchet.sh: exit 0
- ./scripts/check_no_tokio_io_uring.sh: exit 0
- ./scripts/check_extension_schema_boundaries.sh: exit 0
- ./scripts/check_body_cache_whitelist.sh: exit 0
- ./scripts/check_s3s_footprint.sh: exit 0
- ./scripts/check_test_count_ratchet.sh: exit 0
- ./scripts/check_fips_wording.sh: exit 0
- ./scripts/check_embedded_secrets.sh: exit 0
- make script-tests: exit 0
- python3 ./scripts/test_object_generation_protocol_model.py: exit 0
- python3 ./scripts/check_test_wiring.py: exit 0
- ./scripts/check_no_planning_docs.sh: exit 0
- ./scripts/check_uring_lane_lib_only.sh: exit 0

Darwin validation:
- cargo clippy --locked -p rustfs-ecstore -p rustfs-scanner --all-targets -- -D warnings: exit 0
- cargo nextest run --locked -p rustfs-ecstore -p rustfs-scanner --lib -E 'test(config::com::tests::save_config_preserves_retryable_system_volume_errors) | test(scanner_io::tests::replication_maintenance_refreshes_compacted_stats_across_cycles_and_retries)' --test-threads 1 --no-fail-fast: exit 0, 2/2 passed
- cargo clippy --locked -p rustfs-ecstore -p rustfs-scanner --all-targets --features rustfs-ecstore/diagnostic-read-version-caller,rustfs-scanner/diagnostic-read-version-caller -- -D warnings: exit 101
- cargo nextest run --locked -p rustfs-ecstore -p rustfs-scanner --lib --features rustfs-ecstore/diagnostic-read-version-caller,rustfs-scanner/diagnostic-read-version-caller -E 'test(config::com::tests::save_config_preserves_retryable_system_volume_errors) | test(scanner_io::tests::replication_maintenance_refreshes_compacted_stats_across_cycles_and_retries) | test(cluster::rpc::runtime_sources::tests::) | test(config::com::tests::diagnostic_config_write_retains_origin_and_api_for_results_and_cancellation)' --test-threads 1 --no-fail-fast: exit 0, 14/14 passed

Diagnostic strict Clippy remains red on four unchanged production lints:
runtime_sources.rs if_same_then_else and three redundant_locals reports in
set_disk/core/metadata_read.rs and set_disk/read.rs. Their source ranges and
feature wiring match the base; the base was not compiled separately.

Linux aarch64 validation (Rust/Clippy 1.99.0, UID 501, jobs=1):
- cargo clippy --all-targets -- -D warnings: exit 0; Finished dev profile in 68m 12s
- cargo clippy -p rustfs -p rustfs-ecstore --all-targets --features rio-v2 -- -D warnings: exit 0; Finished dev profile in 49m 45s
Source HEAD/tree and clean status matched before and after both commands.
No compiler or stack overrides were used. protoc 35.1 was installed from its
verified ARM64 release; flatc was absent and not invoked by the workspace build scripts.
The local environment differs from hosted CI.
2026-10-16 13:06:24 +08:00
rustfs-cla-assistant[bot] 7e5d32eecf Merge remote-tracking branch 'origin/main' into gateway/integration 2026-10-16 02:09:53 +00:00
overtrue 72da0e21c4 chore: merge main into gateway/integration
Keep the migrated compatibility adapters in their active modules while bringing in upstream fixes. Preserve native publication history on the new create, rename and borrowed-open paths.

Validation:
- `cargo nextest run --locked -p rustfs-ecstore --lib -E 'test(disk::os::native_creation_history_tests::) | test(disk::local::test::borrowed_open_cancellation_retains_started_history_before_execution) | test(disk::local::test::owned_direct_child_open_attempt_consumes_native_history)' --no-fail-fast`: 9/9 passed after restoring all 12 mutation cases at cea78f2590645eb0d303cd7cf56f4dd0d9c00e87; these source blobs are unchanged in this merge.
- `cargo nextest run --locked -p rustfs-s3select-query --lib -E 'test(dispatcher::json_document_schema::tests::)' --no-fail-fast`: 5/5 passed at 5421ba682d1329cc7ebeaac7c6a863da2cea1996, with the same tree.
- `cargo fmt --all --check`: passed.
- `./scripts/check_test_count_ratchet.sh --update`: 52 crates, 22007 tests, 165 ignored.
- Profile baselines use seven actual Darwin listings and seven actual Linux listings.
- Earlier conflict snapshot f5e0cdf0c58aed1ebe53b9243cf52f94832ab049: `cargo nextest run --locked -p rustfs-ecstore -p rustfs --lib -E 'test(disk::os::) | test(bucket::metadata_sys::) | test(server::legacy_compat::) | test(server::layer::tests::request_logging_watchdog) | test(server::http::tests::conditional_object_http::) | test(storage::helper::tests::operation_helper)' --no-fail-fast` passed 218/218 before the borrowed-open fix. This is historical evidence.
2026-10-16 09:49:08 +08:00
Chris 78a0cf321c refactor(replication): move the replication config onto gateway types (#8443)
* wip: T1.4 replication family

* refactor(replication): move the replication config onto gateway types

The replication configuration family leaves s3s: rustfs-replication no longer depends on s3s, and ECStore bucket metadata, the scanner and the rustfs app/admin layers hold rustfs_gateway_types::persistence::PersistedReplicationConfiguration. The persisted XML goes through the gateway persistence codec behind a new BucketConfigXml trait (the 39 byte goldens pass with unchanged fixtures); the legacy s3s edge converts once in storage/ecfs.rs through storage/s3_compat/replication.rs; the scanner data usage cache keeps its MessagePack bytes through a serde mirror pinned by bytes recorded from s3s 5761ddfe. rustfs-gateway-types 0.32.0 is pinned once (rev 772d3385). Refs rustfs/backlog#2745.

* test: use S3 serializer for list response tests
2026-10-16 06:19:32 +08:00
overtrue cbe38a120f Merge main into gateway/integration
Merge frozen main acd26afd8b and include
compatibility fixes and measured Darwin/Linux membership corrections
across six files.

Validation on candidate b4c3ab560a:
- All 20 local gates passed.
- Native smoke: 218 passed. Native full: 661 passed.
- Full passed on the same-head failed-only rerun; the initial failure
  remains recorded.
- Gateway remains report-only: 38 passed, 180 failed, under the existing
  exemption.

CI: https://github.com/rustfs/rustfs/actions/runs/38285788334
2026-10-13 03:26:16 +08:00
overtrue db0828aa1c test(ecstore): isolate rollback guard loss fixtures
Run the three rollback metadata-cleanup cases in separate test processes so reused /proc/self/fd aliases from earlier cases cannot invalidate their creation witnesses. Keep the original fixture, guards, assertions and io_uring test selection, and verify that each child runs the intended case successfully.

Update the generated test-count baseline for the added macro arm.

Validation: cargo check -p rustfs-ecstore --tests; cargo fmt --all --check; all 19 quick-check commands, including make script-tests and the two Python checks. Linux io_uring acceptance and fault controls remain pending.
2026-10-12 00:42:51 +08:00
overtrue 3ca889b099 fix(ecstore): box nested bucket rollback state
Keep the guarded rollback future behind a heap allocation so bucket creation does not store its nested state inline. The rollback body, all three fence references and pending-proof revocation order are unchanged.

The same three original Linux tests overflowed on both e611 CI attempts. Local format, ecstore test compilation and all 19 quick-check steps pass; the original Linux feature lanes still need to validate this candidate.
2026-10-11 20:32:00 +08:00
overtrue e6112c526f fix(ecstore): retain creation fences through rollback
Keep lifecycle, metadata-transaction, and namespace guards around rollback and metadata cleanup. Preserve the original publication error when a guard is lost. Build the timestamp retry fixture through the real interrupted producer so it checks a valid pending creation.

Validated source tree: 4e8e207999.
Two independent source reviews found no blocking regression.

Validation (LANG=en_US.UTF-8):
- bash -c 'shellcheck --version && actionlint' — exit 0
- cargo fmt --all --check — exit 0
- ./scripts/check_unsafe_code_allowances.sh — exit 0
- ./scripts/check_layer_dependencies.sh — exit 0
- ./scripts/check_architecture_migration_rules.sh — exit 0
- ./scripts/check_logging_guardrails.sh — exit 0
- ./scripts/check_error_other_format_ratchet.sh — exit 0
- ./scripts/check_no_tokio_io_uring.sh — exit 0
- ./scripts/check_extension_schema_boundaries.sh — exit 0
- ./scripts/check_body_cache_whitelist.sh — exit 0
- ./scripts/check_s3s_footprint.sh — exit 0
- ./scripts/check_test_count_ratchet.sh — exit 0
- ./scripts/check_fips_wording.sh — exit 0
- ./scripts/check_embedded_secrets.sh — exit 0
- make script-tests — exit 0
- python3 ./scripts/test_object_generation_protocol_model.py — exit 0
- python3 ./scripts/check_test_wiring.py — exit 0
- ./scripts/check_no_planning_docs.sh — exit 0
- ./scripts/check_uring_lane_lib_only.sh — exit 0
- cargo nextest run --profile ci -p rustfs-ecstore --lib --locked --no-fail-fast — 5894 passed, 0 skipped
- cargo check -p rustfs-ecstore --all-targets --locked — exit 0
- cargo nextest run --profile ci -p rustfs --lib --locked --no-fail-fast -E 'test(=admin::handlers::table_catalog::tests::cold_strong_registration_completes_while_other_bucket_backup_waits) | test(=admin::handlers::table_catalog::tests::commit_backend_borrowed_put_preserves_owner_authorization_and_precondition) | test(=admin::handlers::table_catalog::tests::disable_table_bucket_preserves_objects_and_can_be_reenabled) | test(=admin::handlers::table_catalog::tests::load_table_handler_negotiates_vended_credentials_without_breaking_metadata_only_callers) | test(=admin::handlers::table_catalog::tests::namespace_property_handler_updates_object_backed_catalog_and_maps_errors) | test(=app::object::get::tests::execute_get_object_resumes_from_relocated_pool_without_splicing_body) | test(=table_catalog::store::tests::catalog_writer_loss_prevents_recovery_storage_commit)' — 7 passed
- cargo nextest run --profile ci -p rustfs --lib --locked --no-fail-fast -E 'test(unsupported_remote_disk_)' — 2 passed

Additional fault-injection evidence remains incomplete. Timestamp M1 reached its original assertion; its restore run is being collected. M2–M5 and the three planned rollback faults have not run. An automated risk check interrupted the timestamp proof task; no assertions or validation settings were weakened.
2026-10-11 16:16:31 +08:00
Chris c5967686f1 fix(ecstore): bound bucket creation stack usage (#8466) 2026-10-11 00:55:29 -07:00
Chris 859de565ad refactor(rpc): serve internode rpc bodies with the owned Body (#8441)
* test(rpc): pin the wire bytes of every internode rpc response body

rustfs/backlog#2747 batch 4, step 1 of 2, on the s3s bodies the rpc paths
serve today. Each response body builder in storage/rpc/http_service.rs is
served through hyper's HTTP/1.1 server and the raw bytes the peer reads are
compared with goldens captured from this commit: status, content-length or
chunked framing, chunk boundaries, the terminating chunk, HEAD, and the cut
connection a failure after data produces. The capability responses carry a
per-process proof, so their length header and payload are checked against
the body they encode instead.

The read_file_stream response builder moves into read_file_stream_response
so the test reaches the same code the handler runs; behaviour is unchanged.

* refactor(rpc): serve internode rpc bodies with the owned Body

rustfs/backlog#2747 batch 4, step 2 of 2. The internode rpc HTTP paths
build their responses with rustfs_s3_types::Body: Body::from_stream
replaces Body::from(StreamingBlob::wrap(..)) at the six stream sites, and
the in-memory and empty bodies keep their constructors. InternodeRpcService
converts its responses into the wrapped service's response body through
From<Body>, so the server keeps composing it with the s3s service as
before. The wire-byte goldens from the previous commit pass unchanged;
storage/rpc no longer names s3s.

* fix(rpc): simplify wire test response builder type

Name the boxed response builder used by the capability wire test so
all-target Clippy can check it without a type-complexity warning.

Validation (LANG=en_US.UTF-8, CARGO_INCREMENTAL=0):
- cargo clippy -p rustfs --all-targets -- -D warnings: exit 0.
- cargo nextest run --profile ci -p rustfs --lib -E 'test(/storage::rpc::/)': 279 tests run, 279 passed, 4842 skipped.
- All 19 quick-check commands, including script-tests, both Python scripts and cargo fmt --all --check: exit 0.
- Footprint baseline regenerated: files=194, s3_error_lines=1584, ecstore_files=36; test-count baseline regenerated: 52 crates, 21228 tests, 164 ignored.
- All 54 Cargo.toml files parse without duplicate keys.

No assertion was added or changed by this lint fix. R1-R8 are retained
in the existing PR verification record.

* fix(ecstore): resume fenced Object Lock creation intents

* fix(ecstore): bound creation retry futures on the stack

* fix(ecstore): require native proof for creation retries
2026-10-11 12:34:14 +08:00
overtrue 1f7cc593e7 test(ecstore): isolate tier-free recovery fixture startup
The fixture constructor can take the production recovery lock and wait for 60 seconds before this test installs its queue and seeds metadata. Disable its background recovery only while creating this fixture, then restore the environment before calling the existing production recovery entrypoint.

Only the existing test setup changes. Its production entrypoint, default lock parameters, original assertions, 30-second timeout, cancellation and cleanup remain intact. No tests or assertions were added. Production and store/init.rs are byte-identical to the parent.

Independent acceptance ran on merge tree 8ec358cb42ba9ebb3bcfeafcef048a3f0366355b; the runner header reports parent HEAD, while before/after index and source hashes confirm this candidate. Worker task branch d8055766b8 has the same tree.

Every command used LANG=en_US.UTF-8. Task compilation also used CARGO_BUILD_JOBS=1, CARGO_INCREMENTAL=0, CARGO_NET_OFFLINE=true, an independent target, and empty RUSTC_WRAPPER/RUSTC_WORKSPACE_WRAPPER to keep compilers in its owned process group without changing repository configuration.

Command:
shellcheck --version && actionlint
Exit 0; observed output excerpt:
version: 0.11.0
Log SHA-256: fc9eec16b4191d058a295813ca9afbe9d2b37b59975da860170726be162a3924

Command:
cargo fmt --all --check
Exit 0; observed output excerpt:
(no stdout or stderr)
Log SHA-256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Command:
./scripts/check_unsafe_code_allowances.sh
Exit 0; observed output excerpt:
(no stdout or stderr)
Log SHA-256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Command:
./scripts/check_layer_dependencies.sh
Exit 0; observed output excerpt:
Layer dependency guard passed (no new reverse dependencies/cycles).
Log SHA-256: 69c6cb1896c0586b28d1167380d3260d99d8017a4265c8df5a2348f289e93a12

Command:
./scripts/check_architecture_migration_rules.sh
Exit 0; observed output excerpt:
Architecture migration rules passed.
Log SHA-256: 28790e70d070607ed4de0704f292a65030be92ec224ef106d4b72fd8296f896e

Command:
./scripts/check_logging_guardrails.sh
Exit 0; observed output excerpt:
✅ Logging guardrails check passed
Log SHA-256: 7adf41abff8ed8f7617decf86498888ddde78937099dd9ce47f6d359dfc2d317

Command:
./scripts/check_error_other_format_ratchet.sh
Exit 0; observed output excerpt:
error(format!) ratchet passed (total call sites: 579).
Log SHA-256: 66172aef18f150ba0605af122e26ffcf91f6dd86f43e38b05e2e982ce8d783ee

Command:
./scripts/check_no_tokio_io_uring.sh
Exit 0; observed output excerpt:
(no stdout or stderr)
Log SHA-256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Command:
./scripts/check_extension_schema_boundaries.sh
Exit 0; observed output excerpt:
Extension schema boundaries passed.
Log SHA-256: f13d0acd0e2ce5d9815241b12b4dab7d01cc11b9b65bcf6dfb7812c878532a51

Command:
./scripts/check_body_cache_whitelist.sh
Exit 0; observed output excerpt:
Body-cache whitelist guard passed.
Log SHA-256: 6b828847b0383950ee6eef9cd846d0c322c945e47efd4c7d1ad881178810d6bb

Command:
./scripts/check_s3s_footprint.sh
Exit 0; observed output excerpt:
s3s footprint OK: files importing s3s is 195 (baseline files=195)
s3s footprint OK: s3s s3_error! lines is 1584 (baseline s3_error_lines=1584)
s3s footprint OK: ecstore files referencing s3s is 36 (baseline ecstore_files=36)
✅ s3s footprint baseline check passed
Log SHA-256: 47f53d04ef645618563fe1f22abc64667f19078f1974feedcca46e4f2c016844

Command:
./scripts/check_test_count_ratchet.sh
Exit 0; observed output excerpt:
test-count ratchet OK: 52 crates, 21340 tests, 164 ignored match .config/test-count-baseline.txt
Log SHA-256: 618a5e330e933de0c6ff484546df401457024a88bb5986d11d588794e33dab60

Command:
./scripts/check_fips_wording.sh
Exit 0; observed output excerpt:
FIPS wording guard passed (README.md and CHANGELOG.md contain no forbidden claims).
KMS wording guard passed (crates/kms claims no Vault KV2 Transit wrapping).
Log SHA-256: 99221cc9979c480ec4f46f50d76c52b18c72fe499f12e15e4f4a22a1b8bfb140

Command:
./scripts/check_embedded_secrets.sh
Exit 0; observed output excerpt:
Embedded secret guard passed (no private key material or provider credential literal in the tree).
Log SHA-256: 437a3ceba32094d2901889965ad191e411aad32cdb18bf0b8659e818011c406b

Command:
make script-tests
Exit 0; observed output excerpt:
test_cli_requires_the_repository_default_branch (__main__.SelfTests.test_cli_requires_the_repository_default_branch) ... ok
test_config_rejects_duplicate_and_invalid_entries (__main__.SelfTests.test_config_rejects_duplicate_and_invalid_entries) ... ok
test_freshness_boundaries (__main__.SelfTests.test_freshness_boundaries) ... ok
test_grace_requires_two_successful_queries_with_no_history (__main__.SelfTests.test_grace_requires_two_successful_queries_with_no_history) ... ok
test_invalid_api_evidence_fails_closed (__main__.SelfTests.test_invalid_api_evidence_fails_closed) ... ok
test_report_retains_every_workflow (__main__.SelfTests.test_report_retains_every_workflow) ... ok
test_requests_filter_schedule_default_branch_and_success_on_server (__main__.SelfTests.test_requests_filter_schedule_default_branch_and_success_on_server) ... ok
Ran 10 tests in 0.042s
OK
Ran 30 tests in 20.627s
OK
Ran 10 tests in 2.268s
OK
Ran 33 tests in 0.127s
OK
Ran 7 tests in 0.002s
OK
Ran 7 tests in 0.001s
OK
Ran 4 tests in 0.108s
OK
Ran 3 tests in 0.564s
OK
PASS: cold stampede script self-test
Log SHA-256: 75fda2d069a373c63667b908baaf99e6591aab9099a739b0c4c22ceb6da8d68c

Command:
python3 ./scripts/test_object_generation_protocol_model.py
Exit 0; observed output excerpt:
test_an_unavailable_decision_quorum_cannot_choose_a_candidate (__main__.ObjectGenerationProtocolModel.test_an_unavailable_decision_quorum_cannot_choose_a_candidate) ... ok
test_counter_allocation_requires_persistence_and_is_consumed_once (__main__.ObjectGenerationProtocolModel.test_counter_allocation_requires_persistence_and_is_consumed_once) ... ok
test_counter_restart_burns_persisted_allocations_before_or_after_issue (__main__.ObjectGenerationProtocolModel.test_counter_restart_burns_persisted_allocations_before_or_after_issue) ... ok
test_crash_after_promise_before_reply_does_not_restore_an_older_ballot (__main__.ObjectGenerationProtocolModel.test_crash_after_promise_before_reply_does_not_restore_an_older_ballot) ... ok
test_duplicate_or_unconfigured_voters_cannot_form_a_quorum (__main__.ObjectGenerationProtocolModel.test_duplicate_or_unconfigured_voters_cannot_form_a_quorum) ... ok
test_empty_or_unobserved_minority_slot_can_retry_without_allocating_another_revision (__main__.ObjectGenerationProtocolModel.test_empty_or_unobserved_minority_slot_can_retry_without_allocating_another_revision) ... ok
test_equal_ballot_cannot_accept_different_bytes_and_lower_ballot_is_rejected (__main__.ObjectGenerationProtocolModel.test_equal_ballot_cannot_accept_different_bytes_and_lower_ballot_is_rejected) ... ok
test_forgetting_tombstone_authority_allows_an_aba_create (__main__.ObjectGenerationProtocolModel.test_forgetting_tombstone_authority_allows_an_aba_create) ... ok
test_issuing_before_persistence_reuses_a_ballot_after_restart (__main__.ObjectGenerationProtocolModel.test_issuing_before_persistence_reuses_a_ballot_after_restart) ... ok
test_lost_ack_and_restart_preserve_the_chosen_operation (__main__.ObjectGenerationProtocolModel.test_lost_ack_and_restart_preserve_the_chosen_operation) ... ok
test_minority_accepted_work_is_adopted_and_finished (__main__.ObjectGenerationProtocolModel.test_minority_accepted_work_is_adopted_and_finished) ... ok
test_omitting_highest_accepted_adoption_has_a_double_choice_counterexample (__main__.ObjectGenerationProtocolModel.test_omitting_highest_accepted_adoption_has_a_double_choice_counterexample) ... ok
test_quorum_choice_does_not_require_an_uncontacted_disk_to_learn_it (__main__.ObjectGenerationProtocolModel.test_quorum_choice_does_not_require_an_uncontacted_disk_to_learn_it) ... ok
test_recovery_failure_or_stale_expected_head_does_not_allocate_a_successor (__main__.ObjectGenerationProtocolModel.test_recovery_failure_or_stale_expected_head_does_not_allocate_a_successor) ... ok
test_replacing_voters_with_empty_state_can_choose_a_conflicting_value (__main__.ObjectGenerationProtocolModel.test_replacing_voters_with_empty_state_can_choose_a_conflicting_value) ... ok
test_skipping_predecessor_recovery_chooses_a_broken_revision_chain (__main__.ObjectGenerationProtocolModel.test_skipping_predecessor_recovery_chooses_a_broken_revision_chain) ... ok
test_stale_publication_rollback_and_gc_cannot_change_the_winner (__main__.ObjectGenerationProtocolModel.test_stale_publication_rollback_and_gc_cannot_change_the_winner) ... ok
test_superseded_operation_identity_cannot_be_reused_for_different_input (__main__.ObjectGenerationProtocolModel.test_superseded_operation_identity_cannot_be_reused_for_different_input) ... ok
test_superseded_operation_retry_returns_its_original_successor (__main__.ObjectGenerationProtocolModel.test_superseded_operation_retry_returns_its_original_successor) ... ok
test_tombstone_and_null_marker_payloads_do_not_reset_authority_revision (__main__.ObjectGenerationProtocolModel.test_tombstone_and_null_marker_payloads_do_not_reset_authority_revision) ... ok
test_tombstone_rejects_a_delayed_never_present_create (__main__.ObjectGenerationProtocolModel.test_tombstone_rejects_a_delayed_never_present_create) ... ok
test_unlearned_predecessor_is_recovered_before_the_second_slot (__main__.ObjectGenerationProtocolModel.test_unlearned_predecessor_is_recovered_before_the_second_slot) ... ok
Ran 24 tests in 0.929s
OK
Log SHA-256: 0b4be926efb0609d497ae58930340153f01957b606206cbbdb3e0d47eb29d3a2

Command:
python3 ./scripts/check_test_wiring.py
Exit 0; observed output excerpt:
OK: e2e modules, runner selection, fuzz matrices, profiles, scheduled alerts, and Quick Checks are wired
Log SHA-256: 21f676f458451525535ab0ef73d6a9c0d9774e16d76a4d19e396ad34936dd39c

Command:
./scripts/check_no_planning_docs.sh
Exit 0; observed output excerpt:
(no stdout or stderr)
Log SHA-256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Command:
./scripts/check_uring_lane_lib_only.sh
Exit 0; observed output excerpt:
OK: no 'uring_'-matching test functions under crates/ecstore/tests; --lib is safe
Log SHA-256: 43f3f851e27ec2ab9e34d6b05fefdede38af992699c473904bfe6f53a46d52e3

Command:
cargo nextest run --profile ci -p rustfs-ecstore --lib --features rio-v2 -E 'test(=bucket::lifecycle::bucket_lifecycle_ops::tests::tier_free_version_recovery_production_entrypoint_enqueues_seeded_item)' --no-fail-fast
Exit 0; wall 234.399s.
Observed output:
    Finished `test` profile [unoptimized + debuginfo] target(s) in 3m 49s
    Starting 1 test across 1 binary (5871 tests skipped)
  SETUP PASS [   0.006s] ecstore-base-stack: sh -c 'echo RUST_MIN_STACK=4194304 >> "$NEXTEST_ENV"'
        PASS [   0.440s] rustfs-ecstore bucket::lifecycle::bucket_lifecycle_ops::tests::tier_free_version_recovery_production_entrypoint_enqueues_seeded_item
     Summary [   0.586s] 1 test run: 1 passed, 5871 skipped
Log SHA-256: 34e973f86e8dc2102c1a0e483e0ac802ce7df3d1b40a603932f62c0805c4de27

Command:
cargo nextest run --profile ci -p rustfs-ecstore --lib --features rio-v2 -E 'test(=bucket::lifecycle::bucket_lifecycle_ops::tests::tier_free_version_recovery_eight_coordinators_hold_one_leader_and_take_over) | test(=store::bucket::tests::creation_commit_backfill_runs_under_the_config_write_fence) | test(=store::bucket::tests::orphaned_bucket_recovery_requires_every_volume_absent_and_is_retryable)' --no-fail-fast
Exit 0; wall 4.010s.
Observed output:
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.43s
    Starting 3 tests across 1 binary (5869 tests skipped)
  SETUP PASS [   0.005s] ecstore-base-stack: sh -c 'echo RUST_MIN_STACK=4194304 >> "$NEXTEST_ENV"'
        PASS [   0.068s] rustfs-ecstore bucket::lifecycle::bucket_lifecycle_ops::tests::tier_free_version_recovery_eight_coordinators_hold_one_leader_and_take_over
        PASS [   0.637s] rustfs-ecstore store::bucket::tests::creation_commit_backfill_runs_under_the_config_write_fence
        PASS [   0.846s] rustfs-ecstore store::bucket::tests::orphaned_bucket_recovery_requires_every_volume_absent_and_is_retryable
     Summary [   0.987s] 3 tests run: 3 passed, 5869 skipped
Log SHA-256: b5da2a927ff18ca9aa217762f7186a6d4371bd9e8feedd7b77940e10b64dffac

Command:
cargo clippy -p rustfs -p rustfs-ecstore --all-targets --features rio-v2 -- -D warnings
Exit 0; wall 1084.508s.
Observed output:
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 18m 03s
Log SHA-256: 28f98be7970faaa71cd118da1da4e6e2e3d23b9dda7e6449eaa7a37e741260b5

Compiled mutation command (unchanged for each red and restored run):
cargo nextest run --profile ci -p rustfs-ecstore --lib --features rio-v2 -E 'test(=bucket::lifecycle::bucket_lifecycle_ops::tests::tier_free_version_recovery_production_entrypoint_enqueues_seeded_item)' --no-fail-fast

M1: reverse only this test-local constructor flag from false to true. The mutant compiled, then failed the original recovered-item queue assertion after 30.481s. Restoring the entire observed candidate passed in 0.460s. Red log 55bf3b1535529ac0bcfb8071f9b56f9f40631007a85c315367e7e93786d65293; restored log 204d5fbe4574a7917f5e740a795d864fe28a7e7fb5e33d27b0a9cf68e2f17f52.

M2: replace only the actual awaited enqueue with false, consuming its original inputs. The mutant compiled, then failed the same original queue assertion after 30.516s. Restoring the entire observed candidate passed in 0.457s. Red log 89186330413215e231e2b06bf013cc31097ea8f4a106d91421a36d6c8986a7fd; restored log e848b42d2302401afa5dbcd9e37bf76d2e56a96ab6de5a488513b997f53c5e9b.

All temporary observation and mutation code was removed before final acceptance. Historical baseline and diagnostic failures remain recorded; they are not mutation credit. The separate Object Lock intent-retry diagnostic still fails, and these native macOS checks do not establish Linux CI recovery.
2026-10-09 19:29:50 +08:00
overtrue 1d5a50f094 fix: remove redundant pending closure in disk test
Pass the capture-free pending future factory as a function item in the existing slow-operation test. This fixes the redundant_closure error at disk_store.rs:2914 that stopped strict Clippy before the feature tests could run.

The single-line test edit preserves the factory's result, warning and timeout behavior. Reversing the replacement reproduces the parent file byte for byte. All 220 assertion lines and the production prefix are unchanged; no tests, assertions, guards, profiles or baselines were added or relaxed.

Original Linux CI evidence (run 37888552268 at 53245be9f):
- RIO job113685483992: strict Clippy exit101, redundant closure at disk_store.rs:2914; feature tests skipped.
- Workspace Test and Lint job113685484058: same strict Clippy exit101; nextest and doc tests skipped.
These are lint failures, not runtime mutation kills or known flakes.

Native macOS arm64 validation on tree7a5bf47e7533b29479bc85207416102f1337c566, LANG=en_US.UTF-8, one build job, CARGO_INCREMENTAL=0 and offline dependencies:

shellcheck --version && actionlint -> exit 0
cargo fmt --all --check -> exit 0
./scripts/check_unsafe_code_allowances.sh -> exit 0
./scripts/check_layer_dependencies.sh -> exit 0
./scripts/check_architecture_migration_rules.sh -> exit 0
./scripts/check_logging_guardrails.sh -> exit 0
./scripts/check_error_other_format_ratchet.sh -> exit 0
./scripts/check_no_tokio_io_uring.sh -> exit 0
./scripts/check_extension_schema_boundaries.sh -> exit 0
./scripts/check_body_cache_whitelist.sh -> exit 0
./scripts/check_s3s_footprint.sh -> exit 0
./scripts/check_test_count_ratchet.sh -> exit 0
./scripts/check_fips_wording.sh -> exit 0
./scripts/check_embedded_secrets.sh -> exit 0
make script-tests -> exit 0
python3 ./scripts/test_object_generation_protocol_model.py -> exit 0
python3 ./scripts/check_test_wiring.py -> exit 0
./scripts/check_no_planning_docs.sh -> exit 0
./scripts/check_uring_lane_lib_only.sh -> exit 0
All 19 checks: exit0, 312.161s.

$ cargo clippy -p rustfs -p rustfs-ecstore --all-targets --features rio-v2 -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 20m 11s
exit0, 1213.210s total.

$ cargo nextest run --profile ci -p rustfs-ecstore --features rio-v2 slow_disk_operation_warns_once_while_pending_and_preserves_result --no-fail-fast
Finished `test` profile [unoptimized + debuginfo] target(s) in 4m 34s
PASS [0.026s] rustfs-ecstore disk::disk_store::tests::slow_disk_operation_warns_once_while_pending_and_preserves_result
Summary [   0.170s] 1 test run: 1 passed, 5943 skipped
exit0, 281.920s total; 5943 existing filter skips.

warning: linker stderr: ld: __eh_frame section too large (max 16MB) to encode dwarf unwind offsets in compact unwind table, performance of exception handling might be affected
This linker warning is retained; flags, profiles and allowances are unchanged.

54 tracked Cargo.toml files parsed without duplicate keys. git diff --check passed. No new assertions were introduced, so no new runtime mutation is claimed. Native compilation and the existing helper test do not substitute for actual Linux RIO execution; the new integration CI run still needs to recover before the RPC merge.

Preservation and output hashes:
parent file SHA256: 8e59ee745e3aaaa22848b943d3b10f6353b515956282cde1f3af2c394200c9ac
final file SHA256: b69ba3237061b161448ae8b62b615885d5770b98a5b4a2479bcfbd70f1bd1f17
unchanged production prefix SHA256: 7903a6e288252c420231242d7b58a25fa2a7140ea3dd430cbe7f0dde11369dcb
RIO Linux failure log SHA256:421addb9868fd88e4109a922311e54f91f0dfd70862f8ba7fcaba193482ed90b
Workspace Linux failure log SHA256:e0aea8d0f014c022252a9534968e083c98cfc1fd760da445ecd04ec3f522e26a
19 output SHA256:35a54f28d707956ed1edb29d492c4dfe8a9fe753d103b111b5a2f1b5c41c2b98
RIO Clippy output SHA256:d6046e3868f2b3992fe11cdd04e9e98eb50a87d1234d9a70dbfeb154ff61638d
slow-operation output SHA256:605b7b258d2fd09c6ef2ab2ffc90d433d0509480f1e45125d20c823759e83608

Refs rustfs/backlog#2734.
2026-10-09 14:44:39 +08:00
overtrue 53245be9f4 fix: repair integration checks and IPC test readiness
Wait for the RPC/locks test sockets to pass the existing owner and mode
checks inside the original 5s readiness window and 10ms poll interval.

Use the existing admin S3 carrier for the new recovery and quota error
calls. Regenerate the test-count baseline for main's 118 existing tests
across seven crates. Pair the private pagination helper's raw-scan inputs
and remove the redundant Copy clone from the retirement event.

Keep the original assertions, responses, authorization, locks and storage
operations. The pagination body and raw-scan expressions at all five calls
are byte-identical; reinserting only the Copy clone restores the entire
base heal file. All ignored baseline values and s3s counts stay unchanged.

Validation base: c47432e353
Validation tree: f081084bc5
Patch SHA-256: 2dcf0028691bfb2772edfb38e262829b04f4151832dcce823c9dd9f7434b52de
Trace production-prefix SHA-256: fd994f218a21429d62866f4efb8eee1ee57b58f4a51865aa35d05a54ef1ccb45

All commands used LANG=en_US.UTF-8, CARGO_BUILD_JOBS=1,
CARGO_INCREMENTAL=0 and CARGO_NET_OFFLINE=true in one exclusive target.
Every gate retained the same tree and six source hashes before and after.
54 Cargo.toml files parse without duplicate keys.

cargo clippy -p rustfs --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 12m 50s
Exit: 0. Wall time: 770.855s.

The original 19 quick-check steps:
shellcheck --version && actionlint -> exit 0
cargo fmt --all --check -> exit 0
./scripts/check_unsafe_code_allowances.sh -> exit 0
./scripts/check_layer_dependencies.sh -> exit 0
./scripts/check_architecture_migration_rules.sh -> exit 0
./scripts/check_logging_guardrails.sh -> exit 0
./scripts/check_error_other_format_ratchet.sh -> exit 0
./scripts/check_no_tokio_io_uring.sh -> exit 0
./scripts/check_extension_schema_boundaries.sh -> exit 0
./scripts/check_body_cache_whitelist.sh -> exit 0
./scripts/check_s3s_footprint.sh -> exit 0
./scripts/check_test_count_ratchet.sh -> exit 0
./scripts/check_fips_wording.sh -> exit 0
./scripts/check_embedded_secrets.sh -> exit 0
make script-tests -> exit 0
python3 ./scripts/test_object_generation_protocol_model.py -> exit 0
python3 ./scripts/check_test_wiring.py -> exit 0
./scripts/check_no_planning_docs.sh -> exit 0
./scripts/check_uring_lane_lib_only.sh -> exit 0
Wall time: 286.337s.

cargo nextest run --profile ci -p rustfs --no-fail-fast
     Summary [ 217.017s] 5382 tests run: 5382 passed (4 leaky), 40 skipped
Exit: 0. Wall time: 1324.414s.

cargo nextest run --profile ci -p rustfs-s3-types -p rustfs-protocols --features rustfs-protocols/swift --no-fail-fast
     Summary [   2.189s] 543 tests run: 543 passed, 0 skipped
Exit: 0. Wall time: 123.192s.

cargo nextest run --profile ci -p rustfs-ecstore list_objects_paginate --no-fail-fast
     Summary [   0.170s] 8 tests run: 8 passed, 5921 skipped
Exit: 0. Wall time: 261.324s.

cargo nextest run --profile ci -p rustfs-heal durable_mrf_anchor_retires_only_after_exact_bucket_generation_is_deleted --no-fail-fast
     Summary [   0.805s] 1 test run: 1 passed, 835 skipped
Exit: 0. Wall time: 199.801s.

Baseline regeneration:
./scripts/check_test_count_ratchet.sh --update
wrote .config/test-count-baseline.txt: 52 crates, 21340 tests, 164 ignored
Test-only increases: ecstore48, heal3, iam14, io-metrics2, obs3, policy14,
rustfs34. Existing ignored values and all other rows are byte-identical.
s3s footprint OK: files importing s3s is 195 (baseline files=195)
s3s footprint OK: s3s s3_error! lines is 1584 (baseline s3_error_lines=1584)
s3s footprint OK: ecstore files referencing s3s is 36 (baseline ecstore_files=36)

Historical runtime red controls on f622 (same retained two assertions):
cargo nextest run --profile ci -p rustfs --lib -E 'test(=connect::diagnostics::trace_runtime::tests::local_top_rpc_reads_service_http_completions_and_signs_offline) | test(=connect::diagnostics::trace_runtime::tests::local_top_locks_reads_service_manager_and_signs_offline)' --no-fail-fast
Original path readiness with a temporary 500ms bind/seal gap:
     Summary [   0.863s] 2 tests run: 0 passed, 2 failed, 5113 skipped
Exit: 100.
Sealed readiness in that same gap:
     Summary [   5.621s] 2 tests run: 2 passed, 5113 skipped
Exit: 0.
Compiled M1: replace the helper predicate with path.exists():
     Summary [   0.870s] 2 tests run: 0 passed, 2 failed, 5113 skipped
Exit: 100.
Restore the sealed predicate byte-for-byte:
     Summary [   5.640s] 2 tests run: 2 passed, 5113 skipped
Exit: 0.
Both reds observe mode755 with owner_matches=true and fail at the original
RPC/locks unwraps with StateSecurity. M1 failure locations: trace_runtime.rs
2547:29 and 2713:29. No new assertions were introduced.

cargo nextest run --profile ci -p rustfs --lib -E 'test(connect::diagnostics::trace_runtime::tests::)' --no-fail-fast
     Summary [  20.748s] 28 tests run: 28 passed (1 leaky), 5087 skipped
Exit: 0. This security sweep is historical; the full final unit gate above
covers the actual c474 candidate.
The first disk-stopped compile ran no tests and is excluded from red credit.
All temporary seal instrumentation is removed from the final source.

Final unit cleanup markers: 4 leaky, 40 original skips (exit0). The ld
__eh_frame linker warning also appears verbatim in the original f622 run
and the earlier c474 run; there are no new source warnings.
2026-10-09 13:09:50 +08:00
rustfs-cla-assistant[bot] c47432e353 Merge remote-tracking branch 'origin/main' into gateway/integration 2026-10-09 02:20:19 +00:00
overtrue f622c1bce0 fix(test): compare legacy body wire parity as raw bytes
Lossy UTF-8 comparison concealed a changed binary response byte.
Compare the already captured Vec<u8> values directly.

Validation:
- Binary mutant: migrated payload 0x84 vs legacy 0x83; old comparator
  passed 1/1, raw comparator failed 0/1 (exit 100); restored green.
- Non-Swift body-drain mutant: untouched-body delegation test failed
  with empty vs payload (exit 100); restored handler without a diff.
- cargo nextest run --profile ci -p rustfs-s3-types -p rustfs-protocols
  --features rustfs-protocols/swift --no-fail-fast:
  543 tests run, 543 passed, 0 skipped after both mutants restored.
- cargo fmt --all --check and git diff --check passed.

Orchestrator acceptance (LANG=en_US.UTF-8):
cargo nextest run --profile ci -p rustfs-s3-types -p rustfs-protocols --features rustfs-protocols/swift --no-fail-fast
Summary [2.445s] 543 tests run: 543 passed, 0 skipped.

All shared quick checks on the final code tree:
shellcheck --version && actionlint -> exit 0
cargo fmt --all --check -> exit 0
./scripts/check_unsafe_code_allowances.sh -> exit 0
./scripts/check_layer_dependencies.sh -> exit 0
./scripts/check_architecture_migration_rules.sh -> exit 0
./scripts/check_logging_guardrails.sh -> exit 0
./scripts/check_error_other_format_ratchet.sh -> exit 0
./scripts/check_no_tokio_io_uring.sh -> exit 0
./scripts/check_extension_schema_boundaries.sh -> exit 0
./scripts/check_body_cache_whitelist.sh -> exit 0
./scripts/check_s3s_footprint.sh -> exit 0
./scripts/check_test_count_ratchet.sh -> exit 0
./scripts/check_fips_wording.sh -> exit 0
./scripts/check_embedded_secrets.sh -> exit 0
make script-tests -> exit 0
python3 ./scripts/test_object_generation_protocol_model.py -> exit 0
python3 ./scripts/check_test_wiring.py -> exit 0
./scripts/check_no_planning_docs.sh -> exit 0
./scripts/check_uring_lane_lib_only.sh -> exit 0

Final independent acceptance after the drive-test CI repair
Parent: a99d8f4f89
Tested code tree: 93cbd96bf0

Tested tree: 075ae5161c2b62a96812bc1e3c904a7663b4f2f8
shellcheck --version && actionlint -> exit 0
cargo fmt --all --check -> exit 0
./scripts/check_unsafe_code_allowances.sh -> exit 0
./scripts/check_layer_dependencies.sh -> exit 0
./scripts/check_architecture_migration_rules.sh -> exit 0
./scripts/check_logging_guardrails.sh -> exit 0
./scripts/check_error_other_format_ratchet.sh -> exit 0
./scripts/check_no_tokio_io_uring.sh -> exit 0
./scripts/check_extension_schema_boundaries.sh -> exit 0
./scripts/check_body_cache_whitelist.sh -> exit 0
./scripts/check_s3s_footprint.sh -> exit 0
./scripts/check_test_count_ratchet.sh -> exit 0
./scripts/check_fips_wording.sh -> exit 0
./scripts/check_embedded_secrets.sh -> exit 0
make script-tests -> exit 0
python3 ./scripts/test_object_generation_protocol_model.py -> exit 0
python3 ./scripts/check_test_wiring.py -> exit 0
./scripts/check_no_planning_docs.sh -> exit 0
./scripts/check_uring_lane_lib_only.sh -> exit 0

$ LANG=en_US.UTF-8 CARGO_BUILD_JOBS=1 CARGO_INCREMENTAL=0 cargo nextest run --profile ci -p rustfs-s3-types -p rustfs-protocols --features rustfs-protocols/swift --no-fail-fast
    Finished `test` profile [unoptimized + debuginfo] target(s) in 10m 08s
 Nextest run ID 5c7ff102-ec6d-479a-86e0-810859b28bbf with nextest profile: ci
    Starting 543 tests across 8 binaries
     Summary [   6.729s] 543 tests run: 543 passed, 0 skipped
exit_code=0

The only source change is the raw-byte wire comparator. Cargo manifests and the ratchet baselines remain unchanged from the independently validated parent. The invalid-byte and consumed-request mutations remain recorded above; their implementation changes were restored.
2026-10-09 08:42:46 +08:00
overtrue a99d8f4f89 test(connect): restore one-second drive request budgets
Apply the exact test-only repair already landed on main in 5972a09cc3. The filesystem probe and production CLI success test request one second and keep their existing one-second duration and parameter checks. All outcome, I/O, error, cleanup and resource-limit assertions remain.

Scope: rustfs/tests/connect_perf_drive.rs only. Patch-id: cb0a1dfc8f68a67727525adea7458e2cee7d09f8.

Validation environment: LANG=en_US.UTF-8, CARGO_BUILD_JOBS=1, CARGO_INCREMENTAL=0, exclusive APFS-cloned CARGO_TARGET_DIR.

Quick Checks: every command from .github/actions/quick-checks/action.yml, with captured output and exit status below.

$ shellcheck --version && actionlint
ShellCheck - shell script analysis tool
version: 0.11.0
license: GNU General Public License, version 3
website: https://www.shellcheck.net
exit_code=0

$ cargo fmt --all --check
exit_code=0

$ ./scripts/check_unsafe_code_allowances.sh
exit_code=0

$ ./scripts/check_layer_dependencies.sh
Layer dependency guard passed (no new reverse dependencies/cycles).
exit_code=0

$ ./scripts/check_architecture_migration_rules.sh
Architecture migration rules passed.
exit_code=0

$ ./scripts/check_logging_guardrails.sh
✅ Logging guardrails check passed
exit_code=0

$ ./scripts/check_error_other_format_ratchet.sh
error(format!) ratchet passed (total call sites: 582).
exit_code=0

$ ./scripts/check_no_tokio_io_uring.sh
exit_code=0

$ ./scripts/check_extension_schema_boundaries.sh
Extension schema boundaries passed.
exit_code=0

$ ./scripts/check_body_cache_whitelist.sh
Body-cache whitelist guard passed.
exit_code=0

$ ./scripts/check_s3s_footprint.sh
s3s footprint OK: files importing s3s is 195 (baseline files=195)
s3s footprint OK: s3s s3_error! lines is 1584 (baseline s3_error_lines=1584)
s3s footprint OK: ecstore files referencing s3s is 36 (baseline ecstore_files=36)
✅ s3s footprint baseline check passed
exit_code=0

$ ./scripts/check_test_count_ratchet.sh
test-count ratchet OK: 52 crates, 21222 tests, 164 ignored match .config/test-count-baseline.txt
exit_code=0

$ ./scripts/check_fips_wording.sh
FIPS wording guard passed (README.md and CHANGELOG.md contain no forbidden claims).
KMS wording guard passed (crates/kms claims no Vault KV2 Transit wrapping).
exit_code=0

$ ./scripts/check_embedded_secrets.sh
Embedded secret guard passed (no private key material or provider credential literal in the tree).
exit_code=0

$ make script-tests
Running script tests...
entrypoint credential policy tests passed
internode grpc A/B bench env tests passed
object batch benchmark enhanced tests passed
PASS package service script contract
hotpath warp A/B gate tests passed
hotpath warp ABBA tests passed
Scanner validation artifacts written to /var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.1pFe6Kl1Yu/out
Scanner validation artifacts written to /var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.1pFe6Kl1Yu/out-missing-pid
.............................
----------------------------------------------------------------------
Ran 29 tests in 181.286s

OK
{"decision":"verified","pending_gates":["G01","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G02"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"R-E"}
{"decision":"verified","pending_gates":["G01","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G02"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"R-E"}
{"decision":"verified","pending_gates":["G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G01"}
{"decision":"verified","pending_gates":["G01","G02","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G03"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"R-L"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G14"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G14"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G10"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"P1"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"P2"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"P3"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G05"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G06"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"R-D"}
Status-and-outcome release descriptor verified: /private/var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp8rwn1pe0/descriptor/release-bundle-status-outcome.json
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G05"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G06"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"R-D"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G07"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G09","G10","G11","G12","G13","G14","P1","P2","P3","P4","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"G08"}
{"decision":"verified","pending_gates":["G01","G02","G03","G04","G05","G06","G07","G08","G09","G10","G11","G12","G13","G14","P1","P2","P3","R-D","R-E","R-L"],"pending_lanes":["authority-coverage","checkpoint-and-crash","ec8-4-multiset","maintenance-producers","mixed-version-rollback","mrf-responsibility","scheduler-pressure","status-and-outcome"],"rejected_errors":[],"rejected_gate":null,"release_approved":false,"release_schema_capable":true,"schema":1,"verified_gate":"P4"}
exact 1MiB handoff ABBA tests passed
pinned paired ABBA bench tests passed
==> /var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.mYmuI01hNq/bin/path_containment (-max_total_time=7, -seed=123456789, -artifact_prefix=/var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.mYmuI01hNq/explicit-artifacts/path_containment/, corpus=/private/tmp/gw-orchestrator-2734/ci-drive/fuzz/corpus/path_containment)
-seed=123456789
target=path_containment
seed=123456789
max_total_time=7
git_revision=4d15b816236630b2c42f321ffc9ed3654edc94e3
git_dirty=true
runner_mode=prebuilt
==> /var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.mYmuI01hNq/bin/path_containment (-max_total_time=1, -seed=2322617706, -artifact_prefix=/var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.mYmuI01hNq/auto-artifacts/path_containment/, corpus=/private/tmp/gw-orchestrator-2734/ci-drive/fuzz/corpus/path_containment)
-seed=2322617706
==> cargo +nightly fuzz run path_containment (-max_total_time=9, -seed=987654321, -artifact_prefix=/var/folders/0w/s4wxsn2n4w9b6f3cd4xrz53w0000gn/T/tmp.mYmuI01hNq/cargo-artifacts/path_containment/)
+nightly
fuzz
run
path_containment
-seed=987654321
seed=987654321
runner_mode=cargo-fuzz
fuzz runner seed manifest tests passed
✅ scripts/python_bin.sh resolver checks passed
self-test ok: clean fixture with every exemption present passes
self-test ok: all 11 pattern families fire
self-test ok: moving a pinned source is reported
Embedded secret guard self-test passed.
self-test ok: p1-s3s-import: 'use s3s::s3_error;' counts every line, the rustfs_s3_types module's too (s3_error_lines=3)
self-test ok: p2-s3s-mixed-tree: a multi-line s3s use tree naming s3_error counts (s3_error_lines=3)
self-test ok: p3-s3s-glob: a crate-root glob of s3s, bare or inside a tree, counts (s3_error_lines=5)
self-test ok: p4-macro-use: '#[macro_use] extern crate s3s' counts (s3_error_lines=3)
self-test ok: p5-qualified-s3s: a qualified s3s::s3_error! line counts in a cleared file (s3_error_lines=2)
self-test ok: p6-exact-pass: a baseline equal to the tree passes (exit 0)
self-test ok: n1-rustfs-import: 'use rustfs_s3_types::s3_error;' alone counts nothing (s3_error_lines=1)
self-test ok: n2-rustfs-mixed-tree: a rustfs_s3_types tree plus an s3s tree without the macro counts nothing (s3_error_lines=1)
self-test ok: n3-defines: the file defining the macro counts nothing (s3_error_lines=1)
self-test ok: n4-qualified-rustfs: a qualified rustfs_s3_types::s3_error! line counts nothing (s3_error_lines=1)
self-test ok: n5-renamed-call: a call through a renamed macro is not text-matched (out of scope) (s3_error_lines=1)
self-test ok: n6-comment-string: a comment or string mentioning s3_error! in a cleared file counts nothing (s3_error_lines=1)
self-test ok: n7-e2e-excluded: crates/e2e_test is excluded (s3_error_lines=1)
self-test ok: n8-super-glob: an unrecognised import form ('use super::*;') counts (s3_error_lines=3)
self-test ok: n9-facade: a crate-local re-export counts (s3_error_lines=2)
self-test ok: n10-renamed-import: a renamed rustfs_s3_types import does not clear s3_error! lines (s3_error_lines=2)
self-test ok: n11-commented-import: a commented-out rustfs_s3_types import does not clear (s3_error_lines=2)
self-test ok: n12-rustfs-glob: a glob import of rustfs_s3_types does not clear (s3_error_lines=2)
self-test ok: n13-comment-only: a comment mentioning s3_error! in a file with no import counts (s3_error_lines=2)
self-test ok: f1-baseline-missing: a missing baseline file fails (exit 1)
self-test ok: f2-key-missing: a baseline without s3_error_lines fails (exit 1)
self-test ok: f3-rg-fails: a failing classification search fails the guard (exit 1)
✅ s3s footprint self-test passed
test_core_gate_rejects_missing_ignored_filtered_and_corrupt_inputs (__main__.SelfTests.test_core_gate_rejects_missing_ignored_filtered_and_corrupt_inputs) ... ok
test_e2e_requires_registration (__main__.SelfTests.test_e2e_requires_registration) ... ok
test_fuzz_runtime_uses_matrix_target (__main__.SelfTests.test_fuzz_runtime_uses_matrix_target) ... ok
test_ilm_lane_keeps_the_measured_cargo_build_budget (__main__.SelfTests.test_ilm_lane_keeps_the_measured_cargo_build_budget) ... ok
test_profile_listing_binds_platform_digest (__main__.SelfTests.test_profile_listing_binds_platform_digest) ... ok
test_profile_listing_enforces_selection (__main__.SelfTests.test_profile_listing_enforces_selection) ... ok
test_quick_checks_commands_propagate_failure (__main__.SelfTests.test_quick_checks_commands_propagate_failure) ... ok
test_quick_checks_rejects_caller_and_execution_bypasses (__main__.SelfTests.test_quick_checks_rejects_caller_and_execution_bypasses) ... ok
test_runner_readiness_fails_closed (__main__.SelfTests.test_runner_readiness_fails_closed) ... ok
test_s3_runner_rejects_unbounded_failure_locals (__main__.SelfTests.test_s3_runner_rejects_unbounded_failure_locals) ... ok
test_scanner_heal_begin_requires_embedded_source_provenance (__main__.SelfTests.test_scanner_heal_begin_requires_embedded_source_provenance) ... ok
test_scanner_heal_case_does_not_approve_pending_release (__main__.SelfTests.test_scanner_heal_case_does_not_approve_pending_release) ... ok
test_scanner_heal_case_lane_is_required_for_runner_profile (__main__.SelfTests.test_scanner_heal_case_lane_is_required_for_runner_profile) ... ok
test_scanner_heal_case_only_schema_cannot_approve_release (__main__.SelfTests.test_scanner_heal_case_only_schema_cannot_approve_release) ... ok
test_scanner_heal_crash_case_rejects_restart_oracle (__main__.SelfTests.test_scanner_heal_crash_case_rejects_restart_oracle) ... ok
test_scanner_heal_ec84_case_rejects_wrong_erasure_geometry (__main__.SelfTests.test_scanner_heal_ec84_case_rejects_wrong_erasure_geometry) ... ok
test_scanner_heal_finish_collects_oracles_from_registry (__main__.SelfTests.test_scanner_heal_finish_collects_oracles_from_registry) ... ok
test_scanner_heal_multipool_case_accepts_deferred_optional_outage_write (__main__.SelfTests.test_scanner_heal_multipool_case_accepts_deferred_optional_outage_write) ... ok
test_scanner_heal_pending_gate_cannot_map_to_implemented_lane (__main__.SelfTests.test_scanner_heal_pending_gate_cannot_map_to_implemented_lane) ... ok
test_scanner_heal_receipts_reject_reuse_and_missing_builds (__main__.SelfTests.test_scanner_heal_receipts_reject_reuse_and_missing_builds) ... ok
test_scanner_heal_rejects_boolean_fractional_and_out_of_geometry_integers (__main__.SelfTests.test_scanner_heal_rejects_boolean_fractional_and_out_of_geometry_integers) ... ok
test_scanner_heal_rejects_broken_execution_and_artifacts (__main__.SelfTests.test_scanner_heal_rejects_broken_execution_and_artifacts) ... ok
test_scanner_heal_rejects_copied_junit_and_wrong_suite_build (__main__.SelfTests.test_scanner_heal_rejects_copied_junit_and_wrong_suite_build) ... ok
test_scanner_heal_release_bundle_accepts_complete_measured_evidence (__main__.SelfTests.test_scanner_heal_release_bundle_accepts_complete_measured_evidence) ... ok
test_scanner_heal_release_bundle_assembler_copies_measured_artifacts (__main__.SelfTests.test_scanner_heal_release_bundle_assembler_copies_measured_artifacts) ... ok
test_scanner_heal_release_bundle_assembler_merges_measured_descriptors (__main__.SelfTests.test_scanner_heal_release_bundle_assembler_merges_measured_descriptors) ... ok
test_scanner_heal_release_bundle_assembler_rejects_duplicate_descriptor_gate (__main__.SelfTests.test_scanner_heal_release_bundle_assembler_rejects_duplicate_descriptor_gate) ... ok
test_scanner_heal_release_bundle_assembler_rejects_fixture_descriptor (__main__.SelfTests.test_scanner_heal_release_bundle_assembler_rejects_fixture_descriptor) ... ok
test_scanner_heal_release_bundle_assembler_rejects_hash_mismatch (__main__.SelfTests.test_scanner_heal_release_bundle_assembler_rejects_hash_mismatch) ... ok
test_scanner_heal_release_bundle_assembler_rejects_mixed_descriptor_revisions (__main__.SelfTests.test_scanner_heal_release_bundle_assembler_rejects_mixed_descriptor_revisions) ... ok
test_scanner_heal_release_bundle_enforces_topology_duration_profile_and_versions (__main__.SelfTests.test_scanner_heal_release_bundle_enforces_topology_duration_profile_and_versions) ... ok
test_scanner_heal_release_bundle_fixture_writer_is_not_release_evidence (__main__.SelfTests.test_scanner_heal_release_bundle_fixture_writer_is_not_release_evidence) ... ok
test_scanner_heal_release_bundle_gate_accepts_single_measured_gate (__main__.SelfTests.test_scanner_heal_release_bundle_gate_accepts_single_measured_gate) ... ok
test_scanner_heal_release_bundle_gate_rejects_missing_field (__main__.SelfTests.test_scanner_heal_release_bundle_gate_rejects_missing_field) ... ok
test_scanner_heal_release_bundle_gate_rejects_unknown_gate (__main__.SelfTests.test_scanner_heal_release_bundle_gate_rejects_unknown_gate) ... ok
test_scanner_heal_release_bundle_rejects_synthetic_or_missing_fields (__main__.SelfTests.test_scanner_heal_release_bundle_rejects_synthetic_or_missing_fields) ... ok
test_scanner_heal_release_bundle_requires_domain_evidence (__main__.SelfTests.test_scanner_heal_release_bundle_requires_domain_evidence) ... ok
test_scanner_heal_release_bundle_requires_field_provenance (__main__.SelfTests.test_scanner_heal_release_bundle_requires_field_provenance) ... ok
test_scanner_heal_release_bundle_requires_json_artifact_provenance (__main__.SelfTests.test_scanner_heal_release_bundle_requires_json_artifact_provenance) ... ok
test_scanner_heal_release_bundle_requires_mixed_version_field_roles (__main__.SelfTests.test_scanner_heal_release_bundle_requires_mixed_version_field_roles) ... ok
test_scanner_heal_release_bundle_requires_same_gate_measurement_window (__main__.SelfTests.test_scanner_heal_release_bundle_requires_same_gate_measurement_window) ... ok
test_scanner_heal_release_consumes_multiple_registry_oracles (__main__.SelfTests.test_scanner_heal_release_consumes_multiple_registry_oracles) ... ok
test_scanner_heal_release_matrix_lanes_remain_pending_without_real_evidence (__main__.SelfTests.test_scanner_heal_release_matrix_lanes_remain_pending_without_real_evidence) ... ok
test_scanner_heal_release_requirements_cannot_be_cleared (__main__.SelfTests.test_scanner_heal_release_requirements_cannot_be_cleared) ... ok
test_scanner_heal_release_status_rejects_focused_case_run (__main__.SelfTests.test_scanner_heal_release_status_rejects_focused_case_run) ... ok
test_scanner_heal_release_status_rejects_synthetic_case (__main__.SelfTests.test_scanner_heal_release_status_rejects_synthetic_case) ... ok
test_scanner_heal_required_evidence_fields_cannot_be_removed (__main__.SelfTests.test_scanner_heal_required_evidence_fields_cannot_be_removed) ... ok
test_scheduled_alerts_require_completion_watchdog (__main__.SelfTests.test_scheduled_alerts_require_completion_watchdog) ... ok
test_update_profile_selection_changes_only_requested_platform (__main__.SelfTests.test_update_profile_selection_changes_only_requested_platform) ... ok
test_validate_includes_quick_checks (__main__.SelfTests.test_validate_includes_quick_checks) ... ok
test_vault_tests_require_cross_process_serialization (__main__.SelfTests.test_vault_tests_require_cross_process_serialization) ... ok
test_workflow_readiness_requires_dependency_probe (__main__.SelfTests.test_workflow_readiness_requires_dependency_probe) ... ok

----------------------------------------------------------------------
Ran 52 tests in 14.301s

OK
e2e-full selection OK: 1 tests, sha256=29e30e6ed2ed38d9e5b0a7cdd9536abf5c719f7021a02b578ae1381563a3c273
...................................
----------------------------------------------------------------------
Ran 35 tests in 1.161s

OK
...................
----------------------------------------------------------------------
Ran 19 tests in 17.397s

OK
..........
----------------------------------------------------------------------
Ran 10 tests in 0.183s

OK
test_actual_selector_bootstrap_uses_base_policy_and_fails_closed (__main__.SelfTests.test_actual_selector_bootstrap_uses_base_policy_and_fails_closed) ... ok
test_documentation_paths_do_not_hide_build_or_fixture_changes (__main__.SelfTests.test_documentation_paths_do_not_hide_build_or_fixture_changes) ... ok
test_e2e_scope_keeps_production_and_shared_configuration_full (__main__.SelfTests.test_e2e_scope_keeps_production_and_shared_configuration_full) ... ok
test_e2e_shortcut_rejects_new_direct_renamed_and_target_dependencies (__main__.SelfTests.test_e2e_shortcut_rejects_new_direct_renamed_and_target_dependencies) ... ok
test_e2e_shortcut_traverses_implicit_path_dependencies (__main__.SelfTests.test_e2e_shortcut_traverses_implicit_path_dependencies) ... ok
test_event_contract_requires_complete_candidate_and_optional_lanes (__main__.SelfTests.test_event_contract_requires_complete_candidate_and_optional_lanes) ... ok
test_every_wrong_result_missing_job_or_selection_fails_closed (__main__.SelfTests.test_every_wrong_result_missing_job_or_selection_fails_closed) ... ok
test_full_e2e_gate_preserves_workflow_branch_and_event_scope (__main__.SelfTests.test_full_e2e_gate_preserves_workflow_branch_and_event_scope) ... ok
test_git_range_includes_deleted_source_and_rename_origins (__main__.SelfTests.test_git_range_includes_deleted_source_and_rename_origins) ... ok
test_job_ids_and_display_names_cannot_hide_validation (__main__.SelfTests.test_job_ids_and_display_names_cannot_hide_validation) ... ok
test_report_only_stack_lane_mirrors_e2e_smoke_outside_the_aggregate (__main__.SelfTests.test_report_only_stack_lane_mirrors_e2e_smoke_outside_the_aggregate) ... ok
test_repository_wiring_and_missing_dependency_regression (__main__.SelfTests.test_repository_wiring_and_missing_dependency_regression) ... ok
test_verify_command_preserves_failures (__main__.SelfTests.test_verify_command_preserves_failures) ... ok

----------------------------------------------------------------------
Ran 13 tests in 3.280s

OK
security coverage self-test passed
test_api_failures_preserve_other_evidence_and_never_enter_grace (__main__.SelfTests.test_api_failures_preserve_other_evidence_and_never_enter_grace) ... ok
test_attempt_outcome_does_not_replace_recent_success (__main__.SelfTests.test_attempt_outcome_does_not_replace_recent_success) ... ok
test_cancelled_attempt_cannot_refresh_expired_success (__main__.SelfTests.test_cancelled_attempt_cannot_refresh_expired_success) ... ok
test_cli_requires_the_repository_default_branch (__main__.SelfTests.test_cli_requires_the_repository_default_branch) ... ok
test_config_rejects_duplicate_and_invalid_entries (__main__.SelfTests.test_config_rejects_duplicate_and_invalid_entries) ... ok
test_freshness_boundaries (__main__.SelfTests.test_freshness_boundaries) ... ok
test_grace_requires_two_successful_queries_with_no_history (__main__.SelfTests.test_grace_requires_two_successful_queries_with_no_history) ... ok
test_invalid_api_evidence_fails_closed (__main__.SelfTests.test_invalid_api_evidence_fails_closed) ... ok
test_report_retains_every_workflow (__main__.SelfTests.test_report_retains_every_workflow) ... ok
test_requests_filter_schedule_default_branch_and_success_on_server (__main__.SelfTests.test_requests_filter_schedule_default_branch_and_success_on_server) ... ok

----------------------------------------------------------------------
Ran 10 tests in 0.051s

OK
..............................
----------------------------------------------------------------------
Ran 30 tests in 22.354s

OK
..........
----------------------------------------------------------------------
Ran 10 tests in 2.969s

OK
.................................
----------------------------------------------------------------------
Ran 33 tests in 0.160s

OK
Online functional runner labels: pf-testing
.......
----------------------------------------------------------------------
Ran 7 tests in 0.002s

OK
.......
----------------------------------------------------------------------
Ran 7 tests in 0.001s

OK
....
----------------------------------------------------------------------
Ran 4 tests in 0.128s

OK
...
----------------------------------------------------------------------
Ran 3 tests in 0.547s

OK
PASS: cold stampede script self-test
exit_code=0

$ python3 ./scripts/test_object_generation_protocol_model.py
test_a_recovery_barrier_cannot_choose_an_empty_value (__main__.ObjectGenerationProtocolModel.test_a_recovery_barrier_cannot_choose_an_empty_value) ... ok
test_all_bounded_two_proposer_interleavings_choose_at_most_one_value (__main__.ObjectGenerationProtocolModel.test_all_bounded_two_proposer_interleavings_choose_at_most_one_value) ... ok
test_an_unavailable_decision_quorum_cannot_choose_a_candidate (__main__.ObjectGenerationProtocolModel.test_an_unavailable_decision_quorum_cannot_choose_a_candidate) ... ok
test_counter_allocation_requires_persistence_and_is_consumed_once (__main__.ObjectGenerationProtocolModel.test_counter_allocation_requires_persistence_and_is_consumed_once) ... ok
test_counter_restart_burns_persisted_allocations_before_or_after_issue (__main__.ObjectGenerationProtocolModel.test_counter_restart_burns_persisted_allocations_before_or_after_issue) ... ok
test_crash_after_promise_before_reply_does_not_restore_an_older_ballot (__main__.ObjectGenerationProtocolModel.test_crash_after_promise_before_reply_does_not_restore_an_older_ballot) ... ok
test_duplicate_or_unconfigured_voters_cannot_form_a_quorum (__main__.ObjectGenerationProtocolModel.test_duplicate_or_unconfigured_voters_cannot_form_a_quorum) ... ok
test_empty_or_unobserved_minority_slot_can_retry_without_allocating_another_revision (__main__.ObjectGenerationProtocolModel.test_empty_or_unobserved_minority_slot_can_retry_without_allocating_another_revision) ... ok
test_equal_ballot_cannot_accept_different_bytes_and_lower_ballot_is_rejected (__main__.ObjectGenerationProtocolModel.test_equal_ballot_cannot_accept_different_bytes_and_lower_ballot_is_rejected) ... ok
test_forgetting_tombstone_authority_allows_an_aba_create (__main__.ObjectGenerationProtocolModel.test_forgetting_tombstone_authority_allows_an_aba_create) ... ok
test_issuing_before_persistence_reuses_a_ballot_after_restart (__main__.ObjectGenerationProtocolModel.test_issuing_before_persistence_reuses_a_ballot_after_restart) ... ok
test_lost_ack_and_restart_preserve_the_chosen_operation (__main__.ObjectGenerationProtocolModel.test_lost_ack_and_restart_preserve_the_chosen_operation) ... ok
test_minority_accepted_work_is_adopted_and_finished (__main__.ObjectGenerationProtocolModel.test_minority_accepted_work_is_adopted_and_finished) ... ok
test_omitting_highest_accepted_adoption_has_a_double_choice_counterexample (__main__.ObjectGenerationProtocolModel.test_omitting_highest_accepted_adoption_has_a_double_choice_counterexample) ... ok
test_quorum_choice_does_not_require_an_uncontacted_disk_to_learn_it (__main__.ObjectGenerationProtocolModel.test_quorum_choice_does_not_require_an_uncontacted_disk_to_learn_it) ... ok
test_recovery_failure_or_stale_expected_head_does_not_allocate_a_successor (__main__.ObjectGenerationProtocolModel.test_recovery_failure_or_stale_expected_head_does_not_allocate_a_successor) ... ok
test_replacing_voters_with_empty_state_can_choose_a_conflicting_value (__main__.ObjectGenerationProtocolModel.test_replacing_voters_with_empty_state_can_choose_a_conflicting_value) ... ok
test_skipping_predecessor_recovery_chooses_a_broken_revision_chain (__main__.ObjectGenerationProtocolModel.test_skipping_predecessor_recovery_chooses_a_broken_revision_chain) ... ok
test_stale_publication_rollback_and_gc_cannot_change_the_winner (__main__.ObjectGenerationProtocolModel.test_stale_publication_rollback_and_gc_cannot_change_the_winner) ... ok
test_superseded_operation_identity_cannot_be_reused_for_different_input (__main__.ObjectGenerationProtocolModel.test_superseded_operation_identity_cannot_be_reused_for_different_input) ... ok
test_superseded_operation_retry_returns_its_original_successor (__main__.ObjectGenerationProtocolModel.test_superseded_operation_retry_returns_its_original_successor) ... ok
test_tombstone_and_null_marker_payloads_do_not_reset_authority_revision (__main__.ObjectGenerationProtocolModel.test_tombstone_and_null_marker_payloads_do_not_reset_authority_revision) ... ok
test_tombstone_rejects_a_delayed_never_present_create (__main__.ObjectGenerationProtocolModel.test_tombstone_rejects_a_delayed_never_present_create) ... ok
test_unlearned_predecessor_is_recovered_before_the_second_slot (__main__.ObjectGenerationProtocolModel.test_unlearned_predecessor_is_recovered_before_the_second_slot) ... ok

----------------------------------------------------------------------
Ran 24 tests in 0.958s

OK
model: states=51023, transitions=167520, terminal=732, chosen_candidates=2
negative control: double-choice trace=((0, 'prepare', 0), (0, 'prepare', 1), (0, 'prepare', 2), (0, 'accept', 0), (0, 'accept', 1), (0, 'accept', 2), (1, 'prepare', 0), (1, 'prepare', 1), (1, 'prepare', 2), (1, 'accept', 0), (1, 'accept', 1), (1, 'accept', 2))
multi-slot round schedules: 640
exit_code=0

$ python3 ./scripts/check_test_wiring.py
OK: e2e modules, runner selection, fuzz matrices, profiles, scheduled alerts, and Quick Checks are wired
exit_code=0

$ ./scripts/check_no_planning_docs.sh
exit_code=0

$ ./scripts/check_uring_lane_lib_only.sh
OK: no 'uring_'-matching test functions under crates/ecstore/tests; --lib is safe
exit_code=0

Initial complete gate
$ cargo nextest run --profile ci -p rustfs --test connect_perf_drive --no-fail-fast
 Nextest run ID e07fc5b9-c6c8-4cdd-ae61-54839bf24437 with nextest profile: ci
    Starting 10 tests across 1 binary
        PASS [   0.016s] rustfs::connect_perf_drive cancellation_and_single_collector_leave_no_scratch
        PASS [   0.011s] rustfs::connect_perf_drive cleanup_failure_overrides_cancellation_and_remains_attributed
        PASS [   0.009s] rustfs::connect_perf_drive consent_and_resource_budgets_fail_before_scratch_io
        PASS [   0.009s] rustfs::connect_perf_drive invalid_roots_and_existing_scratch_fail_without_clobbering
        PASS [  16.950s] rustfs::connect_perf_drive production_cli_measures_and_signs_exact_binary_provenance
        PASS [   4.025s] rustfs::connect_perf_drive production_cli_rejects_missing_l1_consent_and_limits_before_artifacts
        PASS [   0.008s] rustfs::connect_perf_drive read_only_root_and_full_drive_errors_are_classified
        PASS [   0.015s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
        PASS [   0.007s] rustfs::connect_perf_drive runtime_timeout_and_full_drive_use_schema_valid_failed_reason
        PASS [   0.035s] rustfs::connect_perf_drive successful_result_has_signed_bounded_private_offline_export
────────────
     Summary [  21.087s] 10 tests run: 10 passed, 0 skipped
exit_code=0

Restored complete gate
$ cargo nextest run --profile ci -p rustfs --test connect_perf_drive --no-fail-fast
 Nextest run ID 233b7307-5361-4eb7-94d5-b384f17d2d6a with nextest profile: ci
    Starting 10 tests across 1 binary
        PASS [   0.009s] rustfs::connect_perf_drive cancellation_and_single_collector_leave_no_scratch
        PASS [   0.008s] rustfs::connect_perf_drive cleanup_failure_overrides_cancellation_and_remains_attributed
        PASS [   0.008s] rustfs::connect_perf_drive consent_and_resource_budgets_fail_before_scratch_io
        PASS [   0.008s] rustfs::connect_perf_drive invalid_roots_and_existing_scratch_fail_without_clobbering
        PASS [  19.518s] rustfs::connect_perf_drive production_cli_measures_and_signs_exact_binary_provenance
        PASS [   4.146s] rustfs::connect_perf_drive production_cli_rejects_missing_l1_consent_and_limits_before_artifacts
        PASS [   0.009s] rustfs::connect_perf_drive read_only_root_and_full_drive_errors_are_classified
        PASS [   0.018s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
        PASS [   0.009s] rustfs::connect_perf_drive runtime_timeout_and_full_drive_use_schema_valid_failed_reason
        PASS [   0.054s] rustfs::connect_perf_drive successful_result_has_signed_bounded_private_offline_export
────────────
     Summary [  23.787s] 10 tests run: 10 passed, 0 skipped
exit_code=0

Mutation M1: success_measurement reports max(actual elapsed, requested budget + 1), forcing 1001 ms for the one-second request. The retained duration assertion at rustfs/tests/connect_perf_drive.rs:105 fails.
$ cargo nextest run --profile ci -p rustfs --test connect_perf_drive --no-fail-fast -E 'test(real_local_write_read_is_measured_and_scratch_is_removed)'
info: experimental features enabled: setup-scripts
   Compiling rustfs v1.0.1 (/private/tmp/gw-orchestrator-2734/ci-drive/rustfs)
warning: linker stderr: ld: __eh_frame section too large (max 16MB) to encode dwarf unwind offsets in compact unwind table, performance of exception handling might be affected
  |
  = note: `#[warn(linker_messages)]` on by default

warning: `rustfs` (bin "rustfs") generated 1 warning
warning: `rustfs` (bin "rustfs-cli") generated 1 warning (1 duplicate)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 7m 06s
────────────
 Nextest run ID 9f618777-7bf6-4cbc-8803-dd7f50f449ed with nextest profile: ci
    Starting 1 test across 1 binary (9 tests skipped)
        FAIL [   0.016s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
  stdout ───

    running 1 test
    test real_local_write_read_is_measured_and_scratch_is_removed ... FAILED

    failures:

    failures:
        real_local_write_read_is_measured_and_scratch_is_removed

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.01s

  stderr ───

    thread 'real_local_write_read_is_measured_and_scratch_is_removed' (106986846) panicked at rustfs/tests/connect_perf_drive.rs:105:5:
    assertion failed: (1..=1_000).contains(&data.duration_millis)
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

────────────
     Summary [   0.017s] 1 test run: 0 passed, 1 failed, 9 skipped
        FAIL [   0.016s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
error: test run failed
exit_code=100

Mutation M2: target_parameters reports requested duration + 1. The in-process assertion at rustfs/tests/connect_perf_drive.rs:111 and CLI JSON assertion at rustfs/tests/connect_perf_drive.rs:527 both reject 1001 against 1000.
$ cargo nextest run --profile ci -p rustfs --test connect_perf_drive --no-fail-fast -E 'test(real_local_write_read_is_measured_and_scratch_is_removed) | test(production_cli_measures_and_signs_exact_binary_provenance)'
info: experimental features enabled: setup-scripts
   Compiling rustfs v1.0.1 (/private/tmp/gw-orchestrator-2734/ci-drive/rustfs)
warning: linker stderr: ld: __eh_frame section too large (max 16MB) to encode dwarf unwind offsets in compact unwind table, performance of exception handling might be affected
  |
  = note: `#[warn(linker_messages)]` on by default

warning: `rustfs` (bin "rustfs") generated 1 warning
warning: `rustfs` (bin "rustfs-cli") generated 1 warning (1 duplicate)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 7m 20s
────────────
 Nextest run ID b73d46ab-c910-4e1e-8063-7fc7e332ec15 with nextest profile: ci
    Starting 2 tests across 1 binary (8 tests skipped)
        FAIL [  13.968s] rustfs::connect_perf_drive production_cli_measures_and_signs_exact_binary_provenance
  stdout ───

    running 1 test
    test production_cli_measures_and_signs_exact_binary_provenance ... FAILED

    failures:

    failures:
        production_cli_measures_and_signs_exact_binary_provenance

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 9 filtered out; finished in 13.96s

  stderr ───

    thread 'production_cli_measures_and_signs_exact_binary_provenance' (107015462) panicked at rustfs/tests/connect_perf_drive.rs:527:5:
    assertion `left == right` failed
      left: Number(1001)
     right: 1000
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

        FAIL [   0.015s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
  stdout ───

    running 1 test
    test real_local_write_read_is_measured_and_scratch_is_removed ... FAILED

    failures:

    failures:
        real_local_write_read_is_measured_and_scratch_is_removed

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.01s

  stderr ───

    thread 'real_local_write_read_is_measured_and_scratch_is_removed' (107016667) panicked at rustfs/tests/connect_perf_drive.rs:111:5:
    assertion `left == right` failed
      left: 1001
     right: 1000
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

────────────
     Summary [  13.985s] 2 tests run: 0 passed, 2 failed, 8 skipped
        FAIL [  13.968s] rustfs::connect_perf_drive production_cli_measures_and_signs_exact_binary_provenance
        FAIL [   0.015s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
error: test run failed
exit_code=100

Transient production mutations were restored byte-for-byte before the complete green rerun. Original/restored SHA256: 8d389e6d8836c041aab8c6a93e56addd65ba3f70b33264e1c74f639d0572a2da.

$ git diff --check

exit_code=0

$ git diff --cached --check

exit_code=0

Independent orchestrator acceptance
Tested code tree: e67c72fb01

Tested tree: 16fbbd2ea4
shellcheck --version && actionlint -> exit 0
cargo fmt --all --check -> exit 0
./scripts/check_unsafe_code_allowances.sh -> exit 0
./scripts/check_layer_dependencies.sh -> exit 0
./scripts/check_architecture_migration_rules.sh -> exit 0
./scripts/check_logging_guardrails.sh -> exit 0
./scripts/check_error_other_format_ratchet.sh -> exit 0
./scripts/check_no_tokio_io_uring.sh -> exit 0
./scripts/check_extension_schema_boundaries.sh -> exit 0
./scripts/check_body_cache_whitelist.sh -> exit 0
./scripts/check_s3s_footprint.sh -> exit 0
./scripts/check_test_count_ratchet.sh -> exit 0
./scripts/check_fips_wording.sh -> exit 0
./scripts/check_embedded_secrets.sh -> exit 0
make script-tests -> exit 0
python3 ./scripts/test_object_generation_protocol_model.py -> exit 0
python3 ./scripts/check_test_wiring.py -> exit 0
./scripts/check_no_planning_docs.sh -> exit 0
./scripts/check_uring_lane_lib_only.sh -> exit 0

$ LANG=en_US.UTF-8 CARGO_BUILD_JOBS=1 CARGO_INCREMENTAL=0 cargo nextest run --profile ci -p rustfs --test connect_perf_drive --no-fail-fast
info: experimental features enabled: setup-scripts
warning: linker stderr: ld: __eh_frame section too large (max 16MB) to encode dwarf unwind offsets in compact unwind table, performance of exception handling might be affected
  |
  = note: `#[warn(linker_messages)]` on by default

warning: `rustfs` (bin "rustfs-cli") generated 1 warning
warning: `rustfs` (bin "rustfs") generated 1 warning (1 duplicate)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.69s
────────────
 Nextest run ID cd1edf4c-f1c0-456d-ad1a-76cc00ce05c9 with nextest profile: ci
    Starting 10 tests across 1 binary
        PASS [   0.012s] rustfs::connect_perf_drive cancellation_and_single_collector_leave_no_scratch
        PASS [   0.010s] rustfs::connect_perf_drive cleanup_failure_overrides_cancellation_and_remains_attributed
        PASS [   0.010s] rustfs::connect_perf_drive consent_and_resource_budgets_fail_before_scratch_io
        PASS [   0.009s] rustfs::connect_perf_drive invalid_roots_and_existing_scratch_fail_without_clobbering
        PASS [  20.328s] rustfs::connect_perf_drive production_cli_measures_and_signs_exact_binary_provenance
        PASS [   5.527s] rustfs::connect_perf_drive production_cli_rejects_missing_l1_consent_and_limits_before_artifacts
        PASS [   0.013s] rustfs::connect_perf_drive read_only_root_and_full_drive_errors_are_classified
        PASS [   0.019s] rustfs::connect_perf_drive real_local_write_read_is_measured_and_scratch_is_removed
        PASS [   0.011s] rustfs::connect_perf_drive runtime_timeout_and_full_drive_use_schema_valid_failed_reason
        PASS [   0.049s] rustfs::connect_perf_drive successful_result_has_signed_bounded_private_offline_export
────────────
     Summary [  25.991s] 10 tests run: 10 passed, 0 skipped

exit_code=0

All 54 tracked Cargo.toml files parse without duplicate keys. git diff --check passed. The production source remains unchanged; the two deliberate implementation mutations above were restored before this complete green run.
2026-10-09 08:21:15 +08:00
Chris 4d15b81623 refactor(protocols): move error types to rustfs-s3-types by codemod (#8439)
T1.2 batch 3 (rustfs/backlog#2743): s3select-api, s3select-query and
the error items of protocols move off s3s by scripts/codemods, run with
--hold crates/protocols/src/sftp/errors.rs. That file stays on s3s: it
downcasts the backend error, whose runtime type is still s3s::S3Error.

- rustfs/src/protocols/client.rs: the two webdav session methods now
  return rustfs_s3_types::S3Result and convert the s3s error with From.
- codemod: a child module that calls s3_error! through `use super::*`
  gets its own `use rustfs_s3_types::s3_error;` once its parent imports
  that macro by name; otherwise it is listed as GLOB.
- s3-types: a table test pins code, status and the s3s error the legacy
  edge renders for every variant a moved call site names.
- s3_error_lines 1585 -> 1584 (a lifecycle comment reworded).
2026-10-08 15:59:34 -07:00
Chris 836d30192f feat(s3-types): add Body::from_stream and move Swift off s3s::Body (#8438)
rustfs/backlog#2747 batch 3. `Body::from_stream` wraps a chunk stream of
unknown length over `StreamBody`/`BoxBody`: one data frame per chunk, the
first error ends the body, the size hint stays unknown, and dropping the
body drops the stream. Parity tests pin it to the s3s `StreamingBlob::wrap`
it replaces, at the `http_body` level and byte for byte through hyper.

The Swift handlers in rustfs-protocols build their responses as the owned
`Body`. `SwiftService` converts them into the wrapped S3 service's response
body type through `From<Body>`, so rustfs keeps serving `s3s::Body` at the
legacy edge unchanged. Request bodies stay Send-only (`UnsyncBoxBody`); the
two storage writers and the DLO/SLO segment streams get `Sync` from
`sync_wrapper::SyncStream`, which is what s3s's `http_body_unsync` mutex
provided before. The DTO and error uses of s3s in protocols are untouched
(T1.5 and T1.2).
2026-10-08 15:05:16 -07:00
Chris 860c61ee6d feat(app): add the RustFS-owned RequestEnvelope and its s3s constructor (#8437)
* feat(app): add the RustFS-owned RequestEnvelope and its s3s constructor

* ci: classify the s3s edge adapters in storage/s3_compat as interface
2026-10-08 11:58:55 -07:00
Chris f600af4704 test(e2e): compare two RUSTFS_S3_STACK servers over every S3 operation (#8435)
Add dual_stack_differential to e2e_test. It starts two rustfs processes
from the same binary, stack A on RUSTFS_S3_STACK=legacy and stack B on
RUSTFS_E2E_STACK_B (default legacy until rustfs/backlog#2734 T2.5),
sends both the same aws-sdk-s3 script covering the 73 methods of
impl S3 for FS (a normal request and a 4xx negative each), and compares
status, error code, an allowlist of response headers and a few typed
body fields. Error message text is never compared. Each run writes
<target>/dual-stack/<run>.json with compared_ops and the (op, field,
a, b) differences; any difference fails the test.

differential_detects_an_injected_difference starts B with
RUSTFS_REGION=eu-west-1 and requires GetBucketLocation to be reported.
The comparator is pure and unit-tested without a server.

Wire the module into the e2e-smoke filter and update the e2e-smoke and
e2e-full selection digests and the e2e_test test-count row.

Refs rustfs/backlog#2740
2026-10-08 10:47:10 -07:00
overtrue 9e747e8475 ci(footprint): count only s3_error! lines still on s3s's macro
s3_error_lines counted every line holding the text `s3_error!`, which
also matches the RustFS-owned `rustfs_s3_types::s3_error!`. A codemod
that moves call sites onto rustfs-s3-types therefore could not lower it
(rustfs/backlog#2743, decision 3; rustfs/rustfs#8432, gotcha 2).

The counter now applies a textual, per-file and per-line rule that errs
on the side of counting (full rule in the script header):
- occurrences spelled `rustfs_s3_types::s3_error!` never count;
- a line holding `s3s::s3_error!` always counts;
- any other `s3_error!` line counts unless its file is cleared, that is,
  it imports the macro from rustfs_s3_types by name on a line starting
  with the use item (or defines it with `macro_rules! s3_error`) and does
  not also bring s3s's macro in (`use s3s::s3_error`, a `use s3s::{..}`
  tree naming it or a crate-root `*`, `use s3s::*`, or
  `#[macro_use] extern crate s3s`);
- fail closed: a file matching neither form (`use super::*`, a
  crate-local re-export, a renamed or glob rustfs_s3_types import, a
  commented-out import, a comment-only mention) counts.

Census of the 1585 lines on 96fc06776: 1478 in 64 files that import the
macro from s3s; 107 in 15 files matching neither form (105 through
`use super::*`, 1 qualified `s3s::s3_error!`, 1 comment line); none in
files that import it from rustfs_s3_types or define it. Every line stays
counted, so the baseline remains s3_error_lines=1585 (files=202 and
ecstore_files=36 unchanged). Rewriting rustfs/src/auth.rs's import to
rustfs_s3_types lowers the new counter to 1567; the old one stayed 1585.

`--self-test` (wired into `make script-tests`) copies the script into
22 fixture trees: 6 positive cases and 16 negative ones (lines that must
not count, forms that must not clear a file, and a missing baseline,
missing key or failing classification search that must fail). Each tree
has a control line that must count, and each run gets s3s text on stdin.
Seven cases were red against the old counter. 19 mutants each turn their
case red: old definition, flipped import test, dropped fail-closed
branch, dropped e2e_test exclusion, dropped s3s veto, dropped qualified
s3s rule, dropped rustfs-qualified strip, unanchored rustfs import,
renamed import accepted, nested glob taken as root glob, single-line
s3s trees only, dropped s3s glob forms, dropped macro_use form, dropped
definition clearing, ignored classification rg errors, error-line search
without its path, classification searches without their path, missing
baseline skipped, missing key skipped.
2026-10-09 01:03:21 +08:00
Chris 96fc067765 refactor(ecstore): move S3ErrorCode to rustfs-s3-types by codemod (#8432)
* test(ecstore): pin the InvalidRange responses of new_getobjectreader

Both error branches of new_getobjectreader build an ErrorResponse with S3ErrorCode::InvalidRange, and no test observed either code. Pin the code, its wire name and the location fields of each branch before the code type moves to rustfs-s3-types (rustfs/backlog#2743), so a changed code on either branch fails a test. The ecstore test-count row rises by the two tests.

* chore(scripts): add the s3s-to-rustfs-s3-types error codemod

Task T1.2 of rustfs/backlog#2734 (rustfs/backlog#2743) moves S3Error, S3ErrorCode, S3Result and s3_error! from s3s to rustfs-s3-types by script, one crate closure per PR. The codemod rewrites use trees (splitting mixed s3s imports) and qualified code paths, never comments or literals, adds the rustfs-s3-types dependency, drops s3s only from a crate that no longer names it, refuses every file of the s3s edge allowlist, takes --hold for a file whose type is fixed outside the closure, and prints a per-crate census. A second run changes nothing. Its self-test runs under make script-tests.

* refactor(ecstore): take S3ErrorCode from rustfs-s3-types

Output of scripts/codemods/s3_error_to_s3_types.py over crates/ecstore, crates/lifecycle, crates/scanner and crates/replication (rustfs/backlog#2743 batches 1 and 2). The ErrorResponse code field, the two InvalidRange constructions in new_getobjectreader and an unused tier import now use rustfs_s3_types::S3ErrorCode; the variant names and wire names are unchanged. lifecycle, scanner and replication reference none of the four error names. warm_backend.rs and warm_backend_s3.rs are held: they compare against rustfs_s3_client::ErrorResponse.code, which stays the s3s type until s3-client moves.
2026-10-08 09:30:37 -07:00
Chris e809b4899e refactor(s3-types): own the HTTP Body and drop s3s from three crates (#8431)
Add rustfs_s3_types::Body, a BoxBody<Bytes, StdError> wrapper with
empty() and From<Bytes | Vec<u8> | String | &'static str>, and the
legacy From conversions to and from s3s::Body behind compat-s3s.

The signer is now generic over the request body: it only reads and
writes the request head, so it needs no body type and its callers keep
theirs. s3-client sends its requests with the owned Body, madmin signs a
bodiless head, and targets drops its two S3Request/S3Response header
wrappers in favour of extract_params_header.

rustfs-signer, rustfs-madmin and rustfs-targets no longer depend on
s3s; the s3s footprint baseline drops from 209 to 202 files.

Refs rustfs/backlog#2747, rustfs/backlog#2734
2026-10-08 08:43:06 -07:00
Chris 584f03f300 test(ecstore): reach the bucket-config codec through the test facade (#8428) 2026-10-08 07:12:19 -07:00
Chris d52d6fade7 ci: make the s3s footprint baseline exact and lower-only (#8403)
* ci: make the s3s footprint baseline exact and lower-only

The s3s footprint guard compared three counters against ceilings held in
the script itself, so a ceiling could sit above the tree and a drift was
fixable by raising it (rustfs/rustfs#5964 raised the s3_error! ceiling
to go green). The three values now live in
.config/s3s-footprint-baseline.txt as files, s3_error_lines and
ecstore_files, the script reads only that file, and a measurement that
differs from its baseline in either direction fails: growth prints
"s3s footprint grew: <measured> > <baseline>", shrinkage prints
"lower the baseline to <measured> in this PR". The counting method is
unchanged; the baseline is the current measurement of
gateway/integration (209 / 1585 / 36). The header records the end state:
once all three reach 0, T4.2 switches the script to failing on any
occurrence.

Refs rustfs/backlog#2739, rustfs/backlog#2734

* ci: add the s3s edge allowlist mode to the footprint guard (#8405)

`scripts/check_s3s_footprint.sh --mode allowlist` fails on every Rust
file that references s3s (`s3s::` or `s3s_sigv4`) and is not matched by
an entry of the new `.config/s3s-edge-allowlist.txt`; `--dry-run` lists
those files and exits 0. The allowlist carries the initial edge from the
spec, and the script rejects an entry that names or matches anything
under crates/ other than crates/e2e_test. The baseline mode and the
argument-less CI invocation are unchanged.

Refs rustfs/backlog#2741, rustfs/backlog#2734
2026-10-08 06:48:57 -07:00
Chris 3623d6db2d ci: raise the test-count baseline to the integration tree (#8426) 2026-10-08 06:48:40 -07:00
Chris 484f1254ca test(ecstore): pin the persisted bucket-config XML bytes for 13 families (#8408)
Before any DTO or codec is replaced, pin the exact bytes that
deserialize followed by serialize produces for every persisted
bucket-configuration XML family in its three source shapes (AWS
documentation, MinIO-written, RustFS-written), and the bytes RustFS
writes today for a typed value. Byte equality only: a structural
comparison would let a codec replacement change the persisted encoding
unnoticed.

The generator script refuses to overwrite existing goldens without
--force, refuses on dirty codec paths, cannot report success from its
write mode, and records the generating commit in the fixtures README.

Refs rustfs/backlog#2744, rustfs/backlog#2734
2026-10-08 21:25:56 +08:00
Chris c9c16efbb6 ci: add the per-crate test-count ratchet (#8404)
Quick Checks now fails any PR that lowers the number of test attributes
in a workspace crate or adds #[ignore], measured per crate against the
exact rows of .config/test-count-baseline.txt (rustfs/backlog#2734
section 1 rule 3). The counter widens the spec's literal
#[(tokio::)?test] to the tokio attributes that carry arguments and both
spellings of #[test_case(...)], and anchors at line start so
commented-out attributes do not count. The initial baseline covers 52
crates, 21077 tests and 164 ignored.

Refs rustfs/backlog#2738
Refs rustfs/backlog#2734
2026-10-08 21:25:42 +08:00
Chris f2a59073ca feat(s3-types): add the RustFS-owned S3 error type and s3_error! macro (#8406)
`rustfs-s3-types` now provides `S3ErrorCode` (generated by build.rs from
src/codes.txt, the grep-derived call surface, plus `Custom`), `S3Error`,
`S3Result`, `StdError` and the `s3_error` macro with the same call syntax
as s3s, so the T1.2 codemod is a `use` swap. Statuses are hand-written and
pinned to the s3s behaviour RustFS ships today by an oracle test that uses
s3s as a dev-dependency only. The `From` conversions for the legacy edge
live behind the off-by-default `compat-s3s` feature (the orphan rule
forbids them in rustfs/src/error.rs); `rustfs` enables it.

Refs rustfs/backlog#2742, rustfs/backlog#2734
2026-10-08 04:11:00 -07:00
Chris c1af94d1d1 refactor(server): group the s3s-compat tower layers under legacy_compat (#8410)
Move the ten tower layers that patch s3s behaviour out of
rustfs/src/server/layer.rs into rustfs/src/server/legacy_compat/, one file
per layer with its tests. Each file header names the s3s behaviour it
patches, the gateway mechanism that replaces it (Replaced by:), and the task
that removes it (Removed by: T2.12, rustfs/backlog#2771). The layers keep
their code, their order in external_service_stack!, and their behaviour; no
layer is deleted.

Add server::http::tests::stack_census, which renders the ordered service
chain of the real external_service_stack! expansion and compares it with a
committed constant, so a reorder, insertion or removal is a visible diff.

Route the two s3s error types the moved layers use through a
storage_api::server::legacy_compat shim so the split adds no s3s-importing
file, and lower the s3s footprint baselines to the measured values (files 209
to 208, s3_error! lines 1586 to 1585). Keep the server runtime-source bypass
guard covering the moved code.

Refs rustfs/backlog#2787, rustfs/backlog#2734
2026-10-08 02:57:47 -07:00
Chris f84bbfe28f feat(server): add the RUSTFS_S3_STACK selector and dual-stack e2e lane (#8411) 2026-10-07 21:01:39 -07:00
rustfs-cla-assistant[bot] 378a2ff7f8 Merge remote-tracking branch 'origin/main' into gateway/integration 2026-10-08 02:18:57 +00:00
rustfs-cla-assistant[bot] b88b53aa6a Merge remote-tracking branch 'origin/main' into gateway/integration 2026-10-07 21:18:17 +00:00
446 changed files with 8253 additions and 62289 deletions
-11
View File
@@ -31,14 +31,3 @@
# the flag, so the two can no longer drift apart unnoticed.
#
# For CPU profiling, add `-C force-frame-pointers=yes` to that RUSTFLAGS value.
# Exact internode HTTP/2 PING ACK timeout accounting is also deliberately
# default-off. Hyper exposes the exact timeout only through its unstable tracing
# event, so diagnostic builds must opt in to both the feature and cfg:
#
# RUSTFLAGS="--cfg hyper_unstable_tracing" \
# cargo build -p rustfs --features diagnostic-internode-http2-ping
#
# `crates/protos/build.rs` and `crates/obs/build.rs` fail fast if the feature and
# cfg drift apart. Do not move this cfg into global rustflags: doing so would
# recompile every dependency under an unstable, non-semver build contract.
-10
View File
@@ -1,10 +0,0 @@
# Rulings for the gateway conformance lane (.github/workflows/gateway-acceptance.yml).
#
# One row per case that fails on the GATEWAY stack for a reviewed reason: `case`; `ledger`, the
# rustfs/backlog#2684 entry that accepts the difference (R-0xx or K-n); a one-line `reason`; and
# `failure`, a prefix of the failure the ruling accepts, as the runner's report.json renders it
# (`[expect/status] at /expect/status: exchange #1, attempt 1: expected status 400, observed 403`).
# scripts/check_conformance_rulings.py fails the lane on a failed case without a row, on a ruled
# case whose failures do not start with its `failure`, and on a row whose case no longer fails or
# no longer exists. The legacy stack is a reference run and takes no rulings: the `rustfs` profile
# describes the gateway edge, not the legacy one.
-4
View File
@@ -39,8 +39,6 @@ script-tests: ## Run shell script tests
./scripts/test_entrypoint_directories.sh
./scripts/test_internode_grpc_ab_bench.sh
$(RUSTFS_PYTHON_BIN) ./scripts/test_internode_grpc_window.py
$(RUSTFS_PYTHON_BIN) ./scripts/test_internode_msgpack_peer_canary.py
./scripts/test_internode_msgpack_peer_canary_runner.sh
./scripts/test_object_batch_bench_enhanced.sh
./scripts/test_package_service_scripts.sh
./scripts/test_hotpath_warp_ab_gate.sh
@@ -103,8 +101,6 @@ script-tests: ## Run shell script tests
$(RUSTFS_PYTHON_BIN) ./scripts/test_junit_diff.py
$(RUSTFS_PYTHON_BIN) ./scripts/test_dual_stack.py
$(RUSTFS_PYTHON_BIN) ./scripts/test_mint_stack_diff.py
$(RUSTFS_PYTHON_BIN) ./scripts/check_conformance_rulings.py --self-test
$(RUSTFS_PYTHON_BIN) ./scripts/compat_matrix_report.py --self-test
$(RUSTFS_PYTHON_BIN) ./scripts/s3-tests/test_report_compat.py
$(RUSTFS_PYTHON_BIN) ./scripts/s3-tests/test_runner_tools.py
$(RUSTFS_PYTHON_BIN) ./scripts/s3-tests/test_api_coverage.py
-10
View File
@@ -99,11 +99,6 @@ threads-required = "num-test-threads"
filter = '(package(rustfs-ecstore) & (test(/^core::pools_test::decommission_lock_order_tests::(active_decommission_migration_does_not_invert_capacity_and_delete_object(_tag)?_locks|decommission_moves_a_transitioned_version_expired_by_a_delete_all_rule_without_stalling)$/) | test(=services::integrity::tests::audit_migration_and_ack_recovery_preserve_source_and_reject_conflicts))) | (package(rustfs-heal) & test(=heal::mrf_queue::partial_write::tests::durable_retry_submission_error_keeps_checkpoint_and_uses_backoff))'
threads-required = "num-test-threads"
# These eight-disk namespace-owner probes overlap durable cleanup with a lock contender. Reserve capacity so sibling disk fixtures cannot consume their lock and completion budgets.
[[profile.default.overrides]]
filter = 'package(rustfs-ecstore) & test(/^store::object::tests::(canceled_create_retains_usage_cleanup_namespace_owner|batch_delete_excludes_recovery_on_nonzero_pool|delete_excludes_recovery_with_(disjoint|identical|overlapping)_pool_lock_clients)$/)'
threads-required = "num-test-threads"
# These eight-disk decommission fixtures exercise concurrent retries,
# free-version cleanup, and real capacity probes under production lock deadlines.
# Reserve the run's capacity so unrelated IO cannot exhaust those budgets.
@@ -410,11 +405,6 @@ threads-required = "num-test-threads"
filter = '(package(rustfs-ecstore) & (test(/^core::pools_test::decommission_lock_order_tests::(active_decommission_migration_does_not_invert_capacity_and_delete_object(_tag)?_locks|decommission_moves_a_transitioned_version_expired_by_a_delete_all_rule_without_stalling)$/) | test(=services::integrity::tests::audit_migration_and_ack_recovery_preserve_source_and_reject_conflicts))) | (package(rustfs-heal) & test(=heal::mrf_queue::partial_write::tests::durable_retry_submission_error_keeps_checkpoint_and_uses_backoff))'
threads-required = "num-test-threads"
# These eight-disk namespace-owner probes overlap durable cleanup with a lock contender. Reserve capacity so sibling disk fixtures cannot consume their lock and completion budgets.
[[profile.ci.overrides]]
filter = 'package(rustfs-ecstore) & test(/^store::object::tests::(canceled_create_retains_usage_cleanup_namespace_owner|batch_delete_excludes_recovery_on_nonzero_pool|delete_excludes_recovery_with_(disjoint|identical|overlapping)_pool_lock_clients)$/)'
threads-required = "num-test-threads"
# These eight-disk decommission fixtures exercise concurrent retries,
# free-version cleanup, and real capacity probes under production lock deadlines.
# Reserve the run's capacity so unrelated IO cannot exhaust those budgets.
@@ -34,9 +34,6 @@ services:
- RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_UNSAFE_BYPASS_DISK_CHECK=${RUSTFS_UNSAFE_BYPASS_DISK_CHECK:-true}
- RUSTFS_DURABILITY_MODE=${RUSTFS_DURABILITY_MODE:-strict}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE:-false}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS:-0}
# Internode gRPC optimization knobs (grpc-optimization P0-P3). Defaults match the binary
# defaults, so leaving these unset is a no-op; the A/B driver exports them to toggle a stage.
- RUSTFS_INTERNODE_RPC_TCP_NODELAY=${RUSTFS_INTERNODE_RPC_TCP_NODELAY:-true}
@@ -84,9 +81,6 @@ services:
- RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_UNSAFE_BYPASS_DISK_CHECK=${RUSTFS_UNSAFE_BYPASS_DISK_CHECK:-true}
- RUSTFS_DURABILITY_MODE=${RUSTFS_DURABILITY_MODE:-strict}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE:-false}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS:-0}
# Internode gRPC optimization knobs (grpc-optimization P0-P3). Defaults match the binary
# defaults, so leaving these unset is a no-op; the A/B driver exports them to toggle a stage.
- RUSTFS_INTERNODE_RPC_TCP_NODELAY=${RUSTFS_INTERNODE_RPC_TCP_NODELAY:-true}
@@ -134,9 +128,6 @@ services:
- RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_UNSAFE_BYPASS_DISK_CHECK=${RUSTFS_UNSAFE_BYPASS_DISK_CHECK:-true}
- RUSTFS_DURABILITY_MODE=${RUSTFS_DURABILITY_MODE:-strict}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE:-false}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS:-0}
# Internode gRPC optimization knobs (grpc-optimization P0-P3). Defaults match the binary
# defaults, so leaving these unset is a no-op; the A/B driver exports them to toggle a stage.
- RUSTFS_INTERNODE_RPC_TCP_NODELAY=${RUSTFS_INTERNODE_RPC_TCP_NODELAY:-true}
@@ -184,9 +175,6 @@ services:
- RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_OBJECT_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_LOCK_ACQUIRE_TIMEOUT=${RUSTFS_LOCK_ACQUIRE_TIMEOUT:-5}
- RUSTFS_UNSAFE_BYPASS_DISK_CHECK=${RUSTFS_UNSAFE_BYPASS_DISK_CHECK:-true}
- RUSTFS_DURABILITY_MODE=${RUSTFS_DURABILITY_MODE:-strict}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_ENABLE:-false}
- RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS=${RUSTFS_EXPERIMENTAL_FILE_FDATASYNC_GROUP_COMMIT_WAIT_MICROS:-0}
# Internode gRPC optimization knobs (grpc-optimization P0-P3). Defaults match the binary
# defaults, so leaving these unset is a no-op; the A/B driver exports them to toggle a stage.
- RUSTFS_INTERNODE_RPC_TCP_NODELAY=${RUSTFS_INTERNODE_RPC_TCP_NODELAY:-true}
-53
View File
@@ -296,34 +296,6 @@
"origin": "baseline",
"alert_contract": "scheduled-validation"
},
{
"workflow": ".github/workflows/rdma-feature-check.yml",
"name": "S3-over-RDMA feature check",
"roles": [
"pr",
"periodic",
"manual"
],
"events": [
"pull_request",
"schedule",
"workflow_dispatch"
],
"cadence": "weekly",
"timezone": "UTC",
"schedule": [
"37 5 * * 1"
],
"owner": "@overtrue",
"policy": "active",
"monitor": "workflow",
"max_age_hours": 192,
"result_owner": "rdma-feature-check.yml",
"disposition": "compiles the nixl feature and runs rustfs-nixl unit tests on Linux; the feature is off in every other build",
"failure_owner": "workflow",
"origin": "added",
"alert_contract": "scheduled-validation"
},
{
"workflow": ".github/workflows/rustfs-validation-sweep.yml",
"name": "RustFS Validation Sweep",
@@ -1005,31 +977,6 @@
"origin": "baseline",
"alert_contract": "scheduled-validation"
},
{
"workflow": ".github/workflows/gateway-acceptance.yml",
"name": "Gateway Acceptance",
"roles": [
"periodic",
"manual"
],
"events": [
"schedule",
"workflow_dispatch"
],
"cadence": "nightly",
"timezone": "UTC",
"schedule": [
"29 3 * * *"
],
"owner": "@overtrue",
"policy": "active",
"monitor": "workflow",
"max_age_hours": 36,
"result_owner": "gateway-acceptance.yml",
"disposition": "gateway conformance corpus (rustfs profile) and client matrix against the candidate on both S3 stacks",
"failure_owner": "watchdog",
"origin": "added"
},
{
"workflow": ".github/workflows/gateway-integration-sync.yml",
"name": "Gateway Integration Sync",
+1 -1
View File
@@ -702,7 +702,7 @@ jobs:
uses: ./.github/actions/setup
with:
rust-version: stable
cache-shared-key: ci-dev-ea7eec74fe14
cache-shared-key: ci-dev
cache-save-if: 'false'
install-build-packaging-tools: 'false'
+2 -50
View File
@@ -25,8 +25,8 @@
# Left out of both stacks: `dual_stack_differential::` (servers with an explicit
# stack), `fake_s3_target::`, the upgrade write-readiness cases and one deadline
# case (no server), and `distributed_startup_regression_test::` (needs ci.yml's
# hooks-binary manifest). Both e2e-full stacks use ci.yml's pinned mc and
# Vault binaries and network fault-injection tools.
# hooks-binary manifest). e2e-full runs without the mc, Vault and iptables
# tools ci.yml installs: their cases fail on both stacks.
name: dual-stack-nightly
@@ -160,54 +160,6 @@ jobs:
echo "AWSCURL_PATH=$HOME/.local/bin/awscurl" >> "$GITHUB_ENV"
test -x "$HOME/.local/bin/awscurl"
- name: Install network fault-injection tools
if: matrix.profile == 'e2e-full'
run: |
sudo apt-get install -y iptables
sudo -n iptables --version
# The endpoint-blackhole heal scenario needs CAP_NET_ADMIN. Containerised
# runners can run iptables but not touch the rule set; the test then logs
# a skip instead of failing, so surface that here where it is visible.
if ! sudo -n iptables -w 5 -S OUTPUT >/dev/null 2>&1; then
echo "::warning::iptables cannot read the OUTPUT chain on this runner (no CAP_NET_ADMIN); the endpoint-blackhole heal scenario will be skipped"
fi
- name: Install mc
if: matrix.profile == 'e2e-full'
env:
GH_TOKEN: ${{ github.token }}
MC_VERSION: RELEASE.2025-08-13T08-35-41Z
MC_SHA256: 01f866e9c5f9b87c2b09116fa5d7c06695b106242d829a8bb32990c00312e891
run: |
if ! command -v gh >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y gh
fi
MC_BINARY="mc.linux-amd64.${MC_VERSION}"
python3 .github/actions/setup/download_release_asset.py --repository minio/mc --tag "$MC_VERSION" --asset "$MC_BINARY" --output "$RUNNER_TEMP/mc" --sha256 "$MC_SHA256"
echo "${MC_SHA256} $RUNNER_TEMP/mc" | sha256sum --check --status
chmod +x "$RUNNER_TEMP/mc"
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"
- name: Verify mc
if: matrix.profile == 'e2e-full'
run: mc --version
- name: Install Vault
if: matrix.profile == 'e2e-full'
run: |
VAULT_VERSION="1.17.6"
VAULT_ARCHIVE="vault_${VAULT_VERSION}_linux_amd64.zip"
curl -fsSLo "$RUNNER_TEMP/$VAULT_ARCHIVE" "https://releases.hashicorp.com/vault/${VAULT_VERSION}/${VAULT_ARCHIVE}"
echo "0cddc1fbbb88583b5ba5b845f9f8fae47c6fb39a6d48cd543c6ba6fd3ac1a669 $RUNNER_TEMP/$VAULT_ARCHIVE" | sha256sum --check --status
unzip -q "$RUNNER_TEMP/$VAULT_ARCHIVE" -d "$RUNNER_TEMP/vault-bin"
echo "RUSTFS_TEST_VAULT_BIN=$RUNNER_TEMP/vault-bin/vault" >> "$GITHUB_ENV"
- name: Verify Vault
if: matrix.profile == 'e2e-full'
run: |
"$RUSTFS_TEST_VAULT_BIN" version
- name: Run the profile on the ${{ matrix.stack }} stack
env:
PROFILE: ${{ matrix.profile }}
@@ -65,7 +65,6 @@ jobs:
strategy: { fail-fast: false, matrix: { stack: [legacy, gateway] } }
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
RUSTFS_BUILD_FEATURES: ${{ matrix.stack == 'gateway' && 'gateway-stack' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
@@ -97,7 +96,7 @@ jobs:
# Build once and carry its source/binary identity into the test invocation.
- name: Build rustfs binary
run: |
python3 scripts/e2e_binary.py build --bins --features "$RUSTFS_BUILD_FEATURES"
python3 scripts/e2e_binary.py build --bins
# A gateway binary that refuses to start skips the suite; the summary says why.
- name: Gateway preflight
@@ -115,7 +114,7 @@ jobs:
env:
RUSTFS_E2E_LOG_DIR: ${{ runner.temp }}/rustfs-e2e-repl-nightly-logs
RUSTFS_S3_STACK: ${{ matrix.stack }}
run: python3 scripts/e2e_binary.py run --features "$RUSTFS_BUILD_FEATURES" -- cargo nextest run --profile e2e-repl-nightly -p e2e_test
run: python3 scripts/e2e_binary.py run -- cargo nextest run --profile e2e-repl-nightly -p e2e_test
- name: Prove the stack and upload the leg
if: always()
@@ -214,7 +213,7 @@ jobs:
strategy: { fail-fast: false, matrix: { stack: [legacy, gateway] } }
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
RUSTFS_BUILD_FEATURES: ${{ matrix.stack == 'gateway' && 'ftps,webdav,sftp,gateway-stack' || 'ftps,webdav,sftp' }}
RUSTFS_BUILD_FEATURES: ftps,webdav,sftp
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
-395
View File
@@ -1,395 +0,0 @@
# Copyright 2026 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.
# Gateway black-box acceptance lanes (rustfs/backlog#2775 T3.4, #2776 T3.5).
#
# Runs two suites of the rustfs/gateway repository against the candidate binary,
# once per S3 stack (RUSTFS_S3_STACK=legacy and =gateway), one server per stack:
#
# - the conformance corpus, `--profile rustfs`. That profile describes the
# gateway edge, so scripts/check_conformance_rulings.py judges the gateway
# stack against .config/conformance-rulings.toml (red: an unruled failure, a
# ruled case failing differently, a stale ruling, a skip on the server's own
# answer) and publishes the legacy run as a reference that is never judged:
# it only has to serve, stay up and complete;
# - the client matrix, ci/compat/run_matrix.sh --external, judged per stack by
# scripts/compat_matrix_report.py (no `fail`, no `sut-unregistered`, every
# client ran; a client that could not be installed is reported as skipped).
# The legacy matrix is the baseline: every cell that passes on legacy must
# pass on gateway (`compare`).
#
# The suites are checked out at the rustfs/gateway rev Cargo.toml pins, so the
# suite and the framework under test never drift apart. The verdict of each
# stack is computed from what the run left on disk (startup record, the stack
# the server's own log names, runner exit code, liveness after the corpus,
# report), never from the exit status of an earlier step. Needs
# scripts/dual_stack.py and the `s3_stack` startup field of rustfs/rustfs#9367.
#
# The gateway stack is report-only until T2.10: its job may fail without failing
# the workflow, and its summary says what it observed (did not start, or how many
# cases ran, passed, failed and were answered 501). The stack comparison is
# report-only for the same reason; its conformance half is information only.
#
# Not a pull-request gate. Scheduled failures are owned by the scheduled-validation
# watchdog (.github/scheduled-validations.json).
name: Gateway Acceptance
on:
schedule:
- cron: "29 3 * * *"
workflow_dispatch:
# Matches ci.yml: these variables are hashed into the rust-cache key, so the
# candidate build reads the same ci-dev cache as build-rustfs-debug-binary.
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
plan:
name: Read the gateway pin
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
gateway-rev: ${{ steps.pin.outputs.rev }}
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
persist-credentials: false
- name: Read the rustfs/gateway rev from Cargo.toml
id: pin
run: |
set -euo pipefail
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import re, sys, tomllib
dependencies = tomllib.load(open("Cargo.toml", "rb"))["workspace"]["dependencies"]
revs = {spec.get("rev") for spec in dependencies.values()
if isinstance(spec, dict) and spec.get("git") == "https://github.com/rustfs/gateway.git"}
if len(revs) != 1 or not re.fullmatch(r"[0-9a-f]{40}", str(next(iter(revs)))):
sys.exit(f"Cargo.toml must pin rustfs/gateway at exactly one full rev, found {sorted(map(str, revs))}")
print(f"rev={revs.pop()}")
PY
cat "$GITHUB_OUTPUT"
build-candidate:
name: Build candidate binary
# The same debug build as ci.yml's build-rustfs-debug-binary, reading the
# ci-dev cache written on sm-standard-4.
runs-on: sm-standard-4
timeout-minutes: 60
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
persist-credentials: false
- name: Setup Rust environment
uses: ./.github/actions/setup
with:
rust-version: stable
cache-shared-key: ci-dev
cache-save-if: 'false'
install-build-packaging-tools: 'false'
- name: Build debug binary
run: python3 scripts/e2e_binary.py build --bins --features e2e-test-hooks
- name: Upload candidate binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gateway-acceptance-candidate-binary
overwrite: true
path: |
target/debug/rustfs
target/debug/rustfs.e2e.json
if-no-files-found: error
retention-days: 1
build-gateway-tools:
name: Build gateway conformance runner and compat-sut
needs: [ plan ]
# The gateway workspace builds with its own rust-toolchain.toml, which rustup
# installs on first use; nothing here names a toolchain.
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout rustfs/gateway at the pinned rev
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
repository: rustfs/gateway
ref: ${{ needs.plan.outputs.gateway-rev }}
path: gateway
persist-credentials: false
- name: Build
working-directory: gateway
run: |
cargo build --locked --release -p rustfs-gateway-conformance -p rustfs-gateway-compat-sut \
--bin rustfs-gateway-conformance --bin compat-sut
- name: Upload tools
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gateway-acceptance-tools
overwrite: true
path: |
gateway/target/release/rustfs-gateway-conformance
gateway/target/release/compat-sut
if-no-files-found: error
retention-days: 1
acceptance:
name: ${{ matrix.stack == 'gateway' && 'Acceptance (gateway, report-only until T2.10)' || 'Acceptance (legacy)' }}
needs: [ plan, build-candidate, build-gateway-tools ]
# GitHub-hosted like the s3-tests targets of reference-parity.yml: the job
# only runs prebuilt binaries and the pinned clients, none of which needs Docker.
runs-on: ubuntu-latest
# About 3x the 15 minutes the legacy job took in run 43325101234 (client install about
# 8, matrix about 3, corpus about 3), so a hung server costs 45 runner minutes, not more.
timeout-minutes: 45
continue-on-error: ${{ matrix.stack == 'gateway' }}
strategy:
fail-fast: false
matrix:
stack: [ legacy, gateway ]
env:
STACK: ${{ matrix.stack }}
ENDPOINT: http://127.0.0.1:9000
# The conformance suite signs with these fixed fixture credentials (the AWS
# documentation example pair), so the candidate is started with them and the
# client matrix is handed the same pair.
ACCESS_KEY: AKIAIOSFODNN7EXAMPLE
SECRET_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
persist-credentials: false
- name: Checkout rustfs/gateway at the pinned rev
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
repository: rustfs/gateway
ref: ${{ needs.plan.outputs.gateway-rev }}
path: gateway
persist-credentials: false
- name: Download candidate binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: gateway-acceptance-candidate-binary
path: target/debug
- name: Download gateway tools
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: gateway-acceptance-tools
path: tools
# Records `ready`, or what the process said when it exited, in lane/startup.txt. `ready`
# also needs the server's own `server_starting` log event to name the requested stack
# (its `s3_stack` field comes from rustfs/rustfs#9367; scripts/dual_stack.py reads it).
- name: Start candidate (${{ matrix.stack }} stack)
run: |
set -uo pipefail
chmod +x target/debug/rustfs tools/*
mkdir -p lane "$RUNNER_TEMP"/data/rustfs{0..3}
target/debug/rustfs --version | tee lane/candidate-version.txt
# The four directories share the runner's one disk; the bypass is the CI case the
# physical-disk guard sanctions (as in mint.yml).
RUSTFS_S3_STACK="$STACK" RUSTFS_UNSAFE_BYPASS_DISK_CHECK=true RUST_LOG=info target/debug/rustfs --address 127.0.0.1:9000 \
--access-key "$ACCESS_KEY" --secret-key "$SECRET_KEY" "$RUNNER_TEMP"/data/rustfs{0..3} \
> lane/rustfs.log 2>&1 &
pid=$!
echo "$pid" > lane/rustfs.pid
# Liveness first: a ready answer counts only while this process is still running.
for _ in $(seq 120); do
if ! kill -0 "$pid" 2>/dev/null; then
status=0
wait "$pid" || status=$?
echo "did not start: exit ${status}: $(grep -v '^[[:space:]]*$' lane/rustfs.log | tail -n 1)" > lane/startup.txt
cat lane/startup.txt
exit 1
fi
if curl -sf "$ENDPOINT/health/ready" >/dev/null; then
if python3 scripts/dual_stack.py stack --expect "$STACK" --out lane/stack.json lane/rustfs.log > /dev/null; then
echo ready > lane/startup.txt
exit 0
fi
echo "did not start: stack not observed" > lane/startup.txt
cat lane/startup.txt
exit 1
fi
sleep 1
done
echo "did not start: /health/ready did not answer within 120 seconds" > lane/startup.txt
exit 1
# The exit code is data for the judge step, not this step's result.
- name: Run gateway conformance (rustfs profile)
run: |
set +e
tools/rustfs-gateway-conformance run --root gateway/conformance --profile rustfs \
--endpoint "$ENDPOINT" --allow-external-fixtures \
--json lane/report.json > lane/conformance.log 2>&1
echo "$?" > lane/runner-exit.txt
if kill -0 "$(cat lane/rustfs.pid)" 2>/dev/null; then echo alive; else echo exited; fi > lane/alive-after-conformance.txt
tail -n 20 lane/conformance.log
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
# Toolchains for the matrix's SDK driver programs, as the gateway's own
# client-matrix.yml sets them up; the client versions come from
# gateway/compat/versions.toml.
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "1.26"
cache: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: "8.0.x"
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
with:
distribution: temurin
java-version: "21"
- name: Install Maven
env:
MAVEN_VERSION: "3.9.16"
MAVEN_SHA512: "831a8591fe20c8243b1dbe7d71e3244f31d1665b0804b2e825e38cbbe5ce0cafb8338851f90780735568773e0a6cd07bbec107cda0b896b008b861075358b6f6"
run: |
set -euo pipefail
archive="$RUNNER_TEMP/apache-maven.tar.gz"
curl -sSfL -o "$archive" "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
echo "${MAVEN_SHA512} ${archive}" | sha512sum -c -
tar -xzf "$archive" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/apache-maven-${MAVEN_VERSION}/bin" >> "$GITHUB_PATH"
# One client at a time, so a client that cannot be installed is reported
# as skipped with its reason instead of stopping the others.
- name: Install pinned clients
working-directory: gateway
run: |
set -uo pipefail
python3 -m pip install --disable-pip-version-check "pyyaml==6.0.2"
installed=()
for client in $(python3 -c 'import tomllib; print(" ".join(sorted(tomllib.load(open("compat/versions.toml", "rb"))["clients"])))'); do
if bash ci/compat/install_clients.sh --clients "$client" > "../lane/install-${client}.log" 2>&1; then
installed+=("$client")
else
echo "${client}: skipped: $(tail -n 1 "../lane/install-${client}.log")" >> ../lane/skipped-clients.txt
fi
done
echo "COMPAT_CLIENTS=$(IFS=,; echo "${installed[*]}")" >> "$GITHUB_ENV"
cat ../lane/skipped-clients.txt 2>/dev/null || echo "every pinned client installed"
# The exit code is data for the judge step, not this step's result.
- name: Run client matrix (external)
working-directory: gateway
env:
GATEWAY_COMPAT_SUT_BIN: ${{ github.workspace }}/tools/compat-sut
GATEWAY_COMPAT_RUN_DIR: ${{ github.workspace }}/lane/compat
GATEWAY_COMPAT_MATRIX_OUT: ${{ github.workspace }}/lane/compat/matrix.json
run: |
set +e
export GATEWAY_COMPAT_ACCESS_KEY="$ACCESS_KEY" GATEWAY_COMPAT_SECRET_KEY="$SECRET_KEY"
PATH="$(go env GOPATH)/bin:$PATH"
if [[ -f ../lane/skipped-clients.txt ]]; then
bash ci/compat/run_matrix.sh --external "$ENDPOINT" --product rustfs --clients "$COMPAT_CLIENTS"
else
bash ci/compat/run_matrix.sh --external "$ENDPOINT" --product rustfs
fi
echo "$?" > ../lane/matrix-exit.txt
- name: Judge and summarize
if: always()
run: |
set -uo pipefail
status=0
python3 scripts/check_conformance_rulings.py --stack "$STACK" --run-dir lane | tee -a "$GITHUB_STEP_SUMMARY" || status=1
python3 scripts/compat_matrix_report.py check --stack "$STACK" --run-dir lane | tee -a "$GITHUB_STEP_SUMMARY" || status=1
exit "$status"
- name: Upload lane results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gateway-acceptance-lane-${{ matrix.stack }}
overwrite: true
path: |
lane/*.txt
lane/*.log
lane/report.json
lane/stack.json
lane/compat/matrix.json
lane/compat/probe.jsonl
lane/compat/sut.log
lane/compat/results/**
if-no-files-found: error
retention-days: 14
compare:
name: Compare stacks (report-only until T2.10)
needs: [ acceptance ]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
persist-credentials: false
- name: Download lane results
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: gateway-acceptance-lane-*
path: lanes
- name: Diff legacy and gateway
run: |
set -uo pipefail
status=0
{
python3 scripts/check_conformance_rulings.py \
--diff lanes/gateway-acceptance-lane-legacy lanes/gateway-acceptance-lane-gateway || status=1
echo
python3 scripts/compat_matrix_report.py diff \
--legacy lanes/gateway-acceptance-lane-legacy --gateway lanes/gateway-acceptance-lane-gateway || status=1
} > diff.md
cat diff.md
cat diff.md >> "$GITHUB_STEP_SUMMARY"
exit "$status"
-91
View File
@@ -1,91 +0,0 @@
name: S3-over-RDMA feature check
# The `nixl` and `cuobject` features are off in every other build, so the code
# behind them is compiled nowhere else. This job compiles the `nixl` half on
# Linux and runs rustfs-nixl's unit tests; nixl-sys builds through its stub
# fallback, so no NIXL SDK is needed.
# The cuObject half needs the NVIDIA cuObject SDK and is not compiled here.
# Not a required check and not part of the `Test and Lint` aggregate.
on:
pull_request:
paths:
- "crates/nixl/**"
- "crates/cuobject/**"
- "rustfs/src/storage/rpc/nixl*"
- "rustfs/src/app/object/cuobject.rs"
- "rustfs/src/app/object/get.rs"
- "rustfs/src/app/object/put.rs"
- "rustfs/src/app/multipart_usecase/upload_part.rs"
- "Cargo.toml"
- "rustfs/Cargo.toml"
- ".github/workflows/rdma-feature-check.yml"
schedule:
- cron: "37 5 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: rdma-feature-check-${{ github.ref }}
cancel-in-progress: true
jobs:
nixl-check:
name: cargo check and unit tests (nixl)
runs-on: sm-standard-4
timeout-minutes: 60
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
steps:
- name: Checkout repository
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7
with:
persist-credentials: false
- name: Setup Rust environment
uses: ./.github/actions/setup
with:
rust-version: stable
cache-shared-key: ci-feat-nixl
cache-save-if: 'false'
install-build-packaging-tools: 'false'
- name: Install only missing native build tools
run: |
packages=()
command -v g++ >/dev/null || packages+=(g++)
ldconfig -p | grep -q 'libclang' || packages+=(libclang-dev)
if (( ${#packages[@]} )); then
sudo apt-get update
sudo apt-get install --no-install-recommends -y "${packages[@]}"
fi
- name: Check the nixl feature build
run: cargo check --locked -p rustfs --features nixl
# These unit tests use a fake sysfs and plain host memory; none needs an
# RDMA device or the NIXL libraries.
- name: Run the rustfs-nixl unit tests
run: cargo test --locked -p rustfs-nixl --features sys
alert-on-failure:
name: Alert on scheduled failure
needs: [nixl-check]
# Only scheduled runs open or update the tracking issue; pull-request and
# manual runs stay quiet.
if: always() && github.event_name == 'schedule' && contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
- name: Open or update failure-tracking issue
uses: ./.github/actions/schedule-failure-issue
with:
github-token: ${{ secrets.BACKLOG_ISSUE_TOKEN }}
-2
View File
@@ -44,8 +44,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- **Vault KMS backends no longer fail when the server answers reads from a replica**: a Vault or OpenBao node that serves reads locally (an OpenBao standby, a Vault Enterprise performance standby) can return the state from before a write for a short while after acknowledging it. Against such a node the KV2 backend failed every key creation with `404 Key not found` while leaving the key stored without its description and tags, failed operations issued right after a create or update with `Key not found` or `Concurrent modification`, and the Transit backend failed a disable followed quickly by an enable. Key creation on the KV2 backend is now a single create-only write that carries the description and tags. Both backends now re-read a key record when the answer is older than a write the same RustFS node made in the previous five seconds, pause before re-reading after a lost check-and-set write and allow five attempts instead of three, and retry a Transit key delete that is refused because the deletion switch is not visible yet. A different RustFS node reading the same replica can still observe the earlier state until the replica catches up; see [OpenBao as the Vault KMS backend](docs/operations/kms-openbao-compatibility.md).
- **KMS keys could not be described by ARN through the path route**: `GET /rustfs/admin/v3/kms/keys/{key_id}` read the path segment verbatim, so a key id that has to be percent-encoded to fit in one segment — an AWS key ARN, with its `:` and `/` — was looked up, authorized and audited under its encoded spelling and answered `404`. The segment is now percent-decoded first; a segment that is not valid UTF-8 after decoding is refused with `400 InvalidArgument`. The `describe-key?keyId=` form was unaffected.
- **SSE-KMS objects written through the AWS KMS backend could not be read**: `GetObject`, `CopyObject` and every other read of an `aws:kms` object failed with `400 InvalidRequest` ("SSE-S3 requires RUSTFS_SSE_S3_MASTER_KEY to be set ...") on a deployment using `RUSTFS_KMS_BACKEND=aws`, although the write and `HeadObject` succeeded. The AWS backend stored the `GenerateDataKey` blob as it came from AWS, the read path took those unrecognized bytes for a locally wrapped key, and AWS was never asked to decrypt. The backend now stores the blob inside the same data-key envelope the other backends use, and a blob stored without one is routed to AWS when the AWS backend is active. Objects written by 1.0.4 and 1.0.5 are intact and become readable after the upgrade, with no rewrite. Setting `RUSTFS_SSE_S3_MASTER_KEY` was never a workaround. An object written by this release is not readable by an older one; the same was already true of every object the older release wrote itself.
Generated
+83 -363
View File
@@ -255,7 +255,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -266,7 +266,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -1004,7 +1004,7 @@ version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b744eed18cd75d814effdf2aba2880f912abe0fe1c327b361341d31aba9a7005"
dependencies = [
"bindgen 0.73.2",
"bindgen",
"cc",
"cmake",
"dunce",
@@ -1618,26 +1618,6 @@ dependencies = [
"serde",
]
[[package]]
name = "bindgen"
version = "0.71.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3"
dependencies = [
"bitflags 2.13.2",
"cexpr",
"clang-sys",
"itertools 0.13.0",
"log",
"prettyplease 0.2.37",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex 1.3.0",
"syn 2.0.119",
]
[[package]]
name = "bindgen"
version = "0.73.2"
@@ -1653,7 +1633,7 @@ dependencies = [
"quote",
"regex",
"rustc-hash",
"shlex 2.0.1",
"shlex",
"syn 3.0.10",
]
@@ -1786,15 +1766,6 @@ dependencies = [
"hybrid-array",
]
[[package]]
name = "block2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
dependencies = [
"objc2",
]
[[package]]
name = "blocking"
version = "1.7.0"
@@ -1927,9 +1898,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.20.4"
version = "3.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
[[package]]
name = "bytemuck"
@@ -2015,7 +1986,7 @@ dependencies = [
"maybe-owned",
"rustix",
"rustix-linux-procfs",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
"winx",
]
@@ -2109,14 +2080,14 @@ dependencies = [
[[package]]
name = "cc"
version = "1.11.2"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
checksum = "4ff2a8126fff0f8c839080d619675a585e61720bb12d2baceae45769fd66f155"
dependencies = [
"find-msvc-tools",
"jobserver",
"libc",
"shlex 2.0.1",
"shlex",
]
[[package]]
@@ -2800,27 +2771,6 @@ dependencies = [
"subtle",
]
[[package]]
name = "cuobject"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "486fec9045f8057131bf4bba71fbb87bf9dd3e44f853622cf7fa42713f3a108c"
dependencies = [
"cuobject-sys",
"memmap2",
"thiserror 2.0.21",
]
[[package]]
name = "cuobject-sys"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edc615b2a037eb0d80180d202f809629155742db9c9e94b9f7696b1100a7d52f"
dependencies = [
"bindgen 0.73.2",
"cc",
]
[[package]]
name = "curve25519-dalek"
version = "4.1.3"
@@ -4133,7 +4083,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4212,7 +4162,7 @@ dependencies = [
"md-5",
"minlz",
"opentelemetry-proto",
"prost 0.14.6",
"prost 0.14.5",
"rand 0.10.3",
"rcgen",
"reqwest",
@@ -4447,7 +4397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4915,7 +4865,7 @@ dependencies = [
"hmac 0.13.0",
"http 1.5.0",
"jiff",
"jsonwebtoken 11.1.0",
"jsonwebtoken",
"reqwest",
"rustc_version",
"rustls",
@@ -4973,8 +4923,8 @@ dependencies = [
"opentelemetry_sdk",
"percent-encoding",
"pin-project",
"prost 0.14.6",
"prost-types 0.14.6",
"prost 0.14.5",
"prost-types 0.14.5",
"reqwest",
"rustc_version",
"serde",
@@ -5080,8 +5030,8 @@ dependencies = [
"jiff",
"md5",
"percent-encoding",
"prost 0.14.6",
"prost-types 0.14.6",
"prost 0.14.5",
"prost-types 0.14.5",
"serde",
"serde_json",
"serde_with",
@@ -5587,7 +5537,6 @@ dependencies = [
"pin-project-lite",
"smallvec",
"tokio",
"tracing",
"want",
]
@@ -6078,26 +6027,10 @@ dependencies = [
"base64 0.22.1",
"getrandom 0.2.17",
"js-sys",
"pem 3.0.6",
"serde",
"serde_json",
"signature 2.2.0",
"zeroize",
]
[[package]]
name = "jsonwebtoken"
version = "12.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f347a975eb5fa8f5c4eadce6c1152c11c326cf32cf839fb64ff12d5cb8f4ce8b"
dependencies = [
"aws-lc-rs",
"base64 0.23.1",
"getrandom 0.4.3",
"js-sys",
"pem 4.0.0",
"serde",
"serde_json",
"signature 3.0.0",
"simple_asn1",
"zeroize",
]
@@ -6348,9 +6281,9 @@ dependencies = [
[[package]]
name = "libunftp"
version = "0.25.0"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b019a8d208e2672b68fddc84cc9f15c64df3b717b58773d3b2c9dd28729b30"
checksum = "7d94587cfb90dd87b7cced3bff07d32cb56ad1192baa5d688dfaa8728f22d48d"
dependencies = [
"async-trait",
"bitflags 2.13.2",
@@ -6767,9 +6700,9 @@ dependencies = [
[[package]]
name = "mio"
version = "1.2.5"
version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a"
checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
dependencies = [
"libc",
"wasi 0.11.1+wasi-snapshot-preview1",
@@ -7007,23 +6940,6 @@ dependencies = [
"libc",
]
[[package]]
name = "nixl-sys"
version = "1.6.0"
source = "git+https://github.com/houseme/nixl?rev=cc636c83f13d692e85b67e55aed092413d16fb41#cc636c83f13d692e85b67e55aed092413d16fb41"
dependencies = [
"anyhow",
"bindgen 0.71.1",
"cc",
"libc",
"os_info",
"pkg-config",
"serde",
"thiserror 2.0.21",
"tracing",
"wincode",
]
[[package]]
name = "nkeys"
version = "0.4.5"
@@ -7073,7 +6989,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -7255,27 +7171,6 @@ dependencies = [
"objc2-encode",
]
[[package]]
name = "objc2-cloud-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-foundation",
]
[[package]]
name = "objc2-core-data"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
dependencies = [
"objc2",
"objc2-foundation",
]
[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
@@ -7287,51 +7182,6 @@ dependencies = [
"objc2",
]
[[package]]
name = "objc2-core-graphics"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
dependencies = [
"bitflags 2.13.2",
"dispatch2",
"objc2",
"objc2-core-foundation",
"objc2-io-surface",
]
[[package]]
name = "objc2-core-image"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006"
dependencies = [
"objc2",
"objc2-foundation",
]
[[package]]
name = "objc2-core-location"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009"
dependencies = [
"objc2",
"objc2-foundation",
]
[[package]]
name = "objc2-core-text"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
]
[[package]]
name = "objc2-encode"
version = "4.1.0"
@@ -7345,10 +7195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags 2.13.2",
"block2",
"libc",
"objc2",
"objc2-core-foundation",
]
[[package]]
@@ -7361,17 +7208,6 @@ dependencies = [
"objc2-core-foundation",
]
[[package]]
name = "objc2-io-surface"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-core-foundation",
]
[[package]]
name = "objc2-open-directory"
version = "0.3.2"
@@ -7383,18 +7219,6 @@ dependencies = [
"objc2-foundation",
]
[[package]]
name = "objc2-quartz-core"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-core-foundation",
"objc2-foundation",
]
[[package]]
name = "objc2-system-configuration"
version = "0.3.2"
@@ -7404,37 +7228,6 @@ dependencies = [
"objc2-core-foundation",
]
[[package]]
name = "objc2-ui-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"
dependencies = [
"bitflags 2.13.2",
"block2",
"objc2",
"objc2-cloud-kit",
"objc2-core-data",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-image",
"objc2-core-location",
"objc2-core-text",
"objc2-foundation",
"objc2-quartz-core",
"objc2-user-notifications",
]
[[package]]
name = "objc2-user-notifications"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e"
dependencies = [
"objc2",
"objc2-foundation",
]
[[package]]
name = "object"
version = "0.36.7"
@@ -7624,7 +7417,7 @@ dependencies = [
"opentelemetry-http",
"opentelemetry-proto",
"opentelemetry_sdk",
"prost 0.14.6",
"prost 0.14.5",
"reqwest",
"thiserror 2.0.21",
]
@@ -7637,7 +7430,7 @@ checksum = "d576f5dddc3299341bcd85a04be17b2564844c0c9563214f02d85f2524d1afae"
dependencies = [
"opentelemetry",
"opentelemetry_sdk",
"prost 0.14.6",
"prost 0.14.5",
]
[[package]]
@@ -7699,22 +7492,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "os_info"
version = "3.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf20a545b305cf1da722b236b5155c9bb35f1d5ceb28c048bd96ca842f41b5b"
dependencies = [
"android_system_properties",
"log",
"nix 0.31.3",
"objc2",
"objc2-foundation",
"objc2-ui-kit",
"serde",
"windows-sys 0.61.2",
]
[[package]]
name = "ouroboros"
version = "0.18.5"
@@ -7966,12 +7743,6 @@ dependencies = [
"phc",
]
[[package]]
name = "pastey"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
[[package]]
name = "path-absolutize"
version = "4.0.1"
@@ -8620,12 +8391,12 @@ dependencies = [
[[package]]
name = "prost"
version = "0.14.6"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ef0b569d1d907ab3a28596aee62cf1f61dacb0529a4bedcd8e7460e2d5228b4"
checksum = "c9f016da56b311cff4659f5e7335c4d5fda5ca86cae4f48b8ce1cf3335246a7d"
dependencies = [
"bytes",
"prost-derive 0.14.6",
"prost-derive 0.14.5",
]
[[package]]
@@ -8650,9 +8421,9 @@ dependencies = [
[[package]]
name = "prost-build"
version = "0.14.6"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6e4d69d0fa3e7f6f9cf6b53a0e83e4fc99ba3586f65ce166cff30bd13bb4ad2"
checksum = "f461f69b0cacd7a9c2bcac932e0f3a22cb13c29fc9023092502995a771a10491"
dependencies = [
"heck 0.5.0",
"itertools 0.15.0",
@@ -8660,8 +8431,8 @@ dependencies = [
"multimap",
"petgraph 0.8.3",
"prettyplease 0.3.0",
"prost 0.14.6",
"prost-types 0.14.6",
"prost 0.14.5",
"prost-types 0.14.5",
"pulldown-cmark",
"pulldown-cmark-to-cmark",
"regex",
@@ -8684,9 +8455,9 @@ dependencies = [
[[package]]
name = "prost-derive"
version = "0.14.6"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad9c5423459fa2f729b8d9235fab810aa29628b171467744fc86d21460ad70d"
checksum = "c9a367f131d93b3395fc6207c11e67098493ab040def4ce3085adbf186687f7e"
dependencies = [
"anyhow",
"itertools 0.15.0",
@@ -8706,11 +8477,11 @@ dependencies = [
[[package]]
name = "prost-types"
version = "0.14.6"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29a7c4c7a84cef41a53d338a2d10d4f1b043ea5c3dde26db22ee2c9c1b1c75b"
checksum = "96e89651c132da91958fd6092a2f7262c2c36c08df4f68af0bb3591caacbbb45"
dependencies = [
"prost 0.14.6",
"prost 0.14.5",
]
[[package]]
@@ -8802,7 +8573,7 @@ dependencies = [
"nix 0.31.3",
"object 0.40.0",
"once_cell",
"prost 0.14.6",
"prost 0.14.5",
"reqwest",
"ruzstd",
"serde_json",
@@ -9026,7 +8797,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -9841,7 +9612,7 @@ dependencies = [
"percent-encoding",
"pin-project-lite",
"proptest",
"prost 0.14.6",
"prost 0.14.5",
"pyroscope",
"quick-xml 0.42.0",
"quinn",
@@ -9858,14 +9629,12 @@ dependencies = [
"rustfs-config",
"rustfs-credentials",
"rustfs-crypto",
"rustfs-cuobject",
"rustfs-data-usage",
"rustfs-ecstore",
"rustfs-extension-schema",
"rustfs-filemeta",
"rustfs-gateway",
"rustfs-gateway-adapter",
"rustfs-gateway-stream",
"rustfs-gateway-types",
"rustfs-heal",
"rustfs-heal-contracts",
@@ -9880,7 +9649,6 @@ dependencies = [
"rustfs-madmin",
"rustfs-mimalloc",
"rustfs-mimalloc-sys",
"rustfs-nixl",
"rustfs-notify",
"rustfs-object-capacity",
"rustfs-object-data-cache",
@@ -9975,6 +9743,7 @@ dependencies = [
"base64-simd",
"bytes",
"crc-fast",
"hotpath",
"http 1.5.0",
"md-5",
"pretty_assertions",
@@ -9988,6 +9757,7 @@ name = "rustfs-common"
version = "1.0.5"
dependencies = [
"arc-swap",
"hotpath",
"metrics",
"smallvec",
"thiserror 2.0.21",
@@ -10015,6 +9785,7 @@ name = "rustfs-config"
version = "1.0.5"
dependencies = [
"const-str",
"hotpath",
"serde",
"serde_json",
]
@@ -10037,6 +9808,7 @@ version = "1.0.5"
dependencies = [
"base64-simd",
"hmac 0.13.0",
"hotpath",
"rand 0.10.3",
"serde",
"serde_json",
@@ -10052,7 +9824,8 @@ dependencies = [
"argon2",
"base64-simd",
"chacha20poly1305",
"jsonwebtoken 12.0.0",
"hotpath",
"jsonwebtoken",
"pbkdf2 0.13.0",
"rand 0.10.3",
"rsa 0.10.0-rc.18",
@@ -10064,17 +9837,6 @@ dependencies = [
"time",
]
[[package]]
name = "rustfs-cuobject"
version = "1.0.5"
dependencies = [
"bytes",
"cuobject",
"parking_lot 0.13.0",
"thiserror 2.0.21",
"tokio",
]
[[package]]
name = "rustfs-data-usage"
version = "1.0.5"
@@ -10083,7 +9845,6 @@ dependencies = [
"rmp-serde",
"rustfs-filemeta",
"serde",
"serde_json",
]
[[package]]
@@ -10212,14 +9973,14 @@ dependencies = [
[[package]]
name = "rustfs-erasure-codec"
version = "9.1.0"
version = "9.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d27b3b2484cfd3ca8f444534d96266eae1ac9a87dc658bd093255fe626b4fc6e"
checksum = "10c0115cfe221ffc1e45002a935afc95bce48e01206b642800f0968928bf9b97"
dependencies = [
"cfg_aliases",
"hashlink",
"libm",
"parking_lot 0.13.0",
"parking_lot 0.12.5",
"rayon",
"smallvec",
"spin 0.12.3",
@@ -10229,6 +9990,7 @@ dependencies = [
name = "rustfs-extension-schema"
version = "1.0.5"
dependencies = [
"hotpath",
"serde",
"serde_json",
"thiserror 2.0.21",
@@ -10265,8 +10027,8 @@ dependencies = [
[[package]]
name = "rustfs-gateway"
version = "0.63.0"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
version = "0.62.0"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"arc-swap",
"bytes",
@@ -10313,7 +10075,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-core"
version = "0.60.0"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"bytes",
"futures-core",
@@ -10334,7 +10096,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-http"
version = "0.1.4"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"hmac 0.13.0",
"http 1.5.0",
@@ -10352,7 +10114,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-macros"
version = "0.1.4"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"proc-macro2",
"quote",
@@ -10362,7 +10124,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-sig"
version = "0.15.0"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"hmac 0.13.0",
"http 1.5.0",
@@ -10377,7 +10139,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-stream"
version = "0.2.0"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"bitflags 2.13.2",
"bytes",
@@ -10388,7 +10150,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-types"
version = "0.40.0+aws.2026-10-02"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"bytes",
"crc-fast",
@@ -10411,7 +10173,7 @@ dependencies = [
[[package]]
name = "rustfs-gateway-xml"
version = "0.4.0"
source = "git+https://github.com/rustfs/gateway.git?rev=2a6b8d1f7663db978d8784ab3ea331cade19237b#2a6b8d1f7663db978d8784ab3ea331cade19237b"
source = "git+https://github.com/rustfs/gateway.git?rev=7915d06950f88611d883f6ab3d95efc90c65dec0#7915d06950f88611d883f6ab3d95efc90c65dec0"
dependencies = [
"quick-xml 0.41.0",
]
@@ -10479,7 +10241,7 @@ dependencies = [
"hmac 0.13.0",
"hotpath",
"http 1.5.0",
"jsonwebtoken 12.0.0",
"jsonwebtoken",
"moka",
"openidconnect",
"pollster",
@@ -10729,6 +10491,7 @@ version = "1.0.5"
dependencies = [
"chrono",
"flate2",
"hotpath",
"regex",
"serde",
"serde_json",
@@ -10778,20 +10541,6 @@ dependencies = [
"cc",
]
[[package]]
name = "rustfs-nixl"
version = "1.0.5"
dependencies = [
"base64-simd",
"bytes",
"memmap2",
"nixl-sys",
"parking_lot 0.13.0",
"thiserror 2.0.21",
"tokio",
"tracing",
]
[[package]]
name = "rustfs-notify"
version = "1.0.5"
@@ -10852,6 +10601,7 @@ version = "1.0.5"
dependencies = [
"bytes",
"criterion",
"hotpath",
"metrics",
"metrics-util",
"moka",
@@ -10935,7 +10685,7 @@ dependencies = [
"hotpath",
"ipnetwork",
"jiff",
"jsonwebtoken 12.0.0",
"jsonwebtoken",
"moka",
"pollster",
"proptest",
@@ -11028,9 +10778,7 @@ version = "1.0.5"
dependencies = [
"flatbuffers",
"hotpath",
"hyper",
"hyper-util",
"prost 0.14.6",
"prost 0.14.5",
"rcgen",
"rmp-serde",
"rustfs-common",
@@ -11048,7 +10796,6 @@ dependencies = [
"tonic-prost",
"tonic-prost-build",
"tracing",
"tracing-subscriber",
"uuid",
]
@@ -11058,6 +10805,7 @@ version = "1.0.5"
dependencies = [
"byteorder",
"bytes",
"hotpath",
"regex",
"rmp",
"rmp-serde",
@@ -11198,6 +10946,7 @@ version = "1.0.5"
dependencies = [
"bytes",
"futures-core",
"hotpath",
"http 1.5.0",
"http-body",
"http-body-util",
@@ -11288,7 +11037,7 @@ dependencies = [
"metrics",
"opentelemetry-proto",
"opentelemetry_sdk",
"prost 0.14.6",
"prost 0.14.5",
"rand 0.10.3",
"rmp-serde",
"rustfs-common",
@@ -11344,6 +11093,7 @@ dependencies = [
name = "rustfs-security-governance"
version = "1.0.5"
dependencies = [
"hotpath",
"thiserror 2.0.21",
]
@@ -11544,6 +11294,7 @@ dependencies = [
"hex-simd",
"highway",
"hmac 0.13.0",
"hotpath",
"http 1.5.0",
"hyper",
"local-ip-address",
@@ -11641,7 +11392,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -11723,7 +11474,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -11734,9 +11485,9 @@ checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f"
[[package]]
name = "rustls-webpki"
version = "0.103.17"
version = "0.103.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5"
checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
dependencies = [
"aws-lc-rs",
"ring",
@@ -12351,12 +12102,6 @@ dependencies = [
"dirs",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "shlex"
version = "2.0.1"
@@ -12540,7 +12285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -12691,7 +12436,7 @@ dependencies = [
"cfg-if",
"libc",
"psm",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -12999,10 +12744,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom 0.3.4",
"getrandom 0.4.3",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -13438,7 +13183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eba464054e2226f182a34489b8b079bf4c6e3e7ab5fd7fc30e024f24aa92a484"
dependencies = [
"bytes",
"prost 0.14.6",
"prost 0.14.5",
"tonic",
]
@@ -13450,8 +13195,8 @@ checksum = "2ea216ddc448e08e7839ab09e20e60b06b6a1c32745ccb212c0ebd161c199f1b"
dependencies = [
"prettyplease 0.2.37",
"proc-macro2",
"prost-build 0.14.6",
"prost-types 0.14.6",
"prost-build 0.14.5",
"prost-types 0.14.5",
"quote",
"syn 2.0.119",
"tempfile",
@@ -14117,7 +13862,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -14126,31 +13871,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wincode"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063b5affe63fb4e584a33101d8808f01f2348b4f533db6223bf27263a0fdb9e9"
dependencies = [
"pastey",
"proc-macro2",
"quote",
"thiserror 2.0.21",
"wincode-derive",
]
[[package]]
name = "wincode-derive"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11d582d9fc9d813264407a9e16bfa16846ccf15ef032f9bbcd700741bdc00255"
dependencies = [
"darling 0.23.0",
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "windows"
version = "0.62.2"
@@ -14796,7 +14516,7 @@ version = "2.1.3+zstd.1.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f729a06d0257428fd9d997ac8db7e1407bd0262ab016b085b36bc52957c0052d"
dependencies = [
"bindgen 0.73.2",
"bindgen",
"cc",
"pkg-config",
]
+10 -14
View File
@@ -23,8 +23,6 @@ members = [
"crates/connect-symbol-catalog", # Release-only CPU profile symbol catalog generator
"crates/credentials", # Credential management system
"crates/crypto", # Cryptography and security features
"crates/cuobject", # NVIDIA cuObject S3-over-RDMA staging and transfers (optional)
"crates/nixl", # NIXL/UCX S3-over-RDMA server side (optional)
"crates/ecstore", # Erasure coding storage implementation
"crates/e2e_test", # End-to-end test suite
"crates/filemeta", # File metadata management
@@ -80,6 +78,7 @@ repository = "https://github.com/rustfs/rustfs"
rust-version = "1.99.0"
version = "1.0.5"
homepage = "https://rustfs.com"
description = "RustFS is a high-performance distributed object storage software built using Rust, one of the most popular languages worldwide. "
keywords = ["RustFS", "Minio", "object-storage", "filesystem", "s3"]
categories = ["web-programming", "development-tools", "filesystem", "network-programming"]
authors = ["RustFS Team"]
@@ -94,6 +93,7 @@ redundant_clone = "warn"
[workspace.dependencies]
# RustFS Internal Crates
rustfs = { path = "./rustfs", version = "1.0.5" }
rustfs-gateway-adapter = { path = "crates/gateway-adapter", version = "1.0.5" }
rustfs-heal = { path = "crates/heal", version = "1.0.5" }
rustfs-heal-contracts = { path = "crates/heal-contracts", version = "1.0.5" }
@@ -106,8 +106,6 @@ rustfs-config = { path = "./crates/config", version = "1.0.5" }
rustfs-concurrency = { path = "./crates/concurrency", version = "1.0.5" }
rustfs-credentials = { path = "crates/credentials", version = "1.0.5" }
rustfs-crypto = { path = "crates/crypto", version = "1.0.5" }
rustfs-cuobject = { path = "crates/cuobject", version = "1.0.5" }
rustfs-nixl = { path = "crates/nixl", version = "1.0.5" }
rustfs-ecstore = { path = "crates/ecstore", version = "1.0.5" }
rustfs-filemeta = { path = "crates/filemeta", version = "1.0.5" }
rustfs-iam = { path = "crates/iam", version = "1.0.5" }
@@ -151,14 +149,14 @@ rustfs-zip = { path = "./crates/zip", version = "1.0.5" }
# engine crates move onto from s3s (rustfs/backlog#2745). The one pin of the
# gateway in this workspace; no crate may enable a `compat-s3s*` feature except
# the s3s-facing edge of the rustfs binary.
rustfs-gateway-types = { git = "https://github.com/rustfs/gateway.git", rev = "2a6b8d1f7663db978d8784ab3ea331cade19237b", version = "0.40.0", default-features = false }
rustfs-gateway-stream = { git = "https://github.com/rustfs/gateway.git", rev = "2a6b8d1f7663db978d8784ab3ea331cade19237b", version = "0.2.0", default-features = false }
rustfs-gateway-types = { git = "https://github.com/rustfs/gateway.git", rev = "7915d06950f88611d883f6ab3d95efc90c65dec0", version = "0.40.0", default-features = false }
rustfs-gateway-stream = { git = "https://github.com/rustfs/gateway.git", rev = "7915d06950f88611d883f6ab3d95efc90c65dec0", version = "0.2.0", default-features = false }
# The gateway framework itself, consumed for its extension traits by the ring-2
# adapter. `default-features = false` keeps the `server` feature, and with it the
# server crate, out of the build.
rustfs-gateway = { git = "https://github.com/rustfs/gateway.git", rev = "2a6b8d1f7663db978d8784ab3ea331cade19237b", version = "0.63.0", default-features = false }
rustfs-gateway = { git = "https://github.com/rustfs/gateway.git", rev = "7915d06950f88611d883f6ab3d95efc90c65dec0", version = "0.62.0", default-features = false }
# Test-only: builds the `EffectiveHost` a host-resolution test queries with.
rustfs-gateway-http = { git = "https://github.com/rustfs/gateway.git", rev = "2a6b8d1f7663db978d8784ab3ea331cade19237b", default-features = false }
rustfs-gateway-http = { git = "https://github.com/rustfs/gateway.git", rev = "7915d06950f88611d883f6ab3d95efc90c65dec0", default-features = false }
# Async Runtime and Networking
async-channel = "2.5.0"
@@ -213,7 +211,7 @@ bytesize = "2.7.0"
byteorder = "1.5.0"
flatbuffers = "25.12.19"
form_urlencoded = "1.2.2"
prost = "0.14.6"
prost = "0.14.5"
quick-xml = "0.42.0"
rmp = { version = "0.8.15" }
rmp-serde = { version = "1.3.1" }
@@ -235,7 +233,7 @@ blake2 = "0.11.0"
chacha20poly1305 = { version = "0.11.0" }
crc-fast = "1.10.0"
hmac = { version = "0.13.0" }
jsonwebtoken = { version = "12.0.0" }
jsonwebtoken = { version = "11.1.0" }
openidconnect = { default-features = false, version = "4.1.0" }
pbkdf2 = "0.13.0"
p256 = { version = "0.14.0", features = ["ecdsa", "pkcs8"] }
@@ -308,12 +306,10 @@ hostname = "0.4.2"
ipnetwork = { version = "0.21.1" }
lazy_static = "1.5.1"
libc = "0.2.191"
cuobject = "0.1.0"
libsystemd = "0.7.2"
local-ip-address = "0.6.13"
log = "0.4"
memmap2 = "0.9.12"
nixl-sys = { git = "https://github.com/houseme/nixl", rev = "cc636c83f13d692e85b67e55aed092413d16fb41" }
lz4 = "1.28.1"
lz4_flex = { version = "=0.14.0", default-features = false, features = ["std", "frame"] }
matchit = "0.9.2"
@@ -337,7 +333,7 @@ pretty_assertions = "1.4.1"
rand = { version = "0.10.3" }
ratelimit = "2.0.0"
rayon = "1.12.0"
rustfs-erasure-codec = { version = "9.1.0" }
rustfs-erasure-codec = { version = "9.0.0" }
reed-solomon-simd = "3.1.0"
regex = { version = "1.13.1" }
rumqttc = { package = "rumqttc-next", version = "0.34.0" }
@@ -400,7 +396,7 @@ opentelemetry-stdout = { version = "0.33.1" }
pyroscope = { version = "2.1.5" }
# FTP and SFTP
libunftp = { version = "0.25.0" }
libunftp = { version = "0.24.0" }
unftp-core = "0.1.1"
suppaftp = { version = "12.2.1" }
rcgen = { version = "0.14.10", default-features = false, features = ["aws_lc_rs", "crypto", "pem"] }
-7
View File
@@ -170,17 +170,10 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
;; \
esac
# `RC_RELEASE=disabled` is reserved for local server-only validation when the
# GitHub release asset is unavailable. The placeholder fails if invoked, so a
# production image that needs the CLI must keep the default release download.
# TARGETARCH is only provided by BuildKit. Fall back to TARGETPLATFORM (for
# example set by docker-compose) and then to the build host, like the cargo
# step above, so every path that builds this file passes a real architecture.
RUN set -eu; \
if [ "${RC_RELEASE}" = "disabled" ]; then \
install -m 0755 /bin/false /usr/local/bin/rc; \
exit 0; \
fi; \
rc_arch="${TARGETARCH:-}"; \
if [ -z "${rc_arch}" ]; then \
case "${TARGETPLATFORM:-}" in \
-4
View File
@@ -311,10 +311,6 @@ x env use rustfs
rustfs --help
```
### 7\. Docker Swarm with the SwarmCLI chart (Option 7)
Follow the [SwarmCLI chart guide](https://docs.rustfs.com/en/installation/cloud-native/swarmcli-chart) to run RustFS on Docker Swarm, as a single-node service or a distributed, erasure-coded cluster with one peer per node, with the open-source [SwarmCLI `rustfs` chart](https://github.com/Eldara-Tech/swarmcli-charts/tree/main/charts/rustfs). The chart keeps the root credentials in Docker secrets and refuses the default `rustfsadmin` keys, upgrades and rolls back as versioned releases, and can serve the S3 API over HTTPS through Traefik. Its Console stays off until you enable it. The chart and [SwarmCLI](https://github.com/Eldara-Tech/swarmcli) are maintained by Eldara Tech, not by the RustFS project.
---
### Accessing RustFS
-4
View File
@@ -239,10 +239,6 @@ x env use rustfs
rustfs --help
```
### 7\. 使用 SwarmCLI Chart 部署到 Docker Swarm (Option 7)
请按照 [SwarmCLI Chart 指南](https://docs.rustfs.com/zh/installation/cloud-native/swarmcli-chart),使用开源的 [SwarmCLI `rustfs` Chart](https://github.com/Eldara-Tech/swarmcli-charts/tree/main/charts/rustfs) 在 Docker Swarm 上运行 RustFS,可部署为单节点服务,或每个节点一个对等节点、采用纠删码的分布式集群。该 Chart 将 root 凭证保存在 Docker Secret 中并拒绝默认的 `rustfsadmin` 密钥,以带版本的发布进行升级和回滚,并可通过 Traefik 以 HTTPS 提供 S3 API。控制台默认关闭,需要时再启用。该 Chart 和 [SwarmCLI](https://github.com/Eldara-Tech/swarmcli) 由 Eldara Tech 维护,并非 RustFS 项目的一部分。
---
### 访问 RustFS
+4 -3
View File
@@ -30,11 +30,12 @@ workspace = true
[features]
default = []
hotpath = []
hotpath-alloc = ["hotpath"]
hotpath-cpu = ["hotpath"]
hotpath = ["hotpath/hotpath"]
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]
hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"]
[dependencies]
hotpath.workspace = true
bytes = { workspace = true, features = ["serde"] }
crc-fast = { workspace = true }
http = { workspace = true }
+4 -3
View File
@@ -30,12 +30,13 @@ workspace = true
[features]
default = []
test-util = []
hotpath = []
hotpath-alloc = ["hotpath"]
hotpath-cpu = ["hotpath"]
hotpath = ["hotpath/hotpath", "hotpath/tokio"]
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]
hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"]
[dependencies]
arc-swap.workspace = true
hotpath.workspace = true
tokio = { workspace = true, features = ["fs", "rt-multi-thread"] }
tonic = { workspace = true, features = ["gzip", "deflate"] }
uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] }
-157
View File
@@ -23,80 +23,7 @@ pub static GLOBAL_LOCAL_NODE_NAME: LazyLock<RwLock<String>> = LazyLock::new(|| R
pub static GLOBAL_RUSTFS_HOST: LazyLock<RwLock<String>> = LazyLock::new(|| RwLock::new("".to_string()));
pub static GLOBAL_RUSTFS_PORT: LazyLock<RwLock<String>> = LazyLock::new(|| RwLock::new("9000".to_string()));
pub static GLOBAL_RUSTFS_ADDR: LazyLock<RwLock<String>> = LazyLock::new(|| RwLock::new("".to_string()));
static NEXT_GRPC_CHANNEL_ID: AtomicU64 = AtomicU64::new(1);
static NEXT_GRPC_CONNECTION_GENERATION: AtomicU64 = AtomicU64::new(1);
#[derive(Debug)]
struct GrpcConnectionStateInner {
channel_id: u64,
generation: AtomicU64,
}
/// Lock-free identity and physical-connection generation shared by every clone of one gRPC channel.
#[derive(Clone, Debug)]
pub struct GrpcConnectionState(Arc<GrpcConnectionStateInner>);
/// A point-in-time identity for the physical connection currently used by a gRPC channel.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct GrpcConnectionSnapshot {
pub channel_id: u64,
pub generation: u64,
}
impl GrpcConnectionState {
pub fn new() -> Self {
Self(Arc::new(GrpcConnectionStateInner {
channel_id: next_nonzero_id(&NEXT_GRPC_CHANNEL_ID),
generation: AtomicU64::new(0),
}))
}
/// Publish a successfully opened physical transport before tonic makes it request-ready.
pub fn record_connected(&self) -> GrpcConnectionSnapshot {
let generation = next_nonzero_id(&NEXT_GRPC_CONNECTION_GENERATION);
self.0.generation.store(generation, Ordering::Release);
GrpcConnectionSnapshot {
channel_id: self.0.channel_id,
generation,
}
}
/// Return `None` until the first physical transport has connected successfully.
pub fn snapshot(&self) -> Option<GrpcConnectionSnapshot> {
let generation = self.0.generation.load(Ordering::Acquire);
(generation != 0).then_some(GrpcConnectionSnapshot {
channel_id: self.0.channel_id,
generation,
})
}
}
impl Default for GrpcConnectionState {
fn default() -> Self {
Self::new()
}
}
fn next_nonzero_id(counter: &AtomicU64) -> u64 {
loop {
let id = counter.fetch_add(1, Ordering::Relaxed);
if id != 0 {
return id;
}
}
}
pub static GLOBAL_CONN_MAP: LazyLock<RwLock<HashMap<String, Channel>>> = LazyLock::new(|| RwLock::new(HashMap::new()));
#[derive(Clone)]
struct TrackedGrpcConnection {
channel: Channel,
connection_state: GrpcConnectionState,
}
static GLOBAL_TRACKED_CONN_MAP: LazyLock<RwLock<HashMap<String, TrackedGrpcConnection>>> =
LazyLock::new(|| RwLock::new(HashMap::new()));
static GLOBAL_CONN_CACHE_WRITER: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
pub static GLOBAL_ROOT_CERT: LazyLock<RwLock<Option<Vec<u8>>>> = LazyLock::new(|| RwLock::new(None));
pub static GLOBAL_MTLS_IDENTITY: LazyLock<RwLock<Option<MtlsIdentityPem>>> = LazyLock::new(|| RwLock::new(None));
pub static GLOBAL_OUTBOUND_TLS_GENERATION: LazyLock<AtomicU64> = LazyLock::new(|| AtomicU64::new(0));
@@ -304,16 +231,6 @@ pub async fn evict_connection(addr: &str) {
/// Evict a stale/dead connection from the global connection cache with an explicit log level.
pub async fn evict_connection_with_log_level(addr: &str, log_level: ConnectionEvictionLogLevel) {
let _ = remove_connection_with_log_level(addr, log_level).await;
}
/// Remove a cached connection and report whether it existed. Transport owners use this to
/// attach a rebuild reason only to real cache transitions.
pub async fn remove_connection_with_log_level(addr: &str, log_level: ConnectionEvictionLogLevel) -> bool {
// Writes are rare and serialized so the optimized tracked cache and public compatibility map
// cannot publish different channel clones for one key.
let _writer = GLOBAL_CONN_CACHE_WRITER.lock().await;
GLOBAL_TRACKED_CONN_MAP.write().await.remove(addr);
let removed = GLOBAL_CONN_MAP.write().await.remove(addr);
if removed.is_some() {
match log_level {
@@ -337,7 +254,6 @@ pub async fn remove_connection_with_log_level(addr: &str, log_level: ConnectionE
}
}
}
removed.is_some()
}
/// Get a cached gRPC connection for the given address.
@@ -345,37 +261,8 @@ pub async fn cached_connection(addr: &str) -> Option<Channel> {
GLOBAL_CONN_MAP.read().await.get(addr).cloned()
}
/// Get a cached channel together with its shared physical-connection state, when tracked.
pub async fn cached_connection_with_state(addr: &str) -> Option<(Channel, Option<GrpcConnectionState>)> {
if let Some(cached) = GLOBAL_TRACKED_CONN_MAP.read().await.get(addr).cloned() {
return Some((cached.channel, Some(cached.connection_state)));
}
// A miss may race a low-frequency publish/evict. Serialize only this fallback, recheck the
// tracked map, then consult legacy entries injected through the compatibility API.
let _writer = GLOBAL_CONN_CACHE_WRITER.lock().await;
if let Some(cached) = GLOBAL_TRACKED_CONN_MAP.read().await.get(addr).cloned() {
return Some((cached.channel, Some(cached.connection_state)));
}
cached_connection(addr).await.map(|channel| (channel, None))
}
/// Cache a gRPC connection for the given address.
pub async fn cache_connection(addr: String, channel: Channel) {
let _writer = GLOBAL_CONN_CACHE_WRITER.lock().await;
GLOBAL_TRACKED_CONN_MAP.write().await.remove(&addr);
GLOBAL_CONN_MAP.write().await.insert(addr, channel);
}
/// Cache a gRPC channel and its physical-connection state as one coherent entry.
pub async fn cache_connection_with_state(addr: String, channel: Channel, connection_state: GrpcConnectionState) {
let _writer = GLOBAL_CONN_CACHE_WRITER.lock().await;
GLOBAL_TRACKED_CONN_MAP.write().await.insert(
addr.clone(),
TrackedGrpcConnection {
channel: channel.clone(),
connection_state,
},
);
GLOBAL_CONN_MAP.write().await.insert(addr, channel);
}
@@ -392,8 +279,6 @@ pub async fn has_cached_connection(addr: &str) -> bool {
/// Clear all cached connections. Useful for full cluster reset/recovery.
pub async fn clear_all_connections() {
let _writer = GLOBAL_CONN_CACHE_WRITER.lock().await;
GLOBAL_TRACKED_CONN_MAP.write().await.clear();
let mut map = GLOBAL_CONN_MAP.write().await;
let count = map.len();
map.clear();
@@ -478,46 +363,4 @@ mod tls_snapshot_tests {
assert!(!debug.contains("PRIVATE-KEY-MARKER"));
assert!(debug.contains("[REDACTED]"));
}
#[tokio::test]
async fn conditional_connection_removal_preserves_legacy_evict_api() {
let key = "http://conditional-eviction-test.invalid";
cache_connection(
key.to_owned(),
tonic::transport::Endpoint::from_static("http://127.0.0.1:1").connect_lazy(),
)
.await;
assert!(remove_connection_with_log_level(key, ConnectionEvictionLogLevel::Debug).await);
assert!(!remove_connection_with_log_level(key, ConnectionEvictionLogLevel::Debug).await);
let _: () = evict_connection_with_log_level(key, ConnectionEvictionLogLevel::Debug).await;
}
#[tokio::test]
async fn cached_connection_keeps_channel_and_transport_state_coherent() {
let key = "http://tracked-connection-test.invalid";
let channel = tonic::transport::Endpoint::from_static("http://127.0.0.1:1").connect_lazy();
let state = GrpcConnectionState::new();
assert!(state.snapshot().is_none());
let first = state.record_connected();
cache_connection_with_state(key.to_owned(), channel, state.clone()).await;
let (_, cached_state) = cached_connection_with_state(key).await.expect("tracked cache entry");
let cached_state = cached_state.expect("tracked cache state");
assert_eq!(cached_state.snapshot(), Some(first));
let second = state.record_connected();
assert_eq!(cached_state.snapshot(), Some(second));
assert_eq!(first.channel_id, second.channel_id);
assert_ne!(first.generation, second.generation);
cache_connection(
key.to_owned(),
tonic::transport::Endpoint::from_static("http://127.0.0.1:2").connect_lazy(),
)
.await;
let (_, replacement_state) = cached_connection_with_state(key).await.expect("legacy replacement entry");
assert!(replacement_state.is_none(), "legacy replacement must remove stale tracked state");
assert!(remove_connection_with_log_level(key, ConnectionEvictionLogLevel::Debug).await);
assert!(cached_connection_with_state(key).await.is_none());
}
}
+4 -3
View File
@@ -25,6 +25,7 @@ keywords = ["configuration", "settings", "management", "rustfs", "Minio"]
categories = ["web-programming", "development-tools", "config"]
[dependencies]
hotpath.workspace = true
const-str = { workspace = true, optional = true, features = ["std", "proc"] }
serde = { workspace = true, optional = true, features = ["derive"] }
serde_json = { workspace = true, optional = true, features = ["raw_value"] }
@@ -34,9 +35,9 @@ workspace = true
[features]
default = ["constants"]
hotpath = []
hotpath-alloc = ["hotpath"]
hotpath-cpu = ["hotpath"]
hotpath = ["hotpath/hotpath"]
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]
hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"]
audit = ["dep:const-str", "constants"]
constants = ["dep:const-str"]
notify = ["dep:const-str", "constants"]
-11
View File
@@ -121,11 +121,6 @@ when restoring `/rustfs/console` for a custom OEM build.
- `RUSTFS_SCANNER_CYCLE_MAX_DURATION_SECS` (canonical)
- `RUSTFS_SCANNER_CYCLE_MAX_OBJECTS` (canonical)
- `RUSTFS_SCANNER_CYCLE_MAX_DIRECTORIES` (canonical)
- `RUSTFS_SCANNER_BUCKET_QUANTUM_DURATION_SECS` (canonical)
- `RUSTFS_SCANNER_BUCKET_QUANTUM_OBJECTS` (canonical)
- `RUSTFS_SCANNER_BUCKET_QUANTUM_DIRECTORIES` (canonical)
- `RUSTFS_SCANNER_BUCKET_QUANTUM_ENTRIES` (canonical)
- `RUSTFS_SCANNER_BUCKET_QUANTUM_NAME_BYTES` (canonical)
- `RUSTFS_SCANNER_MAX_CONCURRENT_SET_SCANS` (canonical)
- `RUSTFS_SCANNER_MAX_CONCURRENT_DISK_SCANS` (canonical)
- `RUSTFS_SCANNER_WALKERS_PER_DISK` (canonical)
@@ -135,12 +130,6 @@ Scanner cycle budget controls:
- When `RUSTFS_SCANNER_CYCLE_MAX_DURATION_SECS` is unset, the finite default is 1800 seconds (30 minutes), matching the scanner benchmark guidance.
- An explicit `0` preserves the compatibility behavior of an unbounded runtime budget. Object and directory budgets likewise remain unbounded when explicitly set to `0`.
Scanner bucket quantum controls:
- `RUSTFS_SCANNER_BUCKET_QUANTUM_DURATION_SECS`, `RUSTFS_SCANNER_BUCKET_QUANTUM_OBJECTS`, `RUSTFS_SCANNER_BUCKET_QUANTUM_DIRECTORIES`, `RUSTFS_SCANNER_BUCKET_QUANTUM_ENTRIES`, and `RUSTFS_SCANNER_BUCKET_QUANTUM_NAME_BYTES` cap one bucket admission. Their persistent keys are `scanner.bucket_quantum_duration`, `scanner.bucket_quantum_objects`, `scanner.bucket_quantum_directories`, `scanner.bucket_quantum_entries`, and `scanner.bucket_quantum_name_bytes`; duration is in whole seconds and the remaining keys are work counts or bytes.
- All five defaults are `0` for controlled rollout. A positive value enables that dimension; `0` disables that dimension, and all five zero values disable the bucket quantum. Parent cycle limits remain in force. Invalid unsigned integers and durations outside the platform timer range are rejected; environment overrides take precedence but cannot hide invalid persisted values. Admin scanner status reports each effective value and source under `runtime_config.bucket_quantum_*`, using `bucket_quantum_duration_seconds` for duration.
- Disabled defaults are an initial rollout state, not completion of usage-convergence acceptance. Production defaults require matched-topology A/B measurements and the remote progress/fairness checks in [Scanner runtime controls](../../docs/operations/scanner-runtime-controls.md#bucket-quantum-rollout-and-acceptance). These controls do not certify partial usage or acknowledge pending dirty work.
Scanner recovery retry controls:
- `RUSTFS_SCANNER_RECOVERY_BACKOFF_CAP_SECS` caps the wait between automatic startup recovery retries. The persistent admin key is `scanner.recovery_backoff_cap`; the environment takes precedence over the persistent value, and the unset default remains 600 seconds (10 minutes). Values must be positive integer seconds within the platform timer range; `0`, malformed values, and overflow are rejected. A valid environment override does not hide an invalid persistent value from `admin config set` validation.
+2 -2
View File
@@ -35,8 +35,8 @@ pub const DEFAULT_HEALTH_OBJECT_PROGRESS_TIMEOUT_MS: u64 = 30_000;
/// Additional time beyond the configured object-lock acquisition deadline.
pub const HEALTH_OBJECT_PROGRESS_LOCK_MARGIN_MS: u64 = 5_000;
/// End-to-end budget for cluster health readiness probes (milliseconds).
/// Includes cache/singleflight waiting, storage observations, and lock checks.
/// Timeout for cluster health readiness collectors (milliseconds).
/// This bounds expensive storage and lock quorum checks used by cluster probes.
pub const ENV_HEALTH_CLUSTER_TIMEOUT_MS: &str = "RUSTFS_HEALTH_CLUSTER_TIMEOUT_MS";
pub const DEFAULT_HEALTH_CLUSTER_TIMEOUT_MS: u64 = 2000;
+2 -145
View File
@@ -121,17 +121,9 @@ pub const DEFAULT_INTERNODE_RPC_MSGPACK_ONLY: bool = false;
pub const ENV_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED: &str = "RUSTFS_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED";
pub const DEFAULT_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED: bool = false;
/// Permit current per-peer capability proof to replace fleet-wide confirmation.
///
/// This remains ineffective unless [`ENV_INTERNODE_RPC_MSGPACK_ONLY`] is also enabled. Unknown,
/// unsupported, revoked, or stale connection generations keep dual-writing JSON.
pub const ENV_INTERNODE_RPC_MSGPACK_PEER_CAPABILITY: &str = "RUSTFS_INTERNODE_RPC_MSGPACK_PEER_CAPABILITY";
pub const DEFAULT_INTERNODE_RPC_MSGPACK_PEER_CAPABILITY: bool = false;
// Compile-time invariants: dual-write by default so the base build is byte-for-byte legacy behavior.
const _: () = assert!(!DEFAULT_INTERNODE_RPC_MSGPACK_ONLY);
const _: () = assert!(!DEFAULT_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED);
const _: () = assert!(!DEFAULT_INTERNODE_RPC_MSGPACK_PEER_CAPABILITY);
/// Require target-bound v2 signatures on every internode gRPC request, rejecting the legacy
/// constant-target fallback instead of accepting it (<https://github.com/rustfs/backlog/issues/1327>).
@@ -302,14 +294,6 @@ pub const DEFAULT_INTERNODE_BULK_CONCURRENCY_LIMIT: usize = 64;
pub const ENV_INTERNODE_BULK_BUFFER_SIZE: &str = "RUSTFS_INTERNODE_BULK_BUFFER_SIZE";
pub const DEFAULT_INTERNODE_BULK_BUFFER_SIZE: usize = 1024;
/// Per-peer limit held through complete bulk-unary response decoding and validation. Zero keeps
/// the compatibility behavior with no additional admission gate.
pub const ENV_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT: &str = "RUSTFS_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT";
pub const DEFAULT_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT: usize = 0;
pub const ENV_INTERNODE_BULK_BODY_WAIT_TIMEOUT_MS: &str = "RUSTFS_INTERNODE_BULK_BODY_WAIT_TIMEOUT_MS";
pub const DEFAULT_INTERNODE_BULK_BODY_WAIT_TIMEOUT_MS: u64 = 1_000;
const _: () = assert!(DEFAULT_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT == 0);
/// Profile selector for conservative internode HTTP data-plane client tuning.
pub const ENV_INTERNODE_HTTP_TUNING_PROFILE: &str = "RUSTFS_INTERNODE_HTTP_TUNING_PROFILE";
pub const DEFAULT_INTERNODE_HTTP_TUNING_PROFILE: &str = "legacy";
@@ -349,130 +333,8 @@ pub const DEFAULT_INTERNODE_DATA_TRANSPORT: &str = "tcp-http";
/// Legacy alias for "tcp-http". Both values select the TCP/HTTP transport backend.
pub const INTERNODE_DATA_TRANSPORT_TCP: &str = "tcp";
/// Internode reads whose data moves over NIXL/UCX (InfiniBand rails or RoCE by
/// LID/GID, no IP needed); requests, writes and walks stay on TCP/HTTP. Requires
/// a binary built with the `nixl` feature and `RUSTFS_NIXL_ENABLE`; until the
/// NIXL agent is up, and for any read it cannot serve, it uses TCP/HTTP.
pub const INTERNODE_DATA_TRANSPORT_NIXL: &str = "nixl";
/// Known internode transport backend names accepted by the config parser.
pub const KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS: &[&str] = &[
DEFAULT_INTERNODE_DATA_TRANSPORT,
INTERNODE_DATA_TRANSPORT_TCP,
INTERNODE_DATA_TRANSPORT_NIXL,
];
/// Check the configured RDMA devices at startup and leave out any that is down,
/// slower than its peers, or loses its link during a short watch.
pub const ENV_RUSTFS_NIXL_DEVICE_CHECK: &str = "RUSTFS_NIXL_DEVICE_CHECK";
pub const DEFAULT_RUSTFS_NIXL_DEVICE_CHECK: bool = true;
/// Leave out a device whose link dropped this many times more since boot than
/// the quietest device of its link layer; 0 skips this test.
pub const ENV_RUSTFS_NIXL_DEVICE_MAX_LINK_DROPS: &str = "RUSTFS_NIXL_DEVICE_MAX_LINK_DROPS";
pub const DEFAULT_RUSTFS_NIXL_DEVICE_MAX_LINK_DROPS: u64 = 16;
/// How long the startup device check watches the link counters; 0 skips the watch.
pub const ENV_RUSTFS_NIXL_DEVICE_FLAP_WINDOW_MS: &str = "RUSTFS_NIXL_DEVICE_FLAP_WINDOW_MS";
pub const DEFAULT_RUSTFS_NIXL_DEVICE_FLAP_WINDOW_MS: u64 = 3_000;
/// NIXL internode reads in flight per remote shard stream.
pub const ENV_RUSTFS_NIXL_INTERNODE_DEPTH: &str = "RUSTFS_NIXL_INTERNODE_DEPTH";
pub const DEFAULT_RUSTFS_NIXL_INTERNODE_DEPTH: usize = 4;
/// Whether S3 GETs and PUTs carrying the NIXL headers are served over NIXL/UCX
/// S3-over-RDMA (requires a build with the `nixl` feature and libnixl). The
/// pipeline settings below (`RUSTFS_CUOBJECT_GET_FANOUT*`, `_INFLIGHT_WRITES`,
/// `_SHARD_ARENA_BYTES`) apply to this transport as well.
pub const ENV_RUSTFS_NIXL_ENABLE: &str = "RUSTFS_NIXL_ENABLE";
pub const DEFAULT_RUSTFS_NIXL_ENABLE: bool = false;
/// This node's NIXL agent name; defaults to `rustfs-<first local endpoint host>`.
pub const ENV_RUSTFS_NIXL_AGENT_NAME: &str = "RUSTFS_NIXL_AGENT_NAME";
/// Comma-separated UCX device names (`mlx5_9,mlx5_10`; NIXL adds the port); empty lets UCX use every device.
pub const ENV_RUSTFS_NIXL_UCX_DEVICES: &str = "RUSTFS_NIXL_UCX_DEVICES";
/// UCX progress workers of the agent.
pub const ENV_RUSTFS_NIXL_NUM_WORKERS: &str = "RUSTFS_NIXL_NUM_WORKERS";
pub const DEFAULT_RUSTFS_NIXL_NUM_WORKERS: u32 = 1;
/// Staging chunk size per transfer descriptor to a client.
pub const ENV_RUSTFS_NIXL_CHUNK_BYTES: &str = "RUSTFS_NIXL_CHUNK_BYTES";
pub const DEFAULT_RUSTFS_NIXL_CHUNK_BYTES: usize = 16 * 1024 * 1024;
/// Registered staging memory of the agent.
pub const ENV_RUSTFS_NIXL_POOL_BYTES: &str = "RUSTFS_NIXL_POOL_BYTES";
pub const DEFAULT_RUSTFS_NIXL_POOL_BYTES: usize = 1024 * 1024 * 1024;
/// Transfers in flight per node at most.
pub const ENV_RUSTFS_NIXL_MAX_INFLIGHT: &str = "RUSTFS_NIXL_MAX_INFLIGHT";
pub const DEFAULT_RUSTFS_NIXL_MAX_INFLIGHT: usize = 256;
/// A transfer that has not completed after this many seconds fails the request.
pub const ENV_RUSTFS_NIXL_TRANSFER_TIMEOUT_SECS: &str = "RUSTFS_NIXL_TRANSFER_TIMEOUT_SECS";
pub const DEFAULT_RUSTFS_NIXL_TRANSFER_TIMEOUT_SECS: u64 = 60;
/// Whether S3 GETs carrying an `x-amz-rdma-token` are served over cuObject S3-over-RDMA
/// (requires a build with the `cuobject` feature and libcuobjserver).
pub const ENV_RUSTFS_CUOBJECT_ENABLE: &str = "RUSTFS_CUOBJECT_ENABLE";
pub const DEFAULT_RUSTFS_CUOBJECT_ENABLE: bool = false;
/// Comma-separated RDMA-capable IP addresses that get a cuObject server each.
/// Defaults to the hosts of this node's own endpoints.
pub const ENV_RUSTFS_CUOBJECT_ADDRS: &str = "RUSTFS_CUOBJECT_ADDRS";
/// UDP/RDMA control port of the cuObject servers.
pub const ENV_RUSTFS_CUOBJECT_PORT: &str = "RUSTFS_CUOBJECT_PORT";
pub const DEFAULT_RUSTFS_CUOBJECT_PORT: u16 = 18515;
/// Staging chunk size per RDMA write to a client.
pub const ENV_RUSTFS_CUOBJECT_CHUNK_BYTES: &str = "RUSTFS_CUOBJECT_CHUNK_BYTES";
pub const DEFAULT_RUSTFS_CUOBJECT_CHUNK_BYTES: usize = 16 * 1024 * 1024;
/// Registered staging memory per cuObject server.
pub const ENV_RUSTFS_CUOBJECT_POOL_BYTES: &str = "RUSTFS_CUOBJECT_POOL_BYTES";
pub const DEFAULT_RUSTFS_CUOBJECT_POOL_BYTES: usize = 1024 * 1024 * 1024;
/// Dynamically connected initiators per cuObject server (concurrent client connections).
/// Staging chunks (RDMA writes) kept in flight per GET, so decoding never waits
/// for the write of the previous chunk; each costs one chunk of the pool.
pub const ENV_RUSTFS_CUOBJECT_INFLIGHT_WRITES: &str = "RUSTFS_CUOBJECT_INFLIGHT_WRITES";
pub const DEFAULT_RUSTFS_CUOBJECT_INFLIGHT_WRITES: usize = 3;
/// Staging chunks (RDMA reads from the client buffer) kept in flight per
/// RDMA PUT body, so ingest never waits on one chunk's round trip at a time;
/// each costs one chunk of the pool.
pub const ENV_RUSTFS_CUOBJECT_PUT_READ_AHEAD: &str = "RUSTFS_CUOBJECT_PUT_READ_AHEAD";
pub const DEFAULT_RUSTFS_CUOBJECT_PUT_READ_AHEAD: usize = 4;
/// Concurrent erasure-block-aligned segments one cuObject GET is split into
/// on the server (each segment decodes and RDMA-writes its own stripes), so a
/// single stream keeps several stripes in flight. 1 disables the fan-out.
pub const ENV_RUSTFS_CUOBJECT_GET_FANOUT: &str = "RUSTFS_CUOBJECT_GET_FANOUT";
pub const DEFAULT_RUSTFS_CUOBJECT_GET_FANOUT: usize = 8;
/// Smallest segment worth its own producer (rounded up to whole erasure
/// blocks): each segment pays a reader setup per part it touches, so short
/// requests stay sequential.
pub const ENV_RUSTFS_CUOBJECT_GET_FANOUT_MIN_BYTES: &str = "RUSTFS_CUOBJECT_GET_FANOUT_MIN_BYTES";
pub const DEFAULT_RUSTFS_CUOBJECT_GET_FANOUT_MIN_BYTES: u64 = 192 * 1024 * 1024;
/// Segment producers a node runs across all its cuObject GETs: each new GET
/// gets a fair share (budget / open GETs, at least 1, at most the fan-out)
/// and never waits for one, so many-stream load degrades to sequential GETs
/// instead of a reader-setup storm.
pub const ENV_RUSTFS_CUOBJECT_GET_FANOUT_BUDGET: &str = "RUSTFS_CUOBJECT_GET_FANOUT_BUDGET";
pub const DEFAULT_RUSTFS_CUOBJECT_GET_FANOUT_BUDGET: usize = 16;
/// Registered host memory the erasure decoder reads shards into so a
/// cuObject GET can RDMA-write data shards straight from those buffers
/// (zero-copy emit); 0 keeps the staging copy. Blocks are
/// `RUSTFS_ERASURE_SHARD_BYTES` (4 MiB when unset); objects with larger
/// shards fall back to heap buffers and the staging copy.
pub const ENV_RUSTFS_CUOBJECT_SHARD_ARENA_BYTES: &str = "RUSTFS_CUOBJECT_SHARD_ARENA_BYTES";
pub const DEFAULT_RUSTFS_CUOBJECT_SHARD_ARENA_BYTES: usize = 0;
pub const ENV_RUSTFS_CUOBJECT_NUM_DCIS: &str = "RUSTFS_CUOBJECT_NUM_DCIS";
pub const DEFAULT_RUSTFS_CUOBJECT_NUM_DCIS: u32 = 128;
/// Complete cuObject transfers through the library's asynchronous mode: the
/// write is submitted with a handle and the task waits on the channel's
/// completion descriptor instead of holding a blocking thread for the whole
/// transfer. `false` keeps one blocking library call per transfer.
pub const ENV_RUSTFS_CUOBJECT_ASYNC_TRANSFERS: &str = "RUSTFS_CUOBJECT_ASYNC_TRANSFERS";
pub const DEFAULT_RUSTFS_CUOBJECT_ASYNC_TRANSFERS: bool = true;
pub const KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS: &[&str] = &[DEFAULT_INTERNODE_DATA_TRANSPORT, INTERNODE_DATA_TRANSPORT_TCP];
#[cfg(test)]
mod tests {
@@ -517,12 +379,8 @@ mod tests {
fn internode_channel_isolation_defaults_and_env_names() {
// The isolation-off default is asserted at compile time next to the constant definition.
assert_eq!(DEFAULT_INTERNODE_BULK_CHANNELS, 2);
assert_eq!(DEFAULT_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT, 0);
assert_eq!(DEFAULT_INTERNODE_BULK_BODY_WAIT_TIMEOUT_MS, 1_000);
assert_eq!(ENV_INTERNODE_CHANNEL_ISOLATION, "RUSTFS_INTERNODE_CHANNEL_ISOLATION");
assert_eq!(ENV_INTERNODE_BULK_CHANNELS, "RUSTFS_INTERNODE_BULK_CHANNELS");
assert_eq!(ENV_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT, "RUSTFS_INTERNODE_BULK_BODY_CONCURRENCY_LIMIT");
assert_eq!(ENV_INTERNODE_BULK_BODY_WAIT_TIMEOUT_MS, "RUSTFS_INTERNODE_BULK_BODY_WAIT_TIMEOUT_MS");
}
#[test]
@@ -533,7 +391,6 @@ mod tests {
ENV_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED,
"RUSTFS_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED"
);
assert_eq!(ENV_INTERNODE_RPC_MSGPACK_PEER_CAPABILITY, "RUSTFS_INTERNODE_RPC_MSGPACK_PEER_CAPABILITY");
}
#[test]
@@ -608,6 +465,6 @@ mod tests {
assert_eq!(ENV_RUSTFS_INTERNODE_DATA_TRANSPORT, "RUSTFS_INTERNODE_DATA_TRANSPORT");
assert_eq!(DEFAULT_INTERNODE_DATA_TRANSPORT, "tcp-http");
assert_eq!(INTERNODE_DATA_TRANSPORT_TCP, "tcp");
assert_eq!(KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS, &["tcp-http", "tcp", "nixl"]);
assert_eq!(KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS, &["tcp-http", "tcp"]);
}
}
-50
View File
@@ -44,21 +44,6 @@ pub const SCANNER_CYCLE_MAX_OBJECTS: &str = "cycle_max_objects";
/// Scanner config key capping directories entered by one cycle.
pub const SCANNER_CYCLE_MAX_DIRECTORIES: &str = "cycle_max_directories";
/// Per-bucket admission limit in seconds; zero disables this dimension.
pub const SCANNER_BUCKET_QUANTUM_DURATION: &str = "bucket_quantum_duration";
/// Per-bucket admission limit in objects; zero disables this dimension.
pub const SCANNER_BUCKET_QUANTUM_OBJECTS: &str = "bucket_quantum_objects";
/// Per-bucket admission limit in directories; zero disables this dimension.
pub const SCANNER_BUCKET_QUANTUM_DIRECTORIES: &str = "bucket_quantum_directories";
/// Per-bucket admission limit in raw entries; zero disables this dimension.
pub const SCANNER_BUCKET_QUANTUM_ENTRIES: &str = "bucket_quantum_entries";
/// Per-bucket admission limit in raw entry-name bytes; zero disables this dimension.
pub const SCANNER_BUCKET_QUANTUM_NAME_BYTES: &str = "bucket_quantum_name_bytes";
/// Scanner config key setting the periodic bitrot scan cycle in seconds.
pub const SCANNER_BITROT_CYCLE: &str = "bitrot_cycle";
@@ -108,11 +93,6 @@ pub const SCANNER_KEYS: &[&str] = &[
SCANNER_CYCLE_MAX_DURATION,
SCANNER_CYCLE_MAX_OBJECTS,
SCANNER_CYCLE_MAX_DIRECTORIES,
SCANNER_BUCKET_QUANTUM_DURATION,
SCANNER_BUCKET_QUANTUM_OBJECTS,
SCANNER_BUCKET_QUANTUM_DIRECTORIES,
SCANNER_BUCKET_QUANTUM_ENTRIES,
SCANNER_BUCKET_QUANTUM_NAME_BYTES,
SCANNER_BITROT_CYCLE,
SCANNER_IDLE_MODE,
SCANNER_CACHE_SAVE_TIMEOUT,
@@ -161,36 +141,6 @@ pub const ENV_SCANNER_CYCLE_MAX_OBJECTS: &str = "RUSTFS_SCANNER_CYCLE_MAX_OBJECT
/// - Example: `export RUSTFS_SCANNER_CYCLE_MAX_DIRECTORIES=100000`
pub const ENV_SCANNER_CYCLE_MAX_DIRECTORIES: &str = "RUSTFS_SCANNER_CYCLE_MAX_DIRECTORIES";
/// Per-bucket admission limit in seconds; zero disables this dimension.
pub const ENV_SCANNER_BUCKET_QUANTUM_DURATION_SECS: &str = "RUSTFS_SCANNER_BUCKET_QUANTUM_DURATION_SECS";
/// Disabled until controlled-fleet acceptance selects production limits.
pub const DEFAULT_SCANNER_BUCKET_QUANTUM_DURATION_SECS: u64 = 0;
/// Per-bucket admission limit in objects; zero disables this dimension.
pub const ENV_SCANNER_BUCKET_QUANTUM_OBJECTS: &str = "RUSTFS_SCANNER_BUCKET_QUANTUM_OBJECTS";
/// Disabled until controlled-fleet acceptance selects production limits.
pub const DEFAULT_SCANNER_BUCKET_QUANTUM_OBJECTS: u64 = 0;
/// Per-bucket admission limit in directories; zero disables this dimension.
pub const ENV_SCANNER_BUCKET_QUANTUM_DIRECTORIES: &str = "RUSTFS_SCANNER_BUCKET_QUANTUM_DIRECTORIES";
/// Disabled until controlled-fleet acceptance selects production limits.
pub const DEFAULT_SCANNER_BUCKET_QUANTUM_DIRECTORIES: u64 = 0;
/// Per-bucket admission limit in raw entries; zero disables this dimension.
pub const ENV_SCANNER_BUCKET_QUANTUM_ENTRIES: &str = "RUSTFS_SCANNER_BUCKET_QUANTUM_ENTRIES";
/// Disabled until controlled-fleet acceptance selects production limits.
pub const DEFAULT_SCANNER_BUCKET_QUANTUM_ENTRIES: u64 = 0;
/// Per-bucket admission limit in raw entry-name bytes; zero disables this dimension.
pub const ENV_SCANNER_BUCKET_QUANTUM_NAME_BYTES: &str = "RUSTFS_SCANNER_BUCKET_QUANTUM_NAME_BYTES";
/// Disabled until controlled-fleet acceptance selects production limits.
pub const DEFAULT_SCANNER_BUCKET_QUANTUM_NAME_BYTES: u64 = 0;
/// Environment variable that selects the scanner speed preset.
/// Valid values: `fastest`, `fast`, `default`, `slow`, `slowest`.
/// Controls the sleep factor, maximum sleep duration, and cycle interval.
+4 -3
View File
@@ -26,11 +26,12 @@ categories = ["web-programming", "development-tools", "data-structures", "securi
[features]
default = []
hotpath = []
hotpath-alloc = ["hotpath"]
hotpath-cpu = ["hotpath"]
hotpath = ["hotpath/hotpath"]
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]
hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"]
[dependencies]
hotpath.workspace = true
base64-simd = { workspace = true }
hmac = { workspace = true }
rand = { workspace = true, features = ["serde"] }
+4 -3
View File
@@ -29,6 +29,7 @@ documentation = "https://docs.rs/rustfs-crypto/latest/rustfs_crypto/"
workspace = true
[dependencies]
hotpath.workspace = true
aes-gcm = { workspace = true, optional = true, features = ["rand_core"] }
argon2 = { workspace = true, optional = true }
chacha20poly1305 = { workspace = true, optional = true }
@@ -49,9 +50,9 @@ time = { workspace = true, features = ["parsing", "formatting", "macros", "serde
[features]
default = ["crypto", "fips"]
hotpath = []
hotpath-alloc = ["hotpath"]
hotpath-cpu = ["hotpath"]
hotpath = ["hotpath/hotpath"]
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]
hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"]
fips = []
crypto = [
"dep:aes-gcm",
+5 -2
View File
@@ -18,6 +18,9 @@ use crate::Error;
use crate::jwt::Claims;
pub fn decode(token: &str, token_secret: &[u8]) -> Result<TokenData<Claims>, Error> {
let key = DecodingKey::from_secret(token_secret)?;
Ok(jsonwebtoken::decode(token, &key, &Validation::new(Algorithm::HS512))?)
Ok(jsonwebtoken::decode(
token,
&DecodingKey::from_secret(token_secret),
&Validation::new(Algorithm::HS512),
)?)
}
+5 -2
View File
@@ -18,6 +18,9 @@ use crate::Error;
use crate::jwt::Claims;
pub fn encode(token_secret: &[u8], claims: &Claims) -> Result<String, Error> {
let key = EncodingKey::from_secret(token_secret)?;
Ok(jsonwebtoken::encode(&Header::new(Algorithm::HS512), claims, &key)?)
Ok(jsonwebtoken::encode(
&Header::new(Algorithm::HS512),
claims,
&EncodingKey::from_secret(token_secret),
)?)
}
-26
View File
@@ -1,26 +0,0 @@
[package]
name = "rustfs-cuobject"
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
homepage.workspace = true
description = "RustFS staging pool and transfers for NVIDIA cuObject S3-over-RDMA (GPUDirect object loading)"
keywords = ["rdma", "cuobject", "gpudirect", "s3"]
categories = ["network-programming"]
documentation = "https://docs.rs/rustfs-cuobject/latest/rustfs_cuobject/"
[lints]
workspace = true
[dependencies]
bytes = { workspace = true, optional = true }
cuobject = { workspace = true, default-features = false, optional = true }
parking_lot = { workspace = true, optional = true }
thiserror = { workspace = true, optional = true }
tokio = { workspace = true, features = ["net", "rt-multi-thread", "sync", "time"], optional = true }
[features]
# Compiles the cuObject server bindings (needs the NVIDIA cuObject SDK).
server = ["dep:bytes", "dep:cuobject", "cuobject/server", "dep:parking_lot", "dep:thiserror", "dep:tokio"]
-775
View File
@@ -1,775 +0,0 @@
// 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.
//! Server side of NVIDIA cuObject S3-over-RDMA.
//!
//! A client that supports the protocol (NVIDIA cuObject, NIXL's object plugin,
//! …) sends an ordinary S3 GET with an `x-amz-rdma-token` header describing a
//! registered client buffer (host or GPU memory). Instead of streaming the
//! body over HTTP, the server RDMA-writes the object bytes into that buffer
//! through NVIDIA's `libcuobjserver` and answers with an empty body plus
//! `x-amz-rdma-reply` and `x-amz-rdma-bytes-transferred`.
//!
//! The library bindings come from the [`cuobject`] crate. This crate owns
//! RustFS's pool of registered, page-aligned host staging buffers: the regular
//! read path fills a staging chunk and
//! [`CuObjectServer::write_to_client_owned`] pushes it.
//!
//! Everything below needs the `server` feature, which compiles the
//! NVIDIA cuObject server bindings; without it the crate is empty, so a
//! workspace build does not need the cuObject SDK.
#![cfg(feature = "server")]
use bytes::Bytes;
use cuobject::{Channel, Completion, RegisteredBuffer, Server, ServerOptions, SgBuffer, SgEntry, Source};
use std::collections::VecDeque;
use std::net::IpAddr;
use std::num::NonZeroUsize;
use std::sync::Arc;
use std::time::Duration;
use thiserror::Error;
use tokio::io::Interest;
use tokio::io::unix::AsyncFd;
use tokio::sync::Semaphore;
/// Header carrying the client's RDMA descriptor on a request.
pub const RDMA_TOKEN_HEADER: &str = cuobject::TOKEN_HEADER;
/// Header carrying the transfer status on the response (HTTP-style code).
pub const RDMA_REPLY_HEADER: &str = cuobject::REPLY_HEADER;
/// Header carrying the payload byte count moved over RDMA.
pub const RDMA_BYTES_TRANSFERRED_HEADER: &str = cuobject::BYTES_TRANSFERRED_HEADER;
/// Reply code for a declined transfer (the client then errors or falls back).
pub const RDMA_REPLY_NOT_IMPLEMENTED: u16 = cuobject::REPLY_NOT_IMPLEMENTED;
/// Largest single `handleGetObject` the library accepts.
pub const MAX_RDMA_OP_BYTES: usize = cuobject::MAX_TRANSFER_BYTES;
/// Default RDMA control port of the cuObject server.
pub const DEFAULT_PORT: u16 = cuobject::DEFAULT_PORT;
/// Most ranges one scatter-gather transfer may carry (the library's `max_sge`).
pub const MAX_SG_RANGES: usize = cuobject::DEFAULT_MAX_SG_ENTRIES;
/// Version of the cuObject server headers the bindings were built against, as
/// (major, minor).
pub fn library_version() -> (u32, u32) {
cuobject::header_version()
}
#[derive(Debug, Error)]
pub enum CuObjectError {
#[error("cuobject {op} failed: {source}")]
Os {
op: &'static str,
#[source]
source: std::io::Error,
},
#[error("cuobject rdma token is malformed: {0}")]
Token(String),
#[error("cuobject rdma token buffer ({buffer} bytes) is smaller than the response ({needed} bytes)")]
TokenTooSmall { buffer: u64, needed: u64 },
#[error("cuobject rejected the request: {0}")]
Invalid(&'static str),
#[error("cuobject transfer failed with verbs status {verbs_status}: {source}")]
Transfer {
verbs_status: i32,
#[source]
source: std::io::Error,
},
#[error("cuobject transfer moved {moved} of {expected} bytes")]
ShortTransfer { moved: u64, expected: u64 },
#[error("cuobject staging pool exhausted")]
PoolExhausted,
#[error("cuobject library offers no completion descriptor for channel {0}")]
AsyncUnavailable(u16),
#[error("cuobject read source failed: {0}")]
Source(#[source] std::io::Error),
}
impl From<cuobject::Error> for CuObjectError {
fn from(error: cuobject::Error) -> Self {
match error {
cuobject::Error::Library { op, source } => Self::Os { op, source },
cuobject::Error::Transfer { verbs_status, source } => Self::Transfer { verbs_status, source },
cuobject::Error::InvalidArgument(reason) => Self::Invalid(reason),
cuobject::Error::InvalidToken(reason) => Self::Token(reason.to_owned()),
cuobject::Error::TokenTooSmall { buffer, needed } => Self::TokenTooSmall { buffer, needed },
cuobject::Error::AsyncUnavailable(channel) => Self::AsyncUnavailable(channel),
other => Self::Os {
op: "cuobject",
source: std::io::Error::other(other),
},
}
}
}
/// Parsed `x-amz-rdma-token`.
///
/// Wire format (cuObject RDMA descriptor protocol): colon-separated hex
/// fields `addr:size:rkey:lid:dctn:gid_present:gid`; only the leading
/// address and size are interpreted here, the library consumes the rest.
#[derive(Debug, Clone)]
pub struct RdmaToken {
inner: cuobject::RdmaToken,
/// Start of the client buffer (a copy of the parsed field).
pub remote_addr: u64,
/// Length of the client buffer (a copy of the parsed field).
pub buffer_len: u64,
}
impl RdmaToken {
pub fn parse(raw: &str) -> Result<Self, CuObjectError> {
let inner = cuobject::RdmaToken::parse(raw)?;
Ok(Self {
remote_addr: inner.remote_addr(),
buffer_len: inner.buffer_len(),
inner,
})
}
pub fn as_str(&self) -> &str {
self.inner.as_str()
}
}
/// Tuning for one server instance.
#[derive(Debug, Clone)]
pub struct CuObjectConfig {
pub port: u16,
pub num_dcis: i32,
pub cq_depth: u32,
/// Size of one staging buffer; one RDMA write moves at most this much.
pub chunk_bytes: usize,
/// Total registered staging memory per server instance.
pub pool_bytes: usize,
/// Complete transfers through the library's asynchronous mode (submit,
/// then wait on the channel's completion descriptor) instead of one
/// blocking library call per transfer.
pub async_transfers: bool,
}
impl Default for CuObjectConfig {
fn default() -> Self {
Self {
port: DEFAULT_PORT,
num_dcis: 128,
cq_depth: 640,
chunk_bytes: 64 * 1024 * 1024,
pool_bytes: 1024 * 1024 * 1024,
async_transfers: true,
}
}
}
struct Staging {
buffer: RegisteredBuffer<Arc<Server>>,
free: parking_lot::Mutex<VecDeque<usize>>,
permits: Semaphore,
chunk_bytes: usize,
}
/// One cuObject server bound to the RDMA device that owns an IP address.
pub struct CuObjectServer {
server: Arc<Server>,
staging: Staging,
addr: IpAddr,
port: u16,
/// One permit per library channel (DC initiator): a transfer waits here
/// instead of failing with `EBUSY` when every channel is in use.
channels: Arc<Semaphore>,
async_transfers: bool,
}
impl std::fmt::Debug for CuObjectServer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CuObjectServer")
.field("addr", &self.addr)
.field("port", &self.port)
.field("chunk_bytes", &self.staging.chunk_bytes)
.finish()
}
}
/// Several byte ranges of one [`RegisteredArena`], sent in order as one
/// RDMA operation (at most [`MAX_SG_RANGES`]).
pub struct ArenaRanges {
pub arena: Arc<RegisteredArena>,
/// `(local_offset, len)` pairs, in stream order.
pub ranges: Vec<(usize, usize)>,
}
impl ArenaRanges {
pub fn total_len(&self) -> usize {
self.ranges.iter().map(|(_, len)| *len).sum()
}
}
/// A byte range of a [`RegisteredArena`] to send from.
pub struct ArenaRange {
pub arena: Arc<RegisteredArena>,
pub local_offset: usize,
pub len: usize,
}
/// Host memory registered with one server, owned by the caller (see
/// [`CuObjectServer::register_arena`]).
pub struct RegisteredArena {
buffer: RegisteredBuffer<Arc<Server>>,
server: Arc<CuObjectServer>,
id: u64,
}
impl RegisteredArena {
/// Length of the registered memory.
pub fn len(&self) -> usize {
self.buffer.len()
}
pub fn is_empty(&self) -> bool {
self.buffer.is_empty()
}
/// Process-unique id of this registration.
pub fn id(&self) -> u64 {
self.id
}
/// The server this memory is registered with.
pub fn server(&self) -> &Arc<CuObjectServer> {
&self.server
}
/// Raw pointer to the start of the registered memory. The memory lives as
/// long as this arena; callers hand out disjoint ranges of it and never
/// touch a range while a transfer sends it.
pub fn as_mut_ptr(&self) -> *mut u8 {
self.buffer.as_mut_ptr()
}
}
impl std::fmt::Debug for RegisteredArena {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RegisteredArena")
.field("id", &self.id)
.field("len", &self.len())
.finish()
}
}
/// A reserved staging chunk; returned to the pool on drop.
///
/// The chunk's index is unique while it is reserved, so its range of the
/// staging buffer has one owner. Transfers take the chunk by value, so no
/// Rust borrow of the range overlaps an RDMA operation on it.
pub struct StagingChunk {
server: Arc<CuObjectServer>,
index: usize,
len: usize,
}
impl StagingChunk {
pub fn capacity(&self) -> usize {
self.server.staging.chunk_bytes
}
/// Bytes currently staged.
pub fn len(&self) -> usize {
self.len
}
pub fn is_empty(&self) -> bool {
self.len == 0
}
/// Copies `data` at `self.len()` and advances the staged length.
pub fn append(&mut self, data: &[u8]) -> Result<(), CuObjectError> {
if self.len + data.len() > self.capacity() {
return Err(CuObjectError::Invalid("staging append exceeds chunk"));
}
self.spare_mut()?[..data.len()].copy_from_slice(data);
self.len += data.len();
Ok(())
}
pub fn clear(&mut self) {
self.len = 0;
}
pub fn is_full(&self) -> bool {
self.len >= self.capacity()
}
/// The bytes staged so far.
#[allow(unsafe_code)]
pub fn staged(&self) -> Result<&[u8], CuObjectError> {
// SAFETY: the range lies in this chunk (see the type docs); `&self`
// excludes `spare_mut`, and transfers own the chunk they move.
Ok(unsafe { self.server.staging.buffer.slice(self.start(), self.len)? })
}
/// The unfilled remainder of the chunk, for a reader to fill directly.
#[allow(unsafe_code)]
pub fn spare_mut(&mut self) -> Result<&mut [u8], CuObjectError> {
let len = self.capacity() - self.len;
// SAFETY: the range lies in this chunk (see the type docs) and
// `&mut self` excludes every other borrow of it.
Ok(unsafe { self.server.staging.buffer.slice_mut(self.start() + self.len, len)? })
}
/// Marks `n` more bytes of the spare area as staged.
pub fn advance(&mut self, n: usize) -> Result<(), CuObjectError> {
if self.len + n > self.capacity() {
return Err(CuObjectError::Invalid("staging advance exceeds chunk"));
}
self.len += n;
Ok(())
}
fn start(&self) -> usize {
self.index * self.capacity()
}
}
impl Drop for StagingChunk {
fn drop(&mut self) {
self.server.staging.free.lock().push_back(self.index);
self.server.staging.permits.add_permits(1);
}
}
/// The local side of one GET, owned by the transfer until the DMA finished.
enum Local {
/// A range of the staging buffer, inside a chunk the transfer also owns.
Staging { offset: usize, len: usize },
/// A range of a caller-owned arena.
Arena {
arena: Arc<RegisteredArena>,
offset: usize,
len: usize,
},
/// Several ranges of a caller-owned arena, sent as one operation.
ArenaList {
arena: Arc<RegisteredArena>,
entries: Vec<SgEntry>,
},
}
impl Local {
fn len(&self) -> usize {
match self {
Self::Staging { len, .. } | Self::Arena { len, .. } => *len,
Self::ArenaList { entries, .. } => entries.iter().map(|entry| entry.size).sum(),
}
}
}
/// Why an asynchronous GET did not complete.
enum AsyncFailure {
/// The library has no completion descriptor; nothing was submitted.
Unavailable,
/// The GET failed, or was never submitted; nothing is in flight.
Failed(CuObjectError),
/// Waiting failed after submission: the NIC may still read the memory.
InFlight(CuObjectError),
}
impl From<cuobject::Error> for AsyncFailure {
fn from(error: cuobject::Error) -> Self {
Self::Failed(error.into())
}
}
/// The handle of the one GET in flight on an asynchronous channel.
const ASYNC_HANDLE: NonZeroUsize = NonZeroUsize::MIN;
impl CuObjectServer {
/// Creates the server and its registered staging pool.
pub fn new(addr: IpAddr, config: &CuObjectConfig) -> Result<Arc<Self>, CuObjectError> {
if config.chunk_bytes == 0 || config.chunk_bytes > MAX_RDMA_OP_BYTES || config.pool_bytes < config.chunk_bytes {
return Err(CuObjectError::Invalid("invalid staging configuration"));
}
let mut options = ServerOptions::default();
// A non-positive count keeps the library default.
options.num_dcis = u32::try_from(config.num_dcis).unwrap_or(0);
options.cq_depth = config.cq_depth;
let server = Arc::new(Server::new(addr, config.port, &options)?);
let chunks = config.pool_bytes / config.chunk_bytes;
let buffer = RegisteredBuffer::new(Arc::clone(&server), chunks * config.chunk_bytes)?;
Ok(Arc::new(Self {
channels: Arc::new(Semaphore::new(usize::try_from(config.num_dcis).unwrap_or(1).max(1))),
async_transfers: config.async_transfers,
server,
staging: Staging {
buffer,
free: parking_lot::Mutex::new((0..chunks).collect()),
permits: Semaphore::new(chunks),
chunk_bytes: config.chunk_bytes,
},
addr,
port: config.port,
}))
}
pub fn addr(&self) -> IpAddr {
self.addr
}
pub fn port(&self) -> u16 {
self.port
}
pub fn chunk_bytes(&self) -> usize {
self.staging.chunk_bytes
}
/// Reserves one staging chunk, waiting up to `timeout` for a free one.
pub async fn reserve(self: &Arc<Self>, timeout: Duration) -> Result<StagingChunk, CuObjectError> {
let permit = tokio::time::timeout(timeout, self.staging.permits.acquire())
.await
.map_err(|_| CuObjectError::PoolExhausted)?
.map_err(|_| CuObjectError::PoolExhausted)?;
permit.forget();
let index = self.staging.free.lock().pop_front().ok_or(CuObjectError::PoolExhausted)?;
Ok(StagingChunk {
server: Arc::clone(self),
index,
len: 0,
})
}
/// Reserves one staging chunk without waiting; `None` when the pool is empty.
pub fn try_reserve(self: &Arc<Self>) -> Option<StagingChunk> {
let permit = self.staging.permits.try_acquire().ok()?;
permit.forget();
let index = self.staging.free.lock().pop_front()?;
Some(StagingChunk {
server: Arc::clone(self),
index,
len: 0,
})
}
/// Staging chunks currently free in the pool (a hint; another reservation may win).
pub fn available_chunks(&self) -> usize {
self.staging.permits.available_permits()
}
/// Registers `len` bytes of zero-filled, page-aligned host memory with this
/// server for callers that manage the memory themselves (a shard arena the
/// decoder reads into and the server RDMA-writes from without staging).
pub fn register_arena(self: &Arc<Self>, len: usize) -> Result<Arc<RegisteredArena>, CuObjectError> {
let buffer = RegisteredBuffer::new(Arc::clone(&self.server), len)?;
static NEXT_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
Ok(Arc::new(RegisteredArena {
buffer,
server: Arc::clone(self),
id: NEXT_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed),
}))
}
/// RDMA-writes the staged bytes of `chunk` to `token.remote_addr +
/// remote_offset`. The transfer owns the chunk until the DMA finished, so
/// cancelling the awaiting future can never release the staging slot under
/// an in-flight write. Returns the chunk with the byte count for reuse.
pub async fn write_to_client_owned(
self: &Arc<Self>,
key: &str,
token: &RdmaToken,
remote_offset: u64,
chunk: StagingChunk,
) -> Result<(u64, StagingChunk), CuObjectError> {
if chunk.is_empty() {
return Ok((0, chunk));
}
let local = Local::Staging {
offset: chunk.start(),
len: chunk.len(),
};
self.get_owned(key, token, remote_offset, local, chunk).await
}
/// RDMA-writes `source.len` bytes at `source.local_offset` of
/// `source.arena` to `token.remote_addr + remote_offset`, keeping `keep`
/// alive until the DMA finished (the caller passes whatever owns the arena
/// bytes). The arena must have been registered with this server.
pub async fn write_to_client_from_arena_owned<T: Send + 'static>(
self: &Arc<Self>,
key: &str,
token: &RdmaToken,
remote_offset: u64,
source: ArenaRange,
keep: T,
) -> Result<(u64, T), CuObjectError> {
if source.len == 0 {
return Ok((0, keep));
}
let local = Local::Arena {
arena: source.arena,
offset: source.local_offset,
len: source.len,
};
self.get_owned(key, token, remote_offset, local, keep).await
}
/// RDMA-writes all of `source.ranges` (in order, as one operation) to
/// `token.remote_addr + remote_offset`, keeping `keep` alive until the DMA
/// finished. The arena must have been registered with this server.
pub async fn write_to_client_sg_owned<T: Send + 'static>(
self: &Arc<Self>,
key: &str,
token: &RdmaToken,
remote_offset: u64,
source: ArenaRanges,
keep: T,
) -> Result<(u64, T), CuObjectError> {
if source.ranges.len() > MAX_SG_RANGES {
return Err(CuObjectError::Invalid("too many scatter-gather ranges"));
}
if source.total_len() == 0 {
return Ok((0, keep));
}
let entries = source
.ranges
.iter()
.map(|&(offset, size)| SgEntry {
offset: offset as u64,
size,
})
.collect();
let local = Local::ArenaList {
arena: source.arena,
entries,
};
self.get_owned(key, token, remote_offset, local, keep).await
}
/// RDMA-reads `len` bytes from `token.remote_addr + remote_offset` into the
/// (empty) `chunk`, owning it for the whole DMA like
/// [`Self::write_to_client_owned`]. On success the chunk holds `len` staged
/// bytes.
pub async fn read_from_client_owned(
self: &Arc<Self>,
key: &str,
token: &RdmaToken,
remote_offset: u64,
len: usize,
mut chunk: StagingChunk,
) -> Result<StagingChunk, CuObjectError> {
chunk.clear();
if len == 0 {
return Ok(chunk);
}
if len > chunk.capacity() {
return Err(CuObjectError::Invalid("read exceeds the staging chunk"));
}
let server = Arc::clone(self);
let key = key.to_owned();
let token = token.inner.clone();
let channel_permit = self.channel_permit().await?;
tokio::task::spawn_blocking(move || {
let _channel_permit = channel_permit;
let mut channel = Channel::lease(Arc::clone(&server.server))?;
let moved = channel.put(&key, &token, remote_offset, &server.staging.buffer, chunk.start(), len)?;
check_moved(moved as u64, len as u64)?;
chunk.advance(len)?;
Ok(chunk)
})
.await
.map_err(|error| join_error("read task", error))?
}
async fn channel_permit(&self) -> Result<tokio::sync::OwnedSemaphorePermit, CuObjectError> {
Arc::clone(&self.channels)
.acquire_owned()
.await
.map_err(|_| CuObjectError::Invalid("server closed"))
}
/// RDMA-writes `local` to the client and hands `keep` back once the DMA
/// finished. The transfer runs in a task of its own that owns `local`,
/// `keep` and the channel, so dropping this future never releases memory
/// the NIC may still read.
async fn get_owned<T: Send + 'static>(
self: &Arc<Self>,
key: &str,
token: &RdmaToken,
remote_offset: u64,
local: Local,
keep: T,
) -> Result<(u64, T), CuObjectError> {
let expected = local.len() as u64;
let server = Arc::clone(self);
let key = key.to_owned();
let token = token.inner.clone();
let channel_permit = self.channel_permit().await?;
tokio::spawn(async move {
if server.async_transfers {
match server.get_async(&key, &token, remote_offset, &local).await {
Ok(()) => {
drop(channel_permit);
return Ok((expected, keep));
}
Err(AsyncFailure::Unavailable) => {}
Err(AsyncFailure::Failed(error)) => return Err(error),
Err(AsyncFailure::InFlight(error)) => {
// The NIC may still read this memory: never release it.
std::mem::forget(local);
std::mem::forget(keep);
return Err(error);
}
}
}
tokio::task::spawn_blocking(move || {
let _channel_permit = channel_permit;
let mut channel = Channel::lease(Arc::clone(&server.server))?;
let mut list = None;
let source = server.source(&local, &mut list)?;
let moved = channel.get(&key, &token, remote_offset, source)?;
check_moved(moved as u64, expected)?;
// `keep` (the chunk or the arena owner) is released only here.
Ok((expected, keep))
})
.await
.map_err(|error| join_error("write task", error))?
})
.await
.map_err(|error| join_error("write task", error))?
}
/// Moves `local` with the library's asynchronous mode: the GET is
/// submitted on a channel of its own and the task waits on that channel's
/// completion descriptor instead of holding a blocking thread.
// SAFETY: the allowance covers only this function; its two unsafe calls
// each state the invariant they rely on.
#[allow(unsafe_code)]
async fn get_async(
&self,
key: &str,
token: &cuobject::RdmaToken,
remote_offset: u64,
local: &Local,
) -> Result<(), AsyncFailure> {
let mut channel = Channel::lease(Arc::clone(&self.server))?;
let fd = match channel.completion_fd() {
Ok(fd) => fd,
Err(cuobject::Error::AsyncUnavailable(_)) => return Err(AsyncFailure::Unavailable),
Err(error) => return Err(error.into()),
};
// SAFETY: the library owns the descriptor and keeps it open while the
// server lives; `fd` holds the server, and nothing here closes or
// replaces the descriptor while it is registered.
let completions = unsafe { AsyncFd::register_with_interest(fd, Interest::READABLE) }.map_err(|error| {
AsyncFailure::Failed(CuObjectError::Os {
op: "completion fd",
source: error.into_parts().1,
})
})?;
let mut list = None;
let source = self.source(local, &mut list).map_err(AsyncFailure::Failed)?;
// SAFETY: the memory behind `source` belongs to `local`, owned by the
// calling task together with the transfer's `keep`; staging chunks and
// arena ranges given to a transfer are not borrowed by anyone else.
// This function returns only after the completion carrying the handle
// was drained, except through `InFlight`, where the channel and the
// list are leaked here and the caller leaks `local` and `keep`.
unsafe { channel.get_async(key, token, remote_offset, source, ASYNC_HANDLE) }?;
let mut events = [Completion::default(); 8];
loop {
let mut ready = match completions.readable().await {
Ok(ready) => ready,
Err(source) => {
std::mem::forget(list);
std::mem::forget(channel);
return Err(AsyncFailure::InFlight(CuObjectError::Os {
op: "completion wait",
source,
}));
}
};
loop {
let landed = match channel.process_completions(&mut events) {
Ok(landed) => landed,
Err(error) => {
std::mem::forget(list);
std::mem::forget(channel);
return Err(AsyncFailure::InFlight(error.into()));
}
};
if let Some(done) = events[..landed].iter().find(|event| event.handle() == ASYNC_HANDLE.get()) {
// A completion carries no byte count: success moved the whole range.
return done
.result()
.map_err(|source| AsyncFailure::Failed(CuObjectError::Transfer { verbs_status: 0, source }));
}
if landed < events.len() {
break;
}
}
ready.clear_ready();
}
}
/// The library view of `local`; a scatter-gather list is built into `list`.
fn source<'a: 'l, 'l>(
&'a self,
local: &'a Local,
list: &'l mut Option<SgBuffer<'a, Arc<Server>>>,
) -> Result<Source<'l, Arc<Server>>, CuObjectError> {
Ok(match local {
Local::Staging { offset, len } => Source::Range {
buffer: &self.staging.buffer,
offset: *offset,
len: *len,
},
Local::Arena { arena, offset, len } => Source::Range {
buffer: &arena.buffer,
offset: *offset,
len: *len,
},
Local::ArenaList { arena, entries } => Source::List(list.insert(arena.buffer.sg_buffer(entries)?)),
})
}
}
fn check_moved(moved: u64, expected: u64) -> Result<u64, CuObjectError> {
if moved != expected {
return Err(CuObjectError::ShortTransfer { moved, expected });
}
Ok(moved)
}
fn join_error(op: &'static str, error: tokio::task::JoinError) -> CuObjectError {
CuObjectError::Os {
op,
source: std::io::Error::other(error),
}
}
/// Copies owned bytes into staging; convenience for callers holding `Bytes`.
pub fn fill_chunk(chunk: &mut StagingChunk, data: &Bytes) -> Result<(), CuObjectError> {
chunk.append(data)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn token_parses_leading_fields_and_rejects_garbage() {
let token =
RdmaToken::parse("0000f52eddc00000:00100000:001824d2:0000:002873:1:00000000000000000000ffff0a0d5410").expect("token");
assert_eq!(token.remote_addr, 0x0000_f52e_ddc0_0000);
assert_eq!(token.buffer_len, 0x0010_0000);
assert!(matches!(RdmaToken::parse("nothex:00100000:1:2:3:4:5"), Err(CuObjectError::Token(_))));
assert!(RdmaToken::parse("0000f52eddc00000:00000000:1:2:3:4:5").is_err());
assert!(RdmaToken::parse("0000f52eddc00000:00100000").is_err());
}
}
-3
View File
@@ -39,8 +39,5 @@ serde = { workspace = true, features = ["derive"] }
rmp-serde = { workspace = true }
rustfs-filemeta = { workspace = true }
[dev-dependencies]
serde_json.workspace = true
[lib]
doctest = false
+3 -31
View File
@@ -474,12 +474,6 @@ pub struct BucketTargetUsageInfo {
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct BucketUsageInfo {
pub size: u64,
/// Provenance of this value. Missing and unknown states remain unproven.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub usage_value_state: Option<crate::BucketUsageValueState>,
/// Certification of this exact value, independent of aggregation time.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub usage_certification: Option<crate::BucketUsageCertification>,
/// Bucket identity certified by every set contributing to this snapshot.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub bucket_incarnation: Option<String>,
@@ -586,18 +580,6 @@ pub struct DataUsageInfo {
/// which last-known-good generation contributed to the view.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub usage_snapshot_set_states: Vec<DataUsageSnapshotSetState>,
/// Complete mixed observations for admin display only. Legacy bucket maps
/// and quota consumers continue to use the canonical values above.
#[serde(
default,
skip_serializing_if = "HashMap::is_empty",
deserialize_with = "crate::usage_observation::deserialize_bucket_observations"
)]
pub usage_snapshot_bucket_observations: HashMap<String, crate::DataUsageBucketObservation>,
/// Response-only marker: a projected admin view must never be persisted or
/// admitted as a quota/cache baseline, including after serialization.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub usage_snapshot_admin_projection: bool,
/// Buckets whose dirty-usage generation moved while this complete
/// snapshot was being walked. Their `buckets_usage` values are the walk
/// result, which the cycle could not certify as current; the next cycle
@@ -727,8 +709,7 @@ pub fn observed_data_usage_is_newer(observed: &DataUsageInfo, authoritative: &Da
/// This applies the structural, exact-baseline, and generation checks of
/// [`observed_data_usage_is_newer`] without retaining the baseline's bucket maps.
pub fn observed_data_usage_is_newer_than_identity(observed: &DataUsageInfo, authoritative: DataUsageSnapshotIdentity) -> bool {
!observed.usage_snapshot_admin_projection
&& observed.usage_snapshot_converged == Some(false)
observed.usage_snapshot_converged == Some(false)
&& (observed.is_complete_bucket_usage_snapshot() || observed.is_valid_partial_snapshot())
&& observed.usage_snapshot_authoritative_baseline == Some(authoritative)
&& data_usage_identity_is_newer(observed.snapshot_identity(), authoritative)
@@ -2043,8 +2024,7 @@ impl DataUsageInfo {
/// Whether this snapshot authoritatively covers every reported bucket.
pub fn is_complete_bucket_usage_snapshot(&self) -> bool {
!self.usage_snapshot_admin_projection
&& !self.usage_snapshot_bootstrap_pending
!self.usage_snapshot_bootstrap_pending
&& self.usage_snapshot_complete
&& self.last_update.is_some()
&& u64::try_from(self.buckets_usage.len()).ok() == Some(self.buckets_count)
@@ -2054,8 +2034,7 @@ impl DataUsageInfo {
/// admin display. Partial data is accepted only with unique set states,
/// a plan digest for every state, and at least one usable generation.
pub fn is_valid_partial_snapshot(&self) -> bool {
if self.usage_snapshot_admin_projection
|| self.usage_snapshot_bootstrap_pending
if self.usage_snapshot_bootstrap_pending
|| !self.usage_snapshot_partial
|| self.usage_snapshot_converged != Some(false)
|| self.last_update.is_none()
@@ -2093,11 +2072,9 @@ impl DataUsageInfo {
Ok(name) => name,
Err(_) => return,
};
self.usage_snapshot_bucket_observations.remove(&bucket_name);
// Update bucket statistics
if let Some(bucket_usage) = self.buckets_usage.get_mut(&bucket_name) {
bucket_usage.mark_observed();
bucket_usage.size += meta_object.size as u64;
bucket_usage.objects_count += 1;
bucket_usage.versions_count += 1; // Simplified: assume 1 version per object
@@ -2150,7 +2127,6 @@ impl DataUsageInfo {
Ok(name) => name,
Err(_) => return,
};
self.usage_snapshot_bucket_observations.remove(&bucket_name);
// Calculate accurate statistics from all versions
let mut total_size = 0u64;
@@ -2179,7 +2155,6 @@ impl DataUsageInfo {
// Update bucket statistics
if let Some(bucket_usage) = self.buckets_usage.get_mut(&bucket_name) {
bucket_usage.mark_observed();
bucket_usage.size += total_size;
bucket_usage.objects_count += 1;
bucket_usage.versions_count += versions_count;
@@ -2360,9 +2335,6 @@ impl BucketUsageInfo {
/// Add size summary to this bucket usage
/// Merge another BucketUsageInfo into this one
pub fn merge(&mut self, other: &BucketUsageInfo) {
// Adding contributions produces a new value, not either input's
// whole-bucket certificate. The scanner may certify the final sum.
self.mark_observed();
if self.bucket_incarnation != other.bucket_incarnation {
self.bucket_incarnation = None;
}
-2
View File
@@ -13,7 +13,5 @@
// limitations under the License.
pub mod data_usage;
pub mod usage_observation;
pub use data_usage::*;
pub use usage_observation::*;
-265
View File
@@ -1,265 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
//! Diagnostic provenance and response-only projections of complete bucket observations.
use crate::{BucketUsageInfo, DataUsageInfo, DataUsageSnapshotIdentity};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, time::SystemTime};
pub const DATA_USAGE_BUCKET_OBSERVATION_VERSION: u16 = 1;
/// Provenance of the returned bucket value, independent of quota authority.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum BucketUsageValueState {
Certified,
Carried,
Observed,
#[serde(other)]
Unknown,
}
/// A certification of this exact bucket value, never its publication timestamp.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct BucketUsageCertification {
pub epoch: u64,
pub cycle: u64,
pub certified_at: SystemTime,
}
/// Immutable provenance of one complete traversal contribution.
///
/// The scanner validates its storage-owned sweep identity before constructing
/// this public projection. Equal start/request plans are allowed when a fresh
/// set contributes alongside another set's mixed traversal.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct DataUsageBucketObservationSource {
pub pool_index: u64,
pub set_index: u64,
pub bucket_incarnation: String,
pub scanner_epoch: u64,
pub scanner_cycle: u64,
pub scan_plan_digest: [u8; 32],
pub started_plan: [u8; 32],
pub requested_plan: [u8; 32],
pub completed_at: SystemTime,
}
/// An additive companion; legacy bucket maps never contain this mixed value.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct DataUsageBucketObservation {
pub version: u16,
pub usage: BucketUsageInfo,
/// Exact enclosing candidate identity. Rewrapping preserves source times.
pub snapshot_identity: DataUsageSnapshotIdentity,
/// Oldest contribution time, so a newer set cannot hide an older value.
pub completed_at: SystemTime,
/// Strictly ordered, complete coverage of the enclosing live set inventory.
pub sources: Vec<DataUsageBucketObservationSource>,
}
/// Companion evolution must not make an otherwise usable canonical snapshot
/// unreadable. Unsupported or malformed diagnostic entries never grant proof.
pub(crate) fn deserialize_bucket_observations<'de, D>(
deserializer: D,
) -> Result<HashMap<String, DataUsageBucketObservation>, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(Deserialize)]
#[serde(untagged)]
enum Entry {
Observation(Box<DataUsageBucketObservation>),
Ignored(serde::de::IgnoredAny),
}
Ok(HashMap::<String, Entry>::deserialize(deserializer)?
.into_iter()
.filter_map(|(bucket, entry)| match entry {
Entry::Observation(observation) if observation.version == DATA_USAGE_BUCKET_OBSERVATION_VERSION => {
Some((bucket, *observation))
}
Entry::Observation(_) | Entry::Ignored(_) => None,
})
.collect())
}
impl BucketUsageInfo {
/// Attach a certificate only after the caller proves complete bucket coverage.
pub fn certify(&mut self, certification: BucketUsageCertification) {
self.usage_value_state = Some(BucketUsageValueState::Certified);
self.usage_certification = Some(certification);
}
/// Preserve the certificate when carrying the exact prior bucket value.
pub fn mark_carried(&mut self) {
self.normalize_usage_provenance();
self.usage_value_state = Some(BucketUsageValueState::Carried);
}
/// The value changed without a complete bucket certificate.
pub fn mark_observed(&mut self) {
self.usage_value_state = Some(BucketUsageValueState::Observed);
self.usage_certification = None;
}
/// Future or legacy provenance cannot authorize a retained certificate.
pub fn normalize_usage_provenance(&mut self) {
if !matches!(
self.usage_value_state,
Some(BucketUsageValueState::Certified | BucketUsageValueState::Carried)
) {
self.usage_certification = None;
}
if self.usage_value_state == Some(BucketUsageValueState::Certified) && self.usage_certification.is_none() {
self.usage_value_state = Some(BucketUsageValueState::Unknown);
}
}
}
impl DataUsageBucketObservation {
/// Verify the public provenance against the enclosing candidate and current
/// storage-owned incarnation. This never grants publication or ACK authority.
pub fn matches_snapshot(&self, snapshot: &DataUsageInfo, incarnation: &str) -> bool {
let Some(root_generation) = snapshot.scanner_epoch.zip(snapshot.scanner_cycle) else {
return false;
};
if self.version != DATA_USAGE_BUCKET_OBSERVATION_VERSION
|| snapshot.usage_snapshot_admin_projection
|| self.snapshot_identity != snapshot.snapshot_identity()
|| incarnation.is_empty()
|| self.usage.bucket_incarnation.as_deref() != Some(incarnation)
|| self.sources.is_empty()
|| self.usage.usage_certification.is_some()
|| self.usage.usage_value_state != Some(BucketUsageValueState::Observed)
|| self.sources.iter().map(|source| source.completed_at).min() != Some(self.completed_at)
{
return false;
}
let mut previous = None;
let mut plan = None;
for state in &snapshot.usage_snapshot_set_states {
let key = (state.pool_index, state.set_index);
if previous.is_some_and(|previous| previous >= key)
|| state.scan_plan_digest.is_none()
|| plan.is_some_and(|plan| Some(plan) != state.scan_plan_digest)
{
return false;
}
previous = Some(key);
plan = state.scan_plan_digest;
}
let mut sources = self.sources.iter();
for state in snapshot.usage_snapshot_set_states.iter().filter(|state| !state.tombstone) {
let Some(source) = sources.next() else {
return false;
};
let Some(set_generation) = state.scanner_epoch.zip(state.scanner_cycle) else {
return false;
};
if (source.pool_index, source.set_index) != (state.pool_index, state.set_index)
|| source.bucket_incarnation != incarnation
|| Some(source.scan_plan_digest) != state.scan_plan_digest
|| (source.scanner_epoch, source.scanner_cycle) > set_generation
|| set_generation > root_generation
{
return false;
}
}
sources.next().is_none()
}
}
impl DataUsageInfo {
/// Overlay validated companions on an owned admin response only.
///
/// `incarnations` must come from current storage metadata, not the companion.
/// The projection is marked explicitly so persistence and quota boundaries
/// can reject accidental reuse. Invalid companions leave canonical values
/// unchanged. Counter overflow rejects the whole projection.
pub fn project_bucket_observations_for_admin(&mut self, incarnations: &HashMap<String, String>) -> usize {
if self.usage_snapshot_admin_projection
|| (!self.is_complete_bucket_usage_snapshot() && !self.is_valid_partial_snapshot())
{
return 0;
}
let observations =
self.usage_snapshot_bucket_observations
.iter()
.filter(|(bucket, observation)| {
if self.usage_snapshot_complete
&& (!self.usage_snapshot_pending_buckets.iter().any(|pending| pending == *bucket)
|| u64::try_from(self.usage_snapshot_pending_buckets.len()).ok()
!= Some(self.usage_snapshot_pending_bucket_count))
{
return false;
}
if self
.buckets_usage
.get(*bucket)
.and_then(|usage| usage.usage_certification)
.is_some_and(|certificate| {
observation.sources.iter().all(|source| {
(source.scanner_epoch, source.scanner_cycle) <= (certificate.epoch, certificate.cycle)
})
})
{
return false;
}
incarnations.get(*bucket).is_some_and(|incarnation| {
self.buckets_usage
.get(*bucket)
.and_then(|usage| usage.bucket_incarnation.as_ref())
.is_none_or(|canonical| canonical == incarnation)
&& observation.matches_snapshot(self, incarnation)
})
})
.collect::<HashMap<_, _>>();
if observations.is_empty() {
return 0;
}
let mut values = self
.buckets_usage
.iter()
.filter(|(bucket, _)| !observations.contains_key(bucket))
.map(|(_, usage)| usage)
.chain(observations.values().map(|observation| &observation.usage));
let totals = values.try_fold([0_u64; 4], |total, usage| {
Some([
total[0].checked_add(usage.size)?,
total[1].checked_add(usage.objects_count)?,
total[2].checked_add(usage.versions_count)?,
total[3].checked_add(usage.delete_markers_count)?,
])
});
let Some([size, objects, versions, markers]) = totals else {
return 0;
};
let projected = observations.len();
for (bucket, observation) in observations {
self.buckets_usage.insert(bucket.clone(), observation.usage.clone());
}
self.bucket_sizes = self
.buckets_usage
.iter()
.map(|(bucket, usage)| (bucket.clone(), usage.size))
.collect();
self.buckets_count = u64::try_from(self.buckets_usage.len()).unwrap_or(u64::MAX);
self.objects_total_size = size;
self.objects_total_count = objects;
self.versions_total_count = versions;
self.delete_markers_total_count = markers;
self.replication_info.clear();
self.tier_stats = None;
self.unknown_tier_stats = None;
self.usage_snapshot_complete = false;
self.usage_snapshot_partial = true;
self.usage_snapshot_converged = Some(false);
self.usage_snapshot_observational = true;
self.usage_snapshot_admin_projection = true;
projected
}
}
#[cfg(test)]
mod tests;
@@ -1,323 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
use super::*;
use crate::DataUsageSnapshotSetState;
use std::time::Duration;
const INCARNATION: &str = "11111111-1111-4111-8111-111111111111";
fn time(seconds: u64) -> SystemTime {
SystemTime::UNIX_EPOCH + Duration::from_secs(seconds)
}
fn usage(size: u64) -> BucketUsageInfo {
BucketUsageInfo {
size,
objects_count: size,
versions_count: size,
bucket_incarnation: Some(INCARNATION.to_string()),
..Default::default()
}
}
fn snapshot() -> DataUsageInfo {
let mut main = usage(10);
main.certify(BucketUsageCertification {
epoch: 2,
cycle: 3,
certified_at: time(30),
});
main.mark_carried();
let mut snapshot = DataUsageInfo {
last_update: Some(time(90)),
scanner_epoch: Some(2),
scanner_cycle: Some(9),
buckets_count: 1,
buckets_usage: HashMap::from([("bucket".to_string(), main)]),
bucket_sizes: HashMap::from([("bucket".to_string(), 10)]),
usage_snapshot_complete: true,
usage_snapshot_converged: Some(false),
usage_snapshot_pending_buckets: vec!["bucket".to_string()],
usage_snapshot_pending_bucket_count: 1,
usage_snapshot_set_states: (0..2)
.map(|set_index| DataUsageSnapshotSetState {
pool_index: 0,
set_index,
scanner_epoch: Some(2),
scanner_cycle: Some(9),
scan_plan_digest: Some([1; 32]),
complete: true,
..Default::default()
})
.collect(),
..Default::default()
};
snapshot.calculate_totals();
let mut observed = usage(25);
observed.mark_observed();
let observation = DataUsageBucketObservation {
version: DATA_USAGE_BUCKET_OBSERVATION_VERSION,
usage: observed,
snapshot_identity: snapshot.snapshot_identity(),
completed_at: time(40),
sources: (0..2)
.map(|set_index| DataUsageBucketObservationSource {
pool_index: 0,
set_index,
bucket_incarnation: INCARNATION.to_string(),
scanner_epoch: 2,
scanner_cycle: 4 + set_index,
scan_plan_digest: [1; 32],
started_plan: [2; 32],
requested_plan: [3; 32],
completed_at: time(40 + set_index),
})
.collect(),
};
snapshot
.usage_snapshot_bucket_observations
.insert("bucket".to_string(), observation);
snapshot
}
fn incarnations() -> HashMap<String, String> {
HashMap::from([("bucket".to_string(), INCARNATION.to_string())])
}
#[test]
fn provenance_is_additive_and_unknown_states_do_not_keep_certificates() {
let legacy = usage(10);
let bytes = serde_json::to_vec(&legacy).expect("encode a legacy bucket without provenance");
let text = std::str::from_utf8(&bytes).expect("JSON is UTF-8");
assert!(!text.contains("usage_value_state"));
assert!(!text.contains("usage_certification"));
let decoded: BucketUsageInfo = serde_json::from_slice(&bytes).expect("read legacy bucket");
assert_eq!(decoded.usage_value_state, None);
assert_eq!(decoded.usage_certification, None);
let mut wire = serde_json::to_value(legacy).expect("encode future bucket fixture");
wire["usage_value_state"] = serde_json::json!("future_state");
wire["usage_certification"] =
serde_json::json!({"epoch":2,"cycle":3,"certified_at":{"secs_since_epoch":30,"nanos_since_epoch":0}});
let mut future: BucketUsageInfo = serde_json::from_value(wire).expect("unknown diagnostic enum remains readable");
future.normalize_usage_provenance();
assert_eq!(future.usage_value_state, Some(BucketUsageValueState::Unknown));
assert_eq!(future.usage_certification, None);
}
#[test]
fn carrying_preserves_time_but_adding_a_source_invalidates_the_certificate() {
let mut bucket = snapshot().buckets_usage.remove("bucket").expect("canonical bucket");
bucket.mark_carried();
assert_eq!(bucket.usage_certification.map(|certification| certification.certified_at), Some(time(30)));
bucket.merge(&usage(1));
assert_eq!(bucket.size, 11);
assert_eq!(bucket.usage_value_state, Some(BucketUsageValueState::Observed));
assert_eq!(bucket.usage_certification, None);
}
#[test]
fn direct_object_accumulation_does_not_reuse_the_old_certificate() {
let mut simple = snapshot();
simple.add_object("bucket/object", &rustfs_filemeta::MetaObject::default());
assert_eq!(simple.buckets_usage["bucket"].usage_value_state, Some(BucketUsageValueState::Observed));
assert_eq!(simple.buckets_usage["bucket"].usage_certification, None);
assert!(simple.usage_snapshot_bucket_observations.is_empty());
let mut versioned = snapshot();
versioned.add_object_from_file_meta("bucket/object", &rustfs_filemeta::FileMeta::default());
assert_eq!(versioned.buckets_usage["bucket"].usage_value_state, Some(BucketUsageValueState::Observed));
assert_eq!(versioned.buckets_usage["bucket"].usage_certification, None);
assert!(versioned.usage_snapshot_bucket_observations.is_empty());
}
#[test]
fn future_or_malformed_companions_do_not_break_the_canonical_reader() {
let canonical = snapshot();
for entry in [
serde_json::json!({"version": 2, "future_payload": {"new": true}}),
serde_json::json!({"version": 1, "usage": "broken"}),
] {
let mut wire = serde_json::to_value(&canonical).expect("canonical JSON");
wire["usage_snapshot_bucket_observations"]["bucket"] = entry;
let decoded: DataUsageInfo = serde_json::from_value(wire).expect("diagnostics cannot break canonical data");
assert_eq!(decoded.buckets_usage, canonical.buckets_usage);
assert!(decoded.usage_snapshot_bucket_observations.is_empty());
assert!(decoded.is_complete_bucket_usage_snapshot());
}
}
#[test]
fn complete_companion_projects_only_the_admin_copy_and_keeps_measurement_times() {
let canonical = snapshot();
let canonical_bytes = serde_json::to_vec(&canonical).expect("encode canonical candidate");
let mut response = canonical.clone();
assert_eq!(response.project_bucket_observations_for_admin(&incarnations()), 1);
assert_eq!(response.buckets_usage["bucket"].size, 25);
assert_eq!(response.buckets_usage["bucket"].usage_value_state, Some(BucketUsageValueState::Observed));
assert_eq!(response.buckets_usage["bucket"].usage_certification, None);
assert_eq!(response.objects_total_size, 25);
assert_eq!(response.bucket_sizes["bucket"], 25);
assert_eq!(response.last_update, canonical.last_update);
assert_eq!(response.usage_snapshot_bucket_observations["bucket"].completed_at, time(40));
assert!(response.usage_snapshot_admin_projection);
assert!(response.usage_snapshot_partial);
assert!(response.usage_snapshot_observational);
assert_eq!(response.usage_snapshot_converged, Some(false));
assert!(!response.is_complete_bucket_usage_snapshot());
assert!(
!response.is_valid_partial_snapshot(),
"response-only values cannot be a storage candidate"
);
assert_eq!(serde_json::to_vec(&canonical).expect("reencode original"), canonical_bytes);
assert_eq!(canonical.buckets_usage["bucket"].size, 10);
assert_eq!(
canonical.buckets_usage["bucket"]
.usage_certification
.map(|certificate| certificate.certified_at),
Some(time(30))
);
assert_eq!(response.project_bucket_observations_for_admin(&incarnations()), 0);
}
#[test]
fn invalid_companions_preserve_the_canonical_bucket() {
for invalid in 0..11 {
let mut candidate = snapshot();
let observation = candidate
.usage_snapshot_bucket_observations
.get_mut("bucket")
.expect("companion");
match invalid {
0 => observation.version += 1,
1 => observation.snapshot_identity.scanner_cycle = Some(8),
2 => {
observation.sources.pop();
}
3 => observation.sources[1].set_index = 0,
4 => observation.sources[1].scanner_cycle = 10,
5 => observation.sources[1].scan_plan_digest = [9; 32],
6 => observation.sources[1].bucket_incarnation = "other".to_string(),
7 => observation.completed_at = time(41),
8 => observation.usage.certify(BucketUsageCertification {
epoch: 2,
cycle: 9,
certified_at: time(90),
}),
9 => candidate.usage_snapshot_set_states[1].scanner_cycle = None,
10 => {
candidate
.buckets_usage
.get_mut("bucket")
.expect("canonical")
.bucket_incarnation = Some("recreated".to_string())
}
_ => unreachable!("bounded fixture variants"),
}
let before = candidate.clone();
assert_eq!(
candidate.project_bucket_observations_for_admin(&incarnations()),
0,
"invalid case {invalid}"
);
assert_eq!(candidate, before, "invalid case {invalid} changed canonical data");
}
}
#[test]
fn a_fresh_set_can_contribute_without_refreshing_an_older_mixed_set() {
let mut candidate = snapshot();
let observation = candidate
.usage_snapshot_bucket_observations
.get_mut("bucket")
.expect("companion");
observation.sources[1].started_plan = observation.sources[1].requested_plan;
observation.sources[1].completed_at = time(90);
assert_eq!(candidate.project_bucket_observations_for_admin(&incarnations()), 1);
assert_eq!(candidate.usage_snapshot_bucket_observations["bucket"].completed_at, time(40));
}
#[test]
fn companion_only_partial_keeps_legacy_maps_empty_until_admin_projection() {
let mut candidate = snapshot();
candidate.buckets_usage.clear();
candidate.bucket_sizes.clear();
candidate.buckets_count = 0;
candidate.calculate_totals();
candidate.usage_snapshot_complete = false;
candidate.usage_snapshot_partial = true;
candidate.usage_snapshot_observational = true;
for state in &mut candidate.usage_snapshot_set_states {
state.complete = false;
}
assert!(candidate.is_valid_partial_snapshot());
let wire = serde_json::to_value(&candidate).expect("encode companion-only observation");
assert_eq!(wire["buckets_usage"], serde_json::json!({}));
assert_eq!(wire["bucket_sizes"], serde_json::json!({}));
assert_eq!(wire["objects_total_size"], 0);
assert_eq!(candidate.project_bucket_observations_for_admin(&incarnations()), 1);
assert_eq!(candidate.objects_total_size, 25);
assert!(candidate.usage_snapshot_partial);
assert!(!candidate.usage_snapshot_complete);
}
#[test]
fn projection_rejects_counter_overflow_without_partial_mutation() {
let mut candidate = snapshot();
candidate.buckets_usage.insert("cold".to_string(), usage(u64::MAX));
candidate.buckets_count = 2;
let before = candidate.clone();
assert_eq!(candidate.project_bucket_observations_for_admin(&incarnations()), 0);
assert_eq!(candidate, before);
}
#[test]
fn a_newer_canonical_certificate_and_missing_pending_prevent_old_overlay() {
for newer_certificate in [false, true] {
let mut candidate = snapshot();
if newer_certificate {
candidate
.buckets_usage
.get_mut("bucket")
.expect("canonical")
.certify(BucketUsageCertification {
epoch: 2,
cycle: 9,
certified_at: time(90),
});
} else {
candidate.usage_snapshot_pending_buckets.clear();
candidate.usage_snapshot_pending_bucket_count = 0;
}
assert_eq!(candidate.project_bucket_observations_for_admin(&incarnations()), 0);
assert_eq!(candidate.buckets_usage["bucket"].size, 10);
}
}
#[test]
fn provenance_and_companions_change_candidate_bytes_and_round_trip_as_maps() {
let canonical = snapshot();
let original = serde_json::to_vec(&canonical).expect("encode candidate");
let mut changed = canonical.clone();
changed
.buckets_usage
.get_mut("bucket")
.expect("bucket")
.usage_certification
.as_mut()
.expect("certificate")
.certified_at = time(31);
assert_ne!(serde_json::to_vec(&changed).expect("encode changed certificate"), original);
let mut changed = canonical.clone();
changed
.usage_snapshot_bucket_observations
.get_mut("bucket")
.expect("observation")
.sources[0]
.started_plan = [8; 32];
assert_ne!(serde_json::to_vec(&changed).expect("encode changed source"), original);
let named = rmp_serde::to_vec_named(&canonical).expect("encode named map");
let restored: DataUsageInfo = rmp_serde::from_slice(&named).expect("read named map with additive fields");
assert_eq!(restored, canonical);
}
+8 -8
View File
@@ -99,8 +99,10 @@ rustfs-filemeta.workspace = true
bytes = { workspace = true, features = ["serde"] }
aws-sdk-s3 = { workspace = true, default-features = false, features = ["sigv4a", "default-https-client", "rt-tokio"] }
aws-sdk-sts = { workspace = true, default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-config = { workspace = true }
aws-smithy-http-client = { workspace = true, default-features = false, features = ["rustls-aws-lc"] }
aws-smithy-types.workspace = true
async-compression = { workspace = true, features = ["tokio", "bzip2", "lz4", "xz"] }
async-trait = { workspace = true }
flate2.workspace = true
http.workspace = true
@@ -127,26 +129,24 @@ rand = { workspace = true, features = ["serde"] }
chrono = { workspace = true, features = ["serde"] }
hex-simd = { workspace = true }
md-5 = { workspace = true }
opentelemetry-proto = { workspace = true }
prost.workspace = true
sha2 = { workspace = true }
rustfs-tokio-tar = { workspace = true }
s3s = { workspace = true, features = ["minio"] }
zstd.workspace = true
time = { workspace = true, features = ["parsing", "formatting", "macros", "serde"] }
suppaftp = { workspace = true, features = ["rustls-aws-lc-rs", "tokio-rustls-aws-lc-rs"] }
rcgen.workspace = true
local-ip-address.workspace = true
anyhow.workspace = true
rustls = { workspace = true, default-features = false, features = ["aws-lc-rs", "logging", "tls12", "prefer-post-quantum", "std"] }
russh = { workspace = true, features = ["serde"] }
russh-sftp = { workspace = true }
zip.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
[dev-dependencies]
async-compression = { workspace = true, features = ["tokio", "bzip2", "lz4", "xz"] }
aws-config = { workspace = true }
opentelemetry-proto = { workspace = true }
russh = { workspace = true, features = ["serde"] }
russh-sftp = { workspace = true }
suppaftp = { workspace = true, features = ["rustls-aws-lc-rs", "tokio-rustls-aws-lc-rs"] }
rustfs-tokio-tar = { workspace = true }
zip.workspace = true
same-file.workspace = true
aws-smithy-http-client = { workspace = true, default-features = false, features = ["test-util"] }
rustfs-heal.workspace = true
@@ -14,42 +14,7 @@
//! Differential cases of the `bucket_access` batch (see `super`).
use super::super::{Recorder, none};
use super::super::Recorder;
use aws_sdk_s3::Client;
use aws_sdk_s3::types::{BucketVersioningStatus, VersioningConfiguration};
const BUCKET: &str = "a2-bucket-access";
pub(super) async fn cases(s: &mut Recorder, c: &Client) {
s.step("CreateBucket", "a2-setup", c.create_bucket().bucket(BUCKET).send(), none)
.await;
versioning(s, c).await;
}
async fn versioning(s: &mut Recorder, c: &Client) {
let status = |o: &aws_sdk_s3::operation::get_bucket_versioning::GetBucketVersioningOutput| {
vec![
("status", format!("{:?}", o.status())),
("mfa_delete", format!("{:?}", o.mfa_delete())),
]
};
s.step(
"GetBucketVersioning",
"unconfigured",
c.get_bucket_versioning().bucket(BUCKET).send(),
status,
)
.await;
let suspended = VersioningConfiguration::builder()
.status(BucketVersioningStatus::Suspended)
.build();
let put = c.put_bucket_versioning().bucket(BUCKET).versioning_configuration(suspended);
s.step("PutBucketVersioning", "a2-suspended", put.send(), none).await;
s.step(
"GetBucketVersioning",
"suspended",
c.get_bucket_versioning().bucket(BUCKET).send(),
status,
)
.await;
}
pub(super) async fn cases(_s: &mut Recorder, _c: &Client) {}
@@ -14,59 +14,7 @@
//! Differential cases of the `bucket_core` batch (see `super`).
use super::super::{Recorder, none};
use super::super::Recorder;
use aws_sdk_s3::Client;
use aws_sdk_s3::types::{BucketLocationConstraint, CreateBucketConfiguration};
/// Names RustFS creates although the AWS grammar reserves them, and one it refuses.
const RESERVED_NAMES: [(&str, &str); 5] = [
("reserved-sthree", "sthree-dual-stack"),
("reserved-s3alias", "dual-stack-s3alias"),
("reserved-ol-s3", "dual-stack--ol-s3"),
("reserved-x-s3", "dual-stack--x-s3"),
("reserved-xn", "xn--dual-stack"),
];
pub(super) async fn cases(s: &mut Recorder, c: &Client) {
let located = |bucket: &str, location: &str| {
let configuration = CreateBucketConfiguration::builder()
.location_constraint(BucketLocationConstraint::from(location))
.build();
c.create_bucket().bucket(bucket).create_bucket_configuration(configuration)
};
s.step(
"CreateBucket",
"foreign-location",
located("dual-stack-foreign", "ap-south-1").send(),
none,
)
.await;
s.step("CreateBucket", "eu-alias", located("dual-stack-eu", "EU").send(), none)
.await;
for (case, name) in RESERVED_NAMES {
s.step("CreateBucket", case, c.create_bucket().bucket(name).send(), none)
.await;
}
for (case, bucket, header) in FORCE_DELETES {
// Each case deletes a bucket of its own; the create is setup, not a recorded step.
let _ = c.create_bucket().bucket(bucket).send().await;
let delete = c
.delete_bucket()
.bucket(bucket)
.customize()
.mutate_request(move |request| {
request.headers_mut().insert(header.0, header.1);
})
.send();
s.step("DeleteBucket", case, delete, none).await;
}
}
/// Force-delete headers under both spellings, with values each parser reads differently.
const FORCE_DELETES: [(&str, &str, (&str, &str)); 5] = [
("force-rustfs-true", "dual-stack-force-a", ("x-rustfs-force-delete", "true")),
("force-rustfs-invalid", "dual-stack-force-b", ("x-rustfs-force-delete", "maybe")),
("force-minio-true", "dual-stack-force-c", ("x-minio-force-delete", "true")),
("force-minio-numeric", "dual-stack-force-d", ("x-minio-force-delete", "1")),
("force-minio-invalid", "dual-stack-force-e", ("x-minio-force-delete", "maybe")),
];
pub(super) async fn cases(_s: &mut Recorder, _c: &Client) {}
@@ -13,124 +13,8 @@
// limitations under the License.
//! Differential cases of the `bucket_replication_lifecycle` batch (see `super`).
//!
//! Replication has no case of its own: storing a replication configuration needs a remote target
//! registered through the admin API, which this script does not drive.
use super::super::{Fields, RETAIN_UNTIL_SECS, Recorder, none};
use super::super::Recorder;
use aws_sdk_s3::Client;
use aws_sdk_s3::primitives::DateTime;
use aws_sdk_s3::types::{
AbortIncompleteMultipartUpload, BucketLifecycleConfiguration, DefaultRetention, ExpirationStatus, LifecycleExpiration,
LifecycleRule, LifecycleRuleAndOperator, LifecycleRuleFilter, NoncurrentVersionExpiration, ObjectLockConfiguration,
ObjectLockEnabled, ObjectLockRetentionMode, ObjectLockRule, Tag,
};
/// A name RustFS creates and serves that the AWS bucket grammar reserves.
const RESERVED_BUCKET: &str = "sthree-dual-stack-a3";
const LOCK_BUCKET: &str = "dual-stack-a3-lock";
fn lifecycle_rules(
output: &aws_sdk_s3::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationOutput,
) -> Fields {
vec![("rules", format!("{:?}", output.rules()))]
}
fn object_lock(output: &aws_sdk_s3::operation::get_object_lock_configuration::GetObjectLockConfigurationOutput) -> Fields {
vec![("configuration", format!("{:?}", output.object_lock_configuration()))]
}
pub(super) async fn cases(s: &mut Recorder, c: &Client) {
s.step("CreateBucket", "a3-reserved-name", c.create_bucket().bucket(RESERVED_BUCKET).send(), none)
.await;
let get_lifecycle = || c.get_bucket_lifecycle_configuration().bucket(RESERVED_BUCKET);
s.step("GetBucketLifecycleConfiguration", "a3-reserved-absent", get_lifecycle().send(), none)
.await;
let rule = LifecycleRule::builder()
.id("members")
.status(ExpirationStatus::Enabled)
.filter(
LifecycleRuleFilter::builder()
.and(
LifecycleRuleAndOperator::builder()
.prefix("logs/")
.tags(Tag::builder().key("tier").value("cold").build().expect("tag"))
.object_size_greater_than(1)
.build(),
)
.build(),
)
.expiration(LifecycleExpiration::builder().expired_object_delete_marker(true).build())
.noncurrent_version_expiration(
NoncurrentVersionExpiration::builder()
.noncurrent_days(7)
.newer_noncurrent_versions(2)
.build(),
)
.abort_incomplete_multipart_upload(AbortIncompleteMultipartUpload::builder().days_after_initiation(3).build())
.build()
.expect("lifecycle rule");
// A stored date is answered through a different conversion on each edge of the migration.
let dated = LifecycleRule::builder()
.id("dated")
.status(ExpirationStatus::Disabled)
.filter(LifecycleRuleFilter::builder().prefix("archive/").build())
.expiration(
LifecycleExpiration::builder()
.date(DateTime::from_secs(RETAIN_UNTIL_SECS))
.build(),
)
.build()
.expect("dated lifecycle rule");
let lifecycle = BucketLifecycleConfiguration::builder()
.rules(rule)
.rules(dated)
.build()
.expect("lifecycle configuration");
let put = c
.put_bucket_lifecycle_configuration()
.bucket(RESERVED_BUCKET)
.lifecycle_configuration(lifecycle);
s.step("PutBucketLifecycleConfiguration", "a3-every-member", put.send(), none)
.await;
s.step(
"GetBucketLifecycleConfiguration",
"a3-every-member",
get_lifecycle().send(),
lifecycle_rules,
)
.await;
let get_lock = |bucket: &str| c.get_object_lock_configuration().bucket(bucket);
s.step("GetObjectLockConfiguration", "a3-reserved-absent", get_lock(RESERVED_BUCKET).send(), none)
.await;
let create = c.create_bucket().bucket(LOCK_BUCKET).object_lock_enabled_for_bucket(true);
s.step("CreateBucket", "a3-lock", create.send(), none).await;
s.step(
"GetObjectLockConfiguration",
"a3-enabled-without-rule",
get_lock(LOCK_BUCKET).send(),
object_lock,
)
.await;
let lock = ObjectLockConfiguration::builder()
.object_lock_enabled(ObjectLockEnabled::Enabled)
.rule(
ObjectLockRule::builder()
.default_retention(
DefaultRetention::builder()
.mode(ObjectLockRetentionMode::Compliance)
.years(1)
.build(),
)
.build(),
)
.build();
let put = c
.put_object_lock_configuration()
.bucket(LOCK_BUCKET)
.object_lock_configuration(lock);
s.step("PutObjectLockConfiguration", "a3-years", put.send(), none).await;
s.step("GetObjectLockConfiguration", "a3-years", get_lock(LOCK_BUCKET).send(), object_lock)
.await;
}
pub(super) async fn cases(_s: &mut Recorder, _c: &Client) {}
@@ -12,99 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Differential cases of the `listing_multipart` batch (see `super`): stored keys that need
//! encoding, with and without `encoding-type=url`, ListObjects' marker, ListObjectsV2 pagination,
//! and the listings' parameter refusals.
//! Differential cases of the `listing_multipart` batch (see `super`).
use super::super::{Fields, Recorder, none};
use super::super::Recorder;
use aws_sdk_s3::Client;
use aws_sdk_s3::primitives::ByteStream;
use aws_sdk_s3::types::EncodingType;
const BUCKET: &str = "differential-listing";
const KEYS: [&str; 3] = ["dir a/file+b%.txt", "markup &<>\"'", "~tilde"];
fn v2_fields(o: &aws_sdk_s3::operation::list_objects_v2::ListObjectsV2Output) -> Fields {
let keys: Vec<_> = o.contents().iter().map(|object| object.key()).collect();
vec![
("keys", format!("{keys:?}")),
("encoding_type", format!("{:?}", o.encoding_type())),
("key_count", format!("{:?}", o.key_count())),
("is_truncated", format!("{:?}", o.is_truncated())),
("has_next_token", format!("{}", o.next_continuation_token().is_some())),
]
}
fn v1_fields(o: &aws_sdk_s3::operation::list_objects::ListObjectsOutput) -> Fields {
let keys: Vec<_> = o.contents().iter().map(|object| object.key()).collect();
vec![
("keys", format!("{keys:?}")),
("marker", format!("{:?}", o.marker())),
("next_marker", format!("{:?}", o.next_marker())),
("encoding_type", format!("{:?}", o.encoding_type())),
]
}
pub(super) async fn cases(s: &mut Recorder, c: &Client) {
s.step("ListObjectsV2", "setup-bucket", c.create_bucket().bucket(BUCKET).send(), none)
.await;
for (key, case) in KEYS.into_iter().zip(["setup-object-1", "setup-object-2", "setup-object-3"]) {
let put = c
.put_object()
.bucket(BUCKET)
.key(key)
.body(ByteStream::from_static(b"x"))
.send();
s.step("ListObjectsV2", case, put, none).await;
}
let v2 = || c.list_objects_v2().bucket(BUCKET);
s.step("ListObjectsV2", "raw-keys", v2().send(), v2_fields).await;
s.step("ListObjectsV2", "url-encoded", v2().encoding_type(EncodingType::Url).send(), v2_fields)
.await;
let first = s
.step("ListObjectsV2", "first-page", v2().max_keys(2).send(), v2_fields)
.await;
let token = first.and_then(|page| page.next_continuation_token().map(str::to_owned));
s.step("ListObjectsV2", "next-page", v2().set_continuation_token(token).send(), v2_fields)
.await;
s.step("ListObjectsV2", "negative-max-keys", v2().max_keys(-1).send(), none)
.await;
s.step("ListObjectsV2", "undecodable-token", v2().continuation_token("%%%").send(), none)
.await;
let v1 = || c.list_objects().bucket(BUCKET).max_keys(1);
s.step("ListObjects", "raw-marker", v1().send(), v1_fields).await;
s.step(
"ListObjects",
"url-encoded-marker",
v1().encoding_type(EncodingType::Url).send(),
v1_fields,
)
.await;
s.step("ListObjects", "request-marker", v1().marker(KEYS[0]).send(), v1_fields)
.await;
s.step("ListObjects", "negative-max-keys", v1().max_keys(-1).send(), none)
.await;
let create = c.create_multipart_upload().bucket(BUCKET).key(KEYS[0]).send();
s.step("ListMultipartUploads", "setup-upload", create, none).await;
let uploads = || c.list_multipart_uploads().bucket(BUCKET);
s.step("ListMultipartUploads", "raw-keys", uploads().send(), upload_fields)
.await;
let encoded = uploads().prefix("dir a/").encoding_type(EncodingType::Url).send();
s.step("ListMultipartUploads", "url-encoded", encoded, upload_fields).await;
s.step("ListMultipartUploads", "zero-max-uploads", uploads().max_uploads(0).send(), none)
.await;
let foreign = uploads().prefix("dir").key_marker("other").send();
s.step("ListMultipartUploads", "foreign-key-marker", foreign, none).await;
}
fn upload_fields(o: &aws_sdk_s3::operation::list_multipart_uploads::ListMultipartUploadsOutput) -> Fields {
let keys: Vec<_> = o.uploads().iter().map(|upload| upload.key()).collect();
vec![
("keys", format!("{keys:?}")),
("prefix", format!("{:?}", o.prefix())),
("encoding_type", format!("{:?}", o.encoding_type())),
]
}
pub(super) async fn cases(_s: &mut Recorder, _c: &Client) {}
@@ -14,106 +14,7 @@
//! Differential cases of the `object_meta` batch (see `super`).
use super::super::{Recorder, grants, none, tags};
use super::super::Recorder;
use aws_sdk_s3::Client;
use aws_sdk_s3::primitives::ByteStream;
use aws_sdk_s3::types::{AccessControlPolicy, Grant, Grantee, Owner, Permission, Type};
const BUCKET: &str = "diff-object-meta";
const TAGGED: &str = "tagged";
pub(super) async fn cases(s: &mut Recorder, c: &Client) {
s.step("CreateBucket", "object-meta", c.create_bucket().bucket(BUCKET).send(), none)
.await;
let put = c
.put_object()
.bucket(BUCKET)
.key(TAGGED)
.tagging("k=&odd%20key=v%2Fw")
.body(ByteStream::from_static(b"object meta"));
s.step("PutObject", "object-meta-tagged", put.send(), none).await;
let get_tags = |key: &str, version: Option<&str>| {
c.get_object_tagging()
.bucket(BUCKET)
.key(key)
.set_version_id(version.map(str::to_owned))
};
s.step("GetObjectTagging", "empty-and-encoded-tags", get_tags(TAGGED, None).send(), |o| {
vec![("tags", tags(o.tag_set())), ("version", format!("{:?}", o.version_id()))]
})
.await;
s.step(
"GetObjectTagging",
"malformed-version",
get_tags(TAGGED, Some("not-a-version")).send(),
none,
)
.await;
let absent_version = "00000000-0000-0000-0000-000000000001";
s.step("GetObjectTagging", "absent-version", get_tags(TAGGED, Some(absent_version)).send(), none)
.await;
s.step("GetObjectTagging", "nul-key", get_tags("a\0b", None).send(), none)
.await;
s.step(
"DeleteObjectTagging",
"nul-key",
c.delete_object_tagging().bucket(BUCKET).key("a\0b").send(),
none,
)
.await;
s.step(
"DeleteObjectTagging",
"then-empty",
c.delete_object_tagging().bucket(BUCKET).key(TAGGED).send(),
none,
)
.await;
s.step("GetObjectTagging", "after-delete", get_tags(TAGGED, None).send(), |o| {
vec![("tags", tags(o.tag_set()))]
})
.await;
let grantee = Grantee::builder()
.r#type(Type::CanonicalUser)
.id("owner")
.build()
.expect("grantee");
let policy = AccessControlPolicy::builder()
.owner(Owner::builder().id("owner").build())
.grants(Grant::builder().grantee(grantee).permission(Permission::Read).build())
.build();
let xml_grants = c.put_object_acl().bucket(BUCKET).key(TAGGED).access_control_policy(policy);
s.step("PutObjectAcl", "xml-grants", xml_grants.send(), none).await;
s.step(
"GetObjectAcl",
"after-xml-grants",
c.get_object_acl().bucket(BUCKET).key(TAGGED).send(),
|o| vec![("grants", grants(o.grants()))],
)
.await;
s.step("GetObjectAcl", "nul-key", c.get_object_acl().bucket(BUCKET).key("a\0b").send(), none)
.await;
s.step(
"GetObjectLegalHold",
"no-object-lock",
c.get_object_legal_hold().bucket(BUCKET).key(TAGGED).send(),
none,
)
.await;
s.step(
"GetObjectRetention",
"no-object-lock",
c.get_object_retention().bucket(BUCKET).key(TAGGED).send(),
none,
)
.await;
s.step(
"GetObjectTorrent",
"nul-key",
c.get_object_torrent().bucket(BUCKET).key("a\0b").send(),
none,
)
.await;
}
pub(super) async fn cases(_s: &mut Recorder, _c: &Client) {}
@@ -14,50 +14,7 @@
//! Differential cases of the `object_misc` batch (see `super`).
use super::super::{Recorder, none};
use super::super::Recorder;
use aws_sdk_s3::Client;
use aws_sdk_s3::primitives::ByteStream;
use aws_sdk_s3::types::{BucketVersioningStatus, VersioningConfiguration};
const BUCKET: &str = "dual-stack-object-misc";
const KEY: &str = "doomed.txt";
/// DeleteObject on a versioned bucket: the delete marker and its headers, the delete of that
/// marker by version, and the refusals the delete raises before storage.
pub(super) async fn cases(s: &mut Recorder, c: &Client) {
s.step("CreateBucket", "object-misc-setup", c.create_bucket().bucket(BUCKET).send(), none)
.await;
let enabled = VersioningConfiguration::builder()
.status(BucketVersioningStatus::Enabled)
.build();
let versioning = c.put_bucket_versioning().bucket(BUCKET).versioning_configuration(enabled);
s.step("PutBucketVersioning", "object-misc-setup", versioning.send(), none)
.await;
let put = c.put_object().bucket(BUCKET).key(KEY).body(ByteStream::from_static(b"e2"));
s.step("PutObject", "object-misc-setup", put.send(), none).await;
let marker = s
.step(
"DeleteObject",
"creates-delete-marker",
c.delete_object().bucket(BUCKET).key(KEY).send(),
none,
)
.await
.and_then(|output| output.version_id().map(str::to_owned));
if let Some(marker) = marker {
let delete = c.delete_object().bucket(BUCKET).key(KEY).version_id(marker);
s.step("DeleteObject", "removes-delete-marker", delete.send(), none).await;
}
let delete = c.delete_object().bucket(BUCKET).key(KEY).version_id("not-a-version");
s.step("DeleteObject", "malformed-version", delete.send(), none).await;
let delete = c
.delete_object()
.bucket(BUCKET)
.key(KEY)
.customize()
.mutate_request(|request| {
request.headers_mut().insert("x-rustfs-force-delete", "maybe");
});
s.step("DeleteObject", "invalid-force-delete", delete.send(), none).await;
}
pub(super) async fn cases(_s: &mut Recorder, _c: &Client) {}
@@ -22,11 +22,10 @@ use rustfs_protos::{
models::PingBodyBuilder,
proto_gen::node_service::{
BatchGenerallyLockRequest, BatchGenerallyLockResponse, BatchReadVersionRequest, BatchReadVersionResponse,
GenerallyLockRequest, GenerallyLockResponse, GenerallyLockResult, MrfLifecycleRequest, MrfLifecycleResponse, PingRequest,
PingResponse, ScannerPublicationLeaseReleaseRequest, ScannerPublicationLeaseReleaseResponse,
ScannerPublicationLeaseRequest, ScannerPublicationLeaseResponse, SnapshotLeaseMutationResponse,
SnapshotLeaseReleaseRequest, SnapshotLeaseRenewRequest, SnapshotLeaseRequest, SnapshotLeaseResponse,
node_service_server::NodeService,
GenerallyLockRequest, GenerallyLockResponse, GenerallyLockResult, PingRequest, PingResponse,
ScannerPublicationLeaseReleaseRequest, ScannerPublicationLeaseReleaseResponse, ScannerPublicationLeaseRequest,
ScannerPublicationLeaseResponse, SnapshotLeaseMutationResponse, SnapshotLeaseReleaseRequest, SnapshotLeaseRenewRequest,
SnapshotLeaseRequest, SnapshotLeaseResponse, node_service_server::NodeService,
},
};
use std::pin::Pin;
@@ -439,13 +438,6 @@ impl NodeService for MinimalLockNodeService {
Err(Status::unimplemented("lock-only test server"))
}
async fn write_format_control(
&self,
_request: Request<rustfs_protos::proto_gen::node_service::WriteFormatControlRequest>,
) -> Result<Response<rustfs_protos::proto_gen::node_service::WriteAllResponse>, Status> {
Err(Status::unimplemented("lock-only test server"))
}
async fn compare_and_update_file(
&self,
_request: Request<rustfs_protos::proto_gen::node_service::CompareAndUpdateFileRequest>,
@@ -1003,10 +995,6 @@ impl NodeService for MinimalLockNodeService {
Err(Status::unimplemented("lock-only test server"))
}
async fn mrf_lifecycle(&self, _request: Request<MrfLifecycleRequest>) -> Result<Response<MrfLifecycleResponse>, Status> {
Err(Status::unimplemented("lock-only test server"))
}
async fn background_heal_status(
&self,
_request: Request<rustfs_protos::proto_gen::node_service::BackgroundHealStatusRequest>,
+6 -49
View File
@@ -412,7 +412,6 @@ struct ManualTransitionRunReport {
skipped_delete_marker: u64,
skipped_directory: u64,
skipped_replication: u64,
skipped_already_transitioned: u64,
skipped_already_in_flight: u64,
skipped_queue_full: u64,
skipped_queue_closed: u64,
@@ -1215,16 +1214,9 @@ async fn test_manual_transition_run_black_box_semantics() -> TestResult {
assert!(!due.report.dry_run);
assert!(due.report.lifecycle_config_found);
assert_eq!(due.report.scanned, 1, "due report: {:#?}", due.report);
// PUT can enqueue this object before the manual scan. Account for each
// terminal outcome without depending on how fast the tier worker runs.
assert_eq!(due.report.eligible, 1, "due report: {:#?}", due.report);
assert_eq!(
due.report.eligible + due.report.skipped_already_transitioned,
1,
"due report: {:#?}",
due.report
);
assert_eq!(
due.report.enqueued + due.report.skipped_already_in_flight + due.report.skipped_already_transitioned,
due.report.enqueued + due.report.skipped_already_in_flight,
1,
"due report: {:#?}",
due.report
@@ -1233,34 +1225,12 @@ async fn test_manual_transition_run_black_box_semantics() -> TestResult {
assert_eq!(due.report.skipped_delete_marker, 0);
assert_eq!(due.report.skipped_directory, 0);
assert_eq!(due.report.skipped_replication, 0);
assert_eq!(due.report.skipped_queue_full, 0);
assert_eq!(due.report.skipped_queue_closed, 0);
assert_eq!(due.report.skipped_queue_timeout, 0);
assert_eq!(due.report.tier_failure, 0);
assert!(!due.report.cancelled);
assert!(!due.report.truncated_by_limit);
assert!(!due.report.truncated_by_duration);
wait_for_transition(&hot_client, MANUAL_DUE_BUCKET, MANUAL_DUE_KEY, StdDuration::from_secs(90)).await?;
let remote_count_after_due = cold_tier_object_count(&cold_client).await?;
assert_eq!(remote_count_after_due, 1, "due object must have exactly one remote copy");
// Once HEAD observes the committed transition, a repeated manual scan must
// report the completed object and leave both local reads and the tier intact.
let repeated = manual_transition_run(&hot, MANUAL_DUE_BUCKET, "manual-due/", false).await?;
assert_eq!(repeated.state, "completed", "repeated report: {:#?}", repeated.report);
assert_eq!(repeated.report.scanned, 1, "repeated report: {:#?}", repeated.report);
assert_eq!(repeated.report.eligible, 0, "repeated report: {:#?}", repeated.report);
assert_eq!(repeated.report.enqueued, 0, "repeated report: {:#?}", repeated.report);
assert_eq!(repeated.report.skipped_already_transitioned, 1);
assert_eq!(repeated.report.skipped_already_in_flight, 0);
assert_eq!(cold_tier_object_count(&cold_client).await?, remote_count_after_due);
let due_object = hot_client
.get_object()
.bucket(MANUAL_DUE_BUCKET)
.key(MANUAL_DUE_KEY)
.send()
.await?;
assert_eq!(due_object.body.collect().await?.into_bytes().as_ref(), b"manual due object");
hot_client.create_bucket().bucket(MANUAL_DRY_RUN_BUCKET).send().await?;
enable_bucket_versioning(&hot_client, MANUAL_DRY_RUN_BUCKET).await?;
@@ -2316,14 +2286,6 @@ async fn test_manual_transition_run_continuation_token_resumes_without_raw_marke
)
.await?;
// Configuration updates enqueue existing due objects. Observe their commit
// before paging so eligibility stays stable across the source restart.
for idx in 0..2 {
let key = format!("{MANUAL_CONTINUATION_PREFIX}obj-{idx:02}");
wait_for_transition(&hot_client, MANUAL_CONTINUATION_BUCKET, &key, StdDuration::from_secs(90)).await?;
}
assert_eq!(cold_tier_object_count(&cold_client).await?, 2);
let first = manual_transition_run_with_max(&hot, MANUAL_CONTINUATION_BUCKET, MANUAL_CONTINUATION_PREFIX, true, 1).await?;
assert_eq!(first.state, "partial", "first continuation page: {first:#?}");
assert_eq!(first.mode, "enqueue_only");
@@ -2331,10 +2293,8 @@ async fn test_manual_transition_run_continuation_token_resumes_without_raw_marke
assert_eq!(first.report.prefix, MANUAL_CONTINUATION_PREFIX);
assert!(first.report.dry_run);
assert_eq!(first.report.scanned, 1, "first continuation page: {first:#?}");
assert_eq!(first.report.eligible, 0, "first continuation page: {first:#?}");
assert_eq!(first.report.dry_run_eligible, 0, "first continuation page: {first:#?}");
assert_eq!(first.report.skipped_already_transitioned, 1);
assert_eq!(first.report.enqueued, 0);
assert_eq!(first.report.eligible, 1, "first continuation page: {first:#?}");
assert_eq!(first.report.dry_run_eligible, 1, "first continuation page: {first:#?}");
assert_eq!(first.report.tier_failure, 0);
assert!(!first.report.cancelled);
assert!(first.report.truncated_by_limit);
@@ -2361,15 +2321,12 @@ async fn test_manual_transition_run_continuation_token_resumes_without_raw_marke
.await?;
assert_eq!(second.state, "completed", "second continuation page: {second:#?}");
assert_eq!(second.report.scanned, 1, "second continuation page: {second:#?}");
assert_eq!(second.report.eligible, 0, "second continuation page: {second:#?}");
assert_eq!(second.report.dry_run_eligible, 0, "second continuation page: {second:#?}");
assert_eq!(second.report.skipped_already_transitioned, 1);
assert_eq!(second.report.enqueued, 0);
assert_eq!(second.report.eligible, 1, "second continuation page: {second:#?}");
assert_eq!(second.report.dry_run_eligible, 1, "second continuation page: {second:#?}");
assert_eq!(second.report.tier_failure, 0);
assert!(!second.report.cancelled);
assert!(!second.report.truncated_by_limit);
assert!(second.report.continuation_token.is_none());
assert_eq!(cold_tier_object_count(&cold_client).await?, 2);
Ok(())
}
+9 -46
View File
@@ -208,8 +208,7 @@ pub mod bucket {
pub mod durability {
pub use crate::bucket::durability::{
BUCKET_DURABILITY_MODE_FILE_SYNC, BUCKET_DURABILITY_MODE_NONE, BUCKET_DURABILITY_MODE_RELAXED,
BUCKET_DURABILITY_MODE_STRICT, BucketDurabilityConfig,
BUCKET_DURABILITY_MODE_NONE, BUCKET_DURABILITY_MODE_RELAXED, BUCKET_DURABILITY_MODE_STRICT, BucketDurabilityConfig,
};
}
@@ -503,7 +502,7 @@ pub mod disk {
QUOTA_MUTATION_FENCE_METADATA_SUFFIX, RUSTFS_META_BUCKET, RUSTFS_META_MULTIPART_BUCKET, RUSTFS_META_TMP_BUCKET,
ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameDataResp, STORAGE_FORMAT_FILE, SnapshotLeaseToken,
UpdateMetadataOpts, VolumeInfo, WalkDirOptions, is_quota_mutation_fence_path, new_disk,
validate_batch_read_version_item_count, validate_format_control_path,
validate_batch_read_version_item_count,
};
pub use crate::disk::{
BackgroundMemoryBudget, PhysicalDiskBinding, PhysicalDiskPlan, PhysicalDiskSample, PhysicalDiskSampler,
@@ -566,10 +565,6 @@ pub mod runtime {
global_lock_client, global_lock_clients, global_tier_config_mgr, local_disk_map_read, object_store_handle, region,
rustfs_port, setup_is_dist_erasure, setup_is_erasure, setup_is_erasure_sd, transition_state_handle,
};
pub use crate::runtime::usage_watch::{
SCANNER_USAGE_WATCH_COVERAGE_VERSION, SCANNER_USAGE_WATCH_LEASE_MS, ScannerUsageWatchKnown, ScannerUsageWatchObservation,
ScannerUsageWatchRequest,
};
}
pub mod layout {
@@ -658,25 +653,6 @@ pub mod rio {
}
pub mod rpc {
#[cfg(all(feature = "test-util", feature = "internode-transport"))]
pub mod test_util {
/// Build a remote disk using a controlled transport and no health monitor.
///
/// # Errors
/// Returns the normal remote-disk construction error for the supplied endpoint.
pub async fn remote_disk_with_transport(
endpoint: &crate::layout::endpoint::Endpoint,
transport: std::sync::Arc<dyn super::InternodeDataTransport>,
) -> crate::disk::error::Result<crate::disk::DiskStore> {
let options = crate::disk::DiskOption {
cleanup: false,
health_check: false,
};
let disk = crate::cluster::rpc::remote_disk::RemoteDisk::new(endpoint, &options, transport).await?;
Ok(std::sync::Arc::new(crate::disk::Disk::Remote(Box::new(disk))))
}
}
#[cfg(feature = "internode-transport")]
pub use crate::cluster::rpc::http_auth::ExternalStreamAuth;
pub use crate::cluster::rpc::http_auth::with_rpc_background_request;
@@ -685,15 +661,6 @@ pub mod rpc {
InternodeDataTransport, InternodeDataTransportCapabilities, NsScannerCapabilityRequest, NsScannerStreamRequest,
ReadStreamRequest, TcpHttpInternodeDataTransport, WalkDirStreamRequest, WriteStreamRequest,
};
/// Internode shard reads over NIXL: the receive-pool seam the binary fills
/// and the wire names its serving handler shares with the transport.
pub mod nixl {
pub use crate::cluster::rpc::nixl_internode::{
NIXL_AGENT_QUERY, NIXL_BUFFER_QUERY, NIXL_BUFFERS_QUERY, NIXL_BYTES_HEADER, NIXL_METADATA_HEADER,
NIXL_METADATA_SHA256_QUERY, NIXL_NONCE_QUERY, NixlRecvBuffer, NixlRecvPool, READ_FILE_NIXL_PATH,
WRITE_FILE_NIXL_PATH, install_nixl_recv_pool,
};
}
pub use crate::cluster::rpc::{
AuthenticatedChannel, KMS_SIGNAL_SUBSYSTEM, LocalPeerS3Client, MAX_NETWORK_PROBE_BYTES, MAX_NETWORK_PROBE_DURATION,
NetworkPeerProbeClient, NetworkPeerProbeError, NetworkPeerProbeMeasurement, NetworkPeerTarget, PEER_RESTDRY_RUN,
@@ -705,17 +672,13 @@ pub mod rpc {
gen_tonic_replay_scope_headers, gen_tonic_signature_headers, gen_tonic_signature_interceptor,
node_service_time_out_client, node_service_time_out_client_no_auth, normalize_tonic_rpc_audience,
rpc_auth_is_resource_exhausted, rpc_background_admission, set_tonic_canonical_body_digest, sign_ns_scanner_capability,
sign_ns_scanner_capability_with_checkpoint_coverage, sign_ns_scanner_capability_with_durable_progress,
sign_ns_scanner_capability_with_tier_registry_generation, sign_ns_scanner_capability_with_usage_capabilities,
sign_ns_scanner_usage_watch_capability, sign_put_file_capability, sign_tonic_rpc_response_proof,
tonic_boot_epoch_challenge, tonic_boot_epoch_response_headers, tonic_boot_epoch_response_headers_with_msgpack_capability,
tonic_msgpack_manifest_capability_requested, tonic_rpc_auth_failure_reason, verify_ns_scanner_capability,
verify_ns_scanner_capability_with_checkpoint_coverage, verify_ns_scanner_capability_with_durable_progress,
verify_ns_scanner_capability_with_tier_registry_generation, verify_ns_scanner_capability_with_usage_capabilities,
verify_ns_scanner_usage_watch_capability, verify_put_file_auth_trailer, verify_put_file_capability, verify_rpc_signature,
verify_tonic_boot_epoch_response, verify_tonic_canonical_body_digest, verify_tonic_mutation_body_digest,
verify_tonic_mutation_body_digest_reject_unsigned, verify_tonic_rpc_response_proof, verify_tonic_rpc_signature,
verify_tonic_rpc_signature_with_bootstrap,
sign_ns_scanner_capability_with_checkpoint_coverage, sign_ns_scanner_capability_with_tier_registry_generation,
sign_put_file_capability, sign_tonic_rpc_response_proof, tonic_boot_epoch_challenge, tonic_boot_epoch_response_headers,
tonic_rpc_auth_failure_reason, verify_ns_scanner_capability, verify_ns_scanner_capability_with_checkpoint_coverage,
verify_ns_scanner_capability_with_tier_registry_generation, verify_put_file_auth_trailer, verify_put_file_capability,
verify_rpc_signature, verify_tonic_boot_epoch_response, verify_tonic_canonical_body_digest,
verify_tonic_mutation_body_digest, verify_tonic_mutation_body_digest_reject_unsigned, verify_tonic_rpc_response_proof,
verify_tonic_rpc_signature, verify_tonic_rpc_signature_with_bootstrap,
};
}
+4 -110
View File
@@ -26,8 +26,6 @@ use crate::bucket::target::BucketTargetType;
use crate::bucket::target::{self, BucketTarget, BucketTargets, Credentials};
use crate::bucket::versioning_sys::BucketVersioningSys;
use crate::runtime::sources as runtime_sources;
use aws_sdk_s3::config::interceptors::BeforeDeserializationInterceptorContextRef;
use aws_sdk_s3::config::{ConfigBag, Intercept, RuntimeComponents};
use aws_sdk_s3::error::ProvideErrorMetadata;
use aws_sdk_s3::error::SdkError;
use aws_sdk_s3::operation::complete_multipart_upload::CompleteMultipartUploadOutput;
@@ -55,9 +53,8 @@ use http::{HeaderMap, HeaderName, HeaderValue, StatusCode};
use reqwest::Client as HttpClient;
use rustfs_utils::http::{
AMZ_BUCKET_REPLICATION_STATUS, AMZ_OBJECT_LOCK_BYPASS_GOVERNANCE, AMZ_OBJECT_LOCK_LEGAL_HOLD, AMZ_OBJECT_LOCK_MODE,
AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE, AMZ_OBJECT_TAGGING, AMZ_OBJECT_TAGGING_LOWER, AMZ_STORAGE_CLASS,
AMZ_TAGGING_DIRECTIVE_LOWER, AMZ_WEBSITE_REDIRECT_LOCATION, is_amz_header, is_minio_header, is_rustfs_header,
is_standard_header, is_storageclass_header,
AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE, AMZ_OBJECT_TAGGING_LOWER, AMZ_STORAGE_CLASS, AMZ_WEBSITE_REDIRECT_LOCATION, is_amz_header,
is_minio_header, is_rustfs_header, is_standard_header, is_storageclass_header,
};
use rustfs_utils::http::{
SUFFIX_FORCE_DELETE, SUFFIX_SOURCE_DELETEMARKER, SUFFIX_SOURCE_ETAG, SUFFIX_SOURCE_MTIME, SUFFIX_SOURCE_PROXY_REQUEST,
@@ -135,36 +132,6 @@ impl From<&BucketTarget> for RemoteS3EndpointSpec {
pub type HeadObjectSdkError = Box<SdkError<HeadObjectError>>;
/// Captures the `x-amz-tagging` response header of a replication HEAD, which
/// the SDK drops while deserializing `HeadObjectOutput`.
#[derive(Clone, Debug, Default)]
struct HeadObjectTaggingCapture(Arc<std::sync::Mutex<Option<String>>>);
impl HeadObjectTaggingCapture {
fn take(&self) -> Option<String> {
self.0.lock().unwrap_or_else(std::sync::PoisonError::into_inner).take()
}
}
impl Intercept for HeadObjectTaggingCapture {
fn name(&self) -> &'static str {
"HeadObjectTaggingCapture"
}
fn read_before_deserialization(
&self,
context: &BeforeDeserializationInterceptorContextRef<'_>,
_runtime_components: &RuntimeComponents,
_cfg: &mut ConfigBag,
) -> Result<(), aws_sdk_s3::error::BoxError> {
// Overwrite on every attempt so a retried HEAD reports the tags of the
// response that was actually deserialized.
*self.0.lock().unwrap_or_else(std::sync::PoisonError::into_inner) =
context.response().headers().get(AMZ_OBJECT_TAGGING_LOWER).map(str::to_string);
Ok(())
}
}
/// Whether an edited bucket target still addresses the same remote service
/// (endpoint, bucket, path style, TLS and identity), so a verdict learned
/// about that service stays valid across the edit.
@@ -2133,19 +2100,12 @@ impl TargetClient {
// object with an identical ETag, and the worker concludes the object
// already converged — so it never actually replicates it.
insert_header(&mut headers, SUFFIX_SOURCE_PROXY_REQUEST, "false");
// Ask for the tag set itself (MinIO `x-amz-tagging-directive: ACCESS`):
// a plain HEAD reports only the tag count, which cannot tell the
// replica's tags from the source's.
headers.insert(HeaderName::from_static(AMZ_TAGGING_DIRECTIVE_LOWER), HeaderValue::from_static("ACCESS"));
let target_tagging = HeadObjectTaggingCapture::default();
let mut output = self
.client
self.client
.head_object()
.bucket(bucket)
.key(object)
.set_version_id(resolve_read_api_version_id(version_id))
.customize()
.interceptor(target_tagging.clone())
.map_request(move |mut req| {
for (k, v) in headers.clone().into_iter() {
if let Some(key_str) = k.map(|k| k.as_str().to_string()) {
@@ -2157,17 +2117,7 @@ impl TargetClient {
})
.send()
.await
.map_err(Box::new)?;
// The SDK's typed output has no field for the tag set; carry it where
// the replication comparison reads it. A target that ignores the
// directive leaves the key absent, which compares as "tags unknown".
if let Some(tagging) = target_tagging.take() {
output
.metadata
.get_or_insert_default()
.insert(AMZ_OBJECT_TAGGING.to_string(), tagging);
}
Ok(output)
.map_err(Box::new)
}
/// Candidate replicas by content identity on a target that mints its own
@@ -4606,62 +4556,6 @@ mod tests {
);
}
#[derive(Clone, Debug)]
struct TaggingHeadConnector {
target_tagging: Option<&'static str>,
tagging_directives: Arc<std::sync::Mutex<Vec<Option<String>>>>,
}
impl SmithyHttpConnector for TaggingHeadConnector {
fn call(&self, request: HttpRequest) -> HttpConnectorFuture {
self.tagging_directives
.lock()
.expect("recorded directive lock should not be poisoned")
.push(request.headers().get(AMZ_TAGGING_DIRECTIVE_LOWER).map(str::to_string));
let mut response = HttpResponse::new(
aws_smithy_runtime_api::http::StatusCode::try_from(200_u16).expect("200 should be a valid response status"),
SdkBody::empty(),
);
response.headers_mut().insert("x-amz-meta-owner", "team-a");
if let Some(tagging) = self.target_tagging {
response.headers_mut().insert(AMZ_OBJECT_TAGGING_LOWER, tagging);
}
HttpConnectorFuture::ready(Ok(response))
}
}
#[tokio::test]
async fn head_object_requests_and_reports_the_target_tag_set() {
for target_tagging in [Some("env=prod&team=a"), None] {
let tagging_directives = Arc::new(std::sync::Mutex::new(Vec::new()));
let connector = SharedHttpConnector::new(TaggingHeadConnector {
target_tagging,
tagging_directives: Arc::clone(&tagging_directives),
});
let http_client = http_client_fn(move |_settings, _components| connector.clone());
let (mut client, _) = recording_target_client();
client.client = Arc::new(s3_client_for_test(443, Some(http_client)));
let head = client
.head_object("target-bucket", "object", None)
.await
.expect("canned HEAD should succeed");
assert_eq!(
*tagging_directives
.lock()
.expect("recorded directive lock should not be poisoned"),
vec![Some("ACCESS".to_string())],
"the replication HEAD must ask the target for its tag set"
);
let metadata = head.metadata.expect("user metadata should be parsed");
assert_eq!(metadata.get("owner").map(String::as_str), Some("team-a"));
// Absent means "tags unknown": the comparison then keeps treating a
// tagged replica as different instead of trusting the count alone.
assert_eq!(metadata.get(AMZ_OBJECT_TAGGING).map(String::as_str), target_tagging);
}
}
#[tokio::test]
async fn put_object_sends_source_version_id_query_to_target() {
// MinIO reads the replicated version only from the `versionId` query
+5 -90
View File
@@ -22,13 +22,12 @@
//! `.minio.sys`) can never carry an override; they stay pinned to `strict`.
//! See docs/operations/durability-modes.md for the semantics.
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Serialize};
/// Valid per-bucket durability tier names. `legacy-off` is deliberately not
/// representable per bucket: it exists only for the process-wide legacy
/// switch (`RUSTFS_DRIVE_SYNC_ENABLE=false`).
pub const BUCKET_DURABILITY_MODE_STRICT: &str = "strict";
pub const BUCKET_DURABILITY_MODE_FILE_SYNC: &str = "file-sync";
pub const BUCKET_DURABILITY_MODE_RELAXED: &str = "relaxed";
pub const BUCKET_DURABILITY_MODE_NONE: &str = "none";
@@ -36,69 +35,14 @@ pub const BUCKET_DURABILITY_MODE_NONE: &str = "none";
///
/// An absent entry, an empty payload, or an empty `mode` string all mean
/// "no override": the bucket follows the process-wide durability mode.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct BucketDurabilityConfig {
/// Requested tier: `strict` | `file-sync` | `relaxed` | `none` (case-insensitive,
/// Requested tier: `strict` | `relaxed` | `none` (case-insensitive,
/// whitespace-tolerant). Empty means "inherit the global mode".
#[serde(default)]
pub mode: String,
}
#[derive(Serialize)]
struct BucketDurabilityConfigWireRef<'a> {
mode: &'a str,
#[serde(skip_serializing_if = "is_false")]
file_sync: bool,
}
fn is_false(value: &bool) -> bool {
!*value
}
#[derive(Deserialize)]
struct BucketDurabilityConfigWire {
#[serde(default)]
mode: String,
#[serde(default)]
file_sync: bool,
}
impl Serialize for BucketDurabilityConfig {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let file_sync = self.mode.trim().eq_ignore_ascii_case(BUCKET_DURABILITY_MODE_FILE_SYNC);
BucketDurabilityConfigWireRef {
mode: if file_sync {
BUCKET_DURABILITY_MODE_STRICT
} else {
&self.mode
},
file_sync,
}
.serialize(serializer)
}
}
impl<'de> Deserialize<'de> for BucketDurabilityConfig {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let wire = BucketDurabilityConfigWire::deserialize(deserializer)?;
let mode = if wire.file_sync {
if wire.mode.trim().eq_ignore_ascii_case(BUCKET_DURABILITY_MODE_STRICT) {
BUCKET_DURABILITY_MODE_FILE_SYNC.to_string()
} else {
BUCKET_DURABILITY_MODE_STRICT.to_string()
}
} else {
wire.mode
};
Ok(Self { mode })
}
}
impl BucketDurabilityConfig {
pub fn new(mode: &str) -> Self {
Self { mode: mode.to_string() }
@@ -108,10 +52,7 @@ impl BucketDurabilityConfig {
pub fn is_valid_mode(mode: &str) -> bool {
matches!(
mode.trim().to_ascii_lowercase().as_str(),
BUCKET_DURABILITY_MODE_STRICT
| BUCKET_DURABILITY_MODE_FILE_SYNC
| BUCKET_DURABILITY_MODE_RELAXED
| BUCKET_DURABILITY_MODE_NONE
BUCKET_DURABILITY_MODE_STRICT | BUCKET_DURABILITY_MODE_RELAXED | BUCKET_DURABILITY_MODE_NONE
)
}
@@ -176,7 +117,6 @@ mod tests {
#[test]
fn valid_modes_are_recognized() {
assert!(BucketDurabilityConfig::is_valid_mode("strict"));
assert!(BucketDurabilityConfig::is_valid_mode("file-sync"));
assert!(BucketDurabilityConfig::is_valid_mode("relaxed"));
assert!(BucketDurabilityConfig::is_valid_mode("none"));
assert!(BucketDurabilityConfig::is_valid_mode(" RELAXED "));
@@ -190,7 +130,6 @@ mod tests {
fn normalized_mode_canonicalizes_or_rejects() {
assert_eq!(BucketDurabilityConfig::new(" Relaxed ").normalized_mode().as_deref(), Some("relaxed"));
assert_eq!(BucketDurabilityConfig::new("strict").normalized_mode().as_deref(), Some("strict"));
assert_eq!(BucketDurabilityConfig::new(" FILE-SYNC ").normalized_mode().as_deref(), Some("file-sync"));
assert_eq!(BucketDurabilityConfig::default().normalized_mode(), None);
assert_eq!(BucketDurabilityConfig::new("bogus").normalized_mode(), None);
}
@@ -202,34 +141,11 @@ mod tests {
let back: BucketDurabilityConfig = serde_json::from_slice(&json).expect("deserialize");
assert_eq!(back, cfg);
let file_sync = BucketDurabilityConfig::new("file-sync");
let json = serde_json::to_vec(&file_sync).expect("serialize file-sync");
assert_eq!(json, br#"{"mode":"strict","file_sync":true}"#);
let back: BucketDurabilityConfig = serde_json::from_slice(&json).expect("deserialize file-sync");
assert_eq!(back.normalized_mode().as_deref(), Some("file-sync"));
let malformed = serde_json::from_slice::<BucketDurabilityConfig>(br#"{"mode":"none","file_sync":true}"#)
.expect("deserialize malformed file-sync");
assert_eq!(malformed.normalized_mode().as_deref(), Some("strict"));
// Empty object deserializes to the "inherit" default.
let empty: BucketDurabilityConfig = serde_json::from_slice(b"{}").expect("deserialize empty");
assert_eq!(empty.normalized_mode(), None);
}
#[test]
fn file_sync_encoding_fails_closed_on_legacy_readers() {
#[derive(Deserialize)]
struct LegacyConfig {
#[serde(default)]
mode: String,
}
let json = serde_json::to_vec(&BucketDurabilityConfig::new("file-sync")).expect("serialize file-sync");
let legacy: LegacyConfig = serde_json::from_slice(&json).expect("legacy reader should ignore the marker");
assert_eq!(legacy.mode, "strict", "legacy readers must apply the stronger strict fallback");
}
#[test]
fn new_bucket_default_inherits_when_unset() {
temp_env::with_var_unset(ENV_NEW_BUCKET_DURABILITY_MODE, || {
@@ -241,7 +157,6 @@ mod tests {
fn new_bucket_default_honors_explicit_tiers() {
for mode in [
BUCKET_DURABILITY_MODE_STRICT,
BUCKET_DURABILITY_MODE_FILE_SYNC,
BUCKET_DURABILITY_MODE_RELAXED,
BUCKET_DURABILITY_MODE_NONE,
] {
@@ -4066,11 +4066,6 @@ pub async fn enqueue_transition_immediate(oi: &ObjectInfo, src: LcEventSrc) {
}
pub(crate) async fn enqueue_immediate_expiry(api: Arc<ECStore>, oi: &ObjectInfo, src: LcEventSrc, opts: &ObjectOptions) {
// Without a lifecycle document there is nothing to expire; skip the
// metadata-transaction lock and incarnation read that only validate it.
if !metadata_boundary::cached_metadata_may_have_lifecycle(&api, &oi.bucket).await {
return;
}
let configs = match metadata_boundary::get_expiry_configs_for_options(&api, &oi.bucket, opts).await {
Ok(configs) => configs,
Err(err) => {
@@ -13574,105 +13569,6 @@ mod tests {
);
}
#[tokio::test]
#[serial]
async fn immediate_expiry_without_lifecycle_skips_metadata_transaction() {
let (_paths, ecstore) = setup_test_env().await;
let bucket = format!("lifecycle-absent-expiry-{}", Uuid::new_v4().simple());
create_test_bucket(&ecstore, &bucket).await;
let oi = ecstore
.put_object(
&bucket,
"object",
&mut PutObjReader::from_vec(b"payload".to_vec()),
&ObjectOptions::default(),
)
.await
.expect("create object without lifecycle");
let state = install_unconsumed_runtime_expiry_worker(&ecstore, 4).await;
let transaction = ecstore
.new_ns_lock(
crate::disk::RUSTFS_META_BUCKET,
&metadata_sys::bucket_metadata_transaction_lock_key(&bucket),
)
.await
.expect("metadata transaction namespace");
let opts = ObjectOptions::default();
// A configuration writer outlasts the hook's lock wait; without
// lifecycle there is no incarnation to validate.
let writer = transaction
.get_write_lock(StdDuration::from_secs(5))
.await
.expect("hold metadata transaction");
tokio::time::timeout(
StdDuration::from_secs(1),
super::enqueue_immediate_expiry(Arc::clone(&ecstore), &oi, LcEventSrc::S3PutObject, &opts),
)
.await
.expect("no lifecycle must not wait for the metadata transaction");
assert_eq!(state.read().await.stats.pending_tasks(), 0, "nothing to expire");
drop(writer);
// An unreadable lifecycle document keeps the authoritative path, which
// reports the metadata failure instead of treating it as absent.
let sys = metadata_sys::bucket_metadata_sys_of(&ecstore.ctx).expect("metadata system");
let sys = sys.read().await.clone();
let mut metadata = (*sys.get(&bucket).await.expect("bucket metadata")).clone();
metadata.lifecycle_config_xml = b"<LifecycleConfiguration>".to_vec();
metadata.lifecycle_config = None;
sys.persist_and_set(metadata).await.expect("persist unreadable lifecycle");
let observed = Arc::new(StdMutex::new(Vec::new()));
let observed_events = Arc::clone(&observed);
let _observer = set_lifecycle_observability_observer(move |event, state, reason| {
observed_events
.lock()
.expect("lifecycle observer should not poison")
.push((event, state, reason));
});
super::enqueue_immediate_expiry(Arc::clone(&ecstore), &oi, LcEventSrc::S3PutObject, &opts).await;
assert!(
observed.lock().expect("observed events should not poison").contains(&(
EVENT_LIFECYCLE_EVALUATION_FAILED,
"failed",
Some("metadata_unavailable")
)),
"an unreadable lifecycle document must keep the authoritative path"
);
assert_eq!(state.read().await.stats.pending_tasks(), 0, "nothing enqueued");
}
#[tokio::test]
#[serial]
async fn cached_lifecycle_check_keeps_creation_pending_and_uncached_buckets() {
let (_paths, ecstore) = setup_test_env().await;
let bucket = format!("lifecycle-cached-check-{}", Uuid::new_v4().simple());
create_test_bucket(&ecstore, &bucket).await;
let sys = metadata_sys::bucket_metadata_sys_of(&ecstore.ctx).expect("metadata system");
let sys = sys.read().await.clone();
assert!(
!super::metadata_boundary::cached_metadata_may_have_lifecycle(&ecstore, &bucket).await,
"a cached bucket without lifecycle skips the lookup"
);
let mut pending = (*sys.get(&bucket).await.expect("bucket metadata")).clone();
pending.lock_enabled = true;
pending.bucket_incarnation_sidecar = true;
pending.bucket_creation_committed = false;
assert!(pending.needs_bucket_creation_commit(), "fixture is creation-pending");
sys.set(bucket.clone(), Arc::new(pending)).await;
assert!(
super::metadata_boundary::cached_metadata_may_have_lifecycle(&ecstore, &bucket).await,
"a creation-pending bucket keeps the migration path"
);
assert!(sys.remove(&bucket).await, "cached entry removed");
assert!(
super::metadata_boundary::cached_metadata_may_have_lifecycle(&ecstore, &bucket).await,
"an uncached bucket keeps the authoritative path"
);
}
#[tokio::test]
#[serial]
async fn lifecycle_expiry_fails_closed_on_corrupt_object_lock_metadata() {
@@ -55,25 +55,6 @@ pub(crate) async fn lifecycle_expiry_allowed(
.table_bucket_enabled())
}
/// `get_expiry_configs_for_options` takes the lifecycle rules from this same
/// cached entry and reads the bucket incarnation only to validate it, so a
/// cached entry without any lifecycle document cannot produce an expiry.
/// Uncached, fabricated and creation-pending buckets keep the full path.
pub(crate) async fn cached_metadata_may_have_lifecycle(api: &crate::store::ECStore, bucket: &str) -> bool {
let Ok(sys) = metadata_sys::bucket_metadata_sys_of(&api.ctx) else {
return true;
};
let sys = sys.read().await.clone();
match sys.get(bucket).await {
Ok(metadata) => {
metadata.needs_bucket_creation_commit()
|| metadata.lifecycle_config.is_some()
|| !metadata.lifecycle_config_xml.is_empty()
}
Err(_) => true,
}
}
pub(crate) async fn get_expiry_configs(api: &crate::store::ECStore, bucket: &str) -> Result<LifecycleExpiryConfigs> {
get_expiry_configs_for_options(api, bucket, &crate::object_api::ObjectOptions::default()).await
}
@@ -20,8 +20,6 @@ use crate::test_metrics::CapturingRecorder;
use rustfs_data_usage::{BucketUsageInfo, DataUsageInfo};
use std::time::SystemTime;
mod native_compatibility;
async fn stop_reporting_fixture(store: &crate::store::ECStore) {
if let Some(cancel) = store.ctx.background_cancel_token() {
cancel.cancel();
@@ -92,10 +90,6 @@ async fn install_reporting_snapshot(
#[tokio::test(flavor = "current_thread")]
#[serial]
async fn durable_quota_reporting_retires_degraded_floors_without_changing_ledger_admission() {
assert_durable_quota_reporting_preserves_admission().await;
}
async fn assert_durable_quota_reporting_preserves_admission() {
let recorder = CapturingRecorder::default();
let _recorder = metrics::set_default_local_recorder(&recorder);
for protocol in [1, 2] {
@@ -202,11 +196,6 @@ async fn assert_durable_quota_reporting_preserves_admission() {
.expect("fixture cache cleanup");
crate::data_usage::invalidate_data_usage_snapshot_cache().await;
stop_reporting_fixture(&store).await;
for dir in _dirs {
let path = dir.path().to_path_buf();
dir.close().expect("remove durable quota reporting fixture");
assert!(!path.exists());
}
}
}
}
@@ -214,10 +203,6 @@ async fn assert_durable_quota_reporting_preserves_admission() {
#[tokio::test]
#[serial]
async fn snapshot_quota_admission_retains_degraded_floors_until_migration() {
assert_snapshot_quota_preserves_degraded_floors().await;
}
async fn assert_snapshot_quota_preserves_degraded_floors() {
for source in ["missing", "legacy", "incomplete", "observed"] {
let (_dirs, store, _) = isolated_durable_quota_store().await;
let bucket = format!("quota-compat-{}", Uuid::new_v4().simple());
@@ -248,21 +233,12 @@ async fn assert_snapshot_quota_preserves_degraded_floors() {
.expect("fixture cache cleanup");
crate::data_usage::invalidate_data_usage_snapshot_cache().await;
stop_reporting_fixture(&store).await;
for dir in _dirs {
let path = dir.path().to_path_buf();
dir.close().expect("remove legacy quota reporting fixture");
assert!(!path.exists());
}
}
}
#[tokio::test(flavor = "current_thread")]
#[serial]
async fn quota_without_limit_keeps_the_zero_usage_io_fast_path() {
assert_unlimited_quota_preserves_fast_path().await;
}
async fn assert_unlimited_quota_preserves_fast_path() {
let (_dirs, store, sys) = isolated_durable_quota_store().await;
let bucket = format!("quota-unlimited-{}", Uuid::new_v4().simple());
create_bucket_with_quota_json(
@@ -283,11 +259,6 @@ async fn assert_unlimited_quota_preserves_fast_path() {
assert_eq!(recorder.counter_value(METRIC_QUOTA_USAGE_REPORT_UNAVAILABLE_TOTAL, &[]), 0);
assert_eq!(crate::data_usage::reload_unknown_bucket_usage_calls_for_test(&bucket), 0);
stop_reporting_fixture(&store).await;
for dir in _dirs {
let path = dir.path().to_path_buf();
dir.close().expect("remove unlimited quota reporting fixture");
assert!(!path.exists());
}
}
#[tokio::test]
@@ -1,265 +0,0 @@
// Copyright 2026 RustFS Team
// SPDX-License-Identifier: Apache-2.0
use super::*;
use crate::storage_api_contracts::bucket::{BucketOperations as _, MakeBucketOptions};
use rustfs_data_usage::{
DATA_USAGE_BUCKET_OBSERVATION_VERSION, DataUsageBucketObservation, DataUsageBucketObservationSource,
DataUsageSnapshotSetState,
};
#[tokio::test(flavor = "current_thread")]
#[serial]
async fn usage_quota_modes_preserve_actual_admission_decisions() {
let (dirs, store, sys) = isolated_durable_quota_store().await;
let bucket = format!("usage-no-quota-{}", Uuid::new_v4().simple());
store
.make_bucket(&bucket, &MakeBucketOptions::default())
.await
.expect("unconfigured quota bucket");
let check = QuotaChecker::new(sys)
.check_quota(&bucket, QuotaOperation::PutObject, u64::MAX)
.await
.expect("no quota");
assert!(check.allowed && check.quota_limit.is_none());
store
.put_object(
&bucket,
"allowed",
&mut PutObjReader::from_vec(vec![0x5a; 512]),
&ObjectOptions::default(),
)
.await
.expect("real no-quota write");
stop_reporting_fixture(&store).await;
let paths = dirs.iter().map(|dir| dir.path().to_path_buf()).collect::<Vec<_>>();
drop(store);
drop(dirs);
assert!(paths.iter().all(|path| !path.exists()));
assert_unlimited_quota_preserves_fast_path().await;
assert_snapshot_quota_preserves_degraded_floors().await;
assert_durable_quota_reporting_preserves_admission().await;
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-19", "assertion_id": "USAGE-19-A01", "status": "PASS",
"evidence": {
"quota_modes": ["unconfigured", "unlimited", "legacy-snapshot", "durable-v1", "durable-v2"],
"durable_snapshot_sources": ["missing", "legacy", "incomplete", "observed", "complete"],
"durable_storage_decisions_per_fixture": ["reject-8192", "accept-512", "accept-3584", "reject-1"],
"legacy_missing_baseline_fails_closed": true,
"legacy_grounded_baselines": ["legacy", "incomplete", "observed"]
}
})
);
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-19", "status": "PASS", "fixtures_removed": true})
);
}
async fn persist_companion_fixture(
store: Arc<crate::store::ECStore>,
bucket: &str,
primary: bool,
companion_size: u64,
) -> (String, Vec<u8>) {
let incarnation = store
.bucket_incarnation_id_from_disk(bucket)
.await
.expect("real companion bucket identity");
let completed_at = SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(20);
let mut snapshot = DataUsageInfo {
last_update: Some(completed_at),
scanner_epoch: Some(2),
scanner_cycle: Some(3),
usage_snapshot_complete: primary,
usage_snapshot_partial: !primary,
usage_snapshot_observational: true,
usage_snapshot_converged: Some(false),
usage_snapshot_authoritative_baseline: Some(DataUsageInfo::default().snapshot_identity()),
usage_snapshot_pending_buckets: vec![bucket.to_owned()],
usage_snapshot_pending_bucket_count: 1,
usage_snapshot_set_states: vec![DataUsageSnapshotSetState {
pool_index: 0,
set_index: 0,
scanner_epoch: Some(2),
scanner_cycle: Some(3),
scan_plan_digest: Some([1; 32]),
complete: primary,
..Default::default()
}],
..Default::default()
};
if primary {
snapshot.buckets_count = 1;
snapshot.buckets_usage.insert(
bucket.into(),
BucketUsageInfo {
size: 1000,
objects_count: 1,
versions_count: 1,
bucket_incarnation: Some(incarnation.to_string()),
..Default::default()
},
);
snapshot.bucket_sizes.insert(bucket.into(), 1000);
snapshot.calculate_totals();
}
let mut usage = BucketUsageInfo {
size: companion_size,
objects_count: 1,
versions_count: 1,
bucket_incarnation: Some(incarnation.to_string()),
..Default::default()
};
usage.mark_observed();
snapshot.usage_snapshot_bucket_observations.insert(
bucket.into(),
DataUsageBucketObservation {
version: DATA_USAGE_BUCKET_OBSERVATION_VERSION,
usage,
snapshot_identity: snapshot.snapshot_identity(),
completed_at,
sources: vec![DataUsageBucketObservationSource {
pool_index: 0,
set_index: 0,
bucket_incarnation: incarnation.to_string(),
scanner_epoch: 2,
scanner_cycle: 3,
scan_plan_digest: [1; 32],
started_plan: [2; 32],
requested_plan: [3; 32],
completed_at,
}],
},
);
let mut admin = snapshot.clone();
assert_eq!(
admin.project_bucket_observations_for_admin(&HashMap::from([(bucket.to_owned(), incarnation.to_string())])),
1,
"the companion must be valid, not discarded as malformed"
);
assert_eq!(admin.buckets_usage[bucket].size, companion_size);
let path = format!(
"{}/{}",
crate::disk::BUCKET_META_PREFIX,
rustfs_data_usage::DATA_USAGE_OBSERVED_OBJECT_NAME
);
let bytes = serde_json::to_vec(&snapshot).expect("encode valid companion snapshot");
crate::config::com::save_config(store, &path, bytes.clone())
.await
.expect("persist companion beside canonical fields");
crate::data_usage::invalidate_data_usage_snapshot_cache().await;
(path, bytes)
}
#[tokio::test(flavor = "current_thread")]
#[serial]
async fn usage_companions_do_not_expand_legacy_fallback_or_durable_admission() {
let mut decisions = Vec::new();
for protocol in [0, 1, 2] {
for (primary, companion_size) in [(true, 0), (true, 1_000_000), (false, 1_000_000)] {
let (dirs, store, sys) = isolated_durable_quota_store().await;
let bucket = format!("usage-companion-quota-{}", Uuid::new_v4().simple());
let quota = match protocol {
0 => legacy_quota_json(4096),
1 => serde_json::to_vec(&BucketQuota::new(Some(4096))).unwrap(),
_ => serde_json::to_vec(&BucketQuota::new_sharded(4096)).unwrap(),
};
create_bucket_with_quota_json(&store, &bucket, quota).await;
let (path, bytes) = persist_companion_fixture(store.clone(), &bucket, primary, companion_size).await;
let checker = if protocol == 0 {
QuotaChecker::new(Arc::new(RwLock::new(BucketMetadataSys::new(store.clone()))))
} else {
QuotaChecker::new(sys)
};
if protocol == 0 {
let small = checker.check_quota(&bucket, QuotaOperation::PutObject, 512).await;
if primary {
let small = small.expect("grounded primary fallback");
assert!(small.allowed && !small.uses_durable_reservations);
assert_eq!(small.current_usage, Some(1000));
assert!(
!checker
.check_quota(&bucket, QuotaOperation::PutObject, 4096)
.await
.expect("legacy limit")
.allowed
);
} else {
assert!(
matches!(small, Err(QuotaError::UsageUnavailable { .. })),
"a companion cannot invent a legacy baseline"
);
}
} else {
assert!(
checker
.check_quota(&bucket, QuotaOperation::PutObject, 512)
.await
.expect("durable checker")
.uses_durable_reservations
);
if protocol == 1 {
assert!(matches!(
store
.put_object(
&bucket,
"bootstrap",
&mut PutObjReader::from_vec(vec![0x5a; 512]),
&ObjectOptions::default()
)
.await,
Err(StorageError::SlowDown)
));
crate::bucket::quota::reservation::retry_quota_reconciliation_for_test(store.clone(), &bucket)
.await
.expect("real v1 ledger bootstrap");
}
store
.put_object(&bucket, "fits", &mut PutObjReader::from_vec(vec![0x5a; 4096]), &ObjectOptions::default())
.await
.expect("ledger admits exactly the physical quota regardless of companion");
assert!(
matches!(
store
.put_object(&bucket, "exceeds", &mut PutObjReader::from_vec(vec![0x5a; 1]), &ObjectOptions::default())
.await,
Err(StorageError::QuotaExceeded { .. })
),
"a low companion cannot expand the ledger"
);
}
assert_eq!(
crate::config::com::read_config(store.clone(), &path)
.await
.expect("retained scanner evidence"),
bytes
);
decisions
.push(serde_json::json!({"protocol": protocol, "primary_baseline": primary, "companion_size": companion_size}));
crate::data_usage::prepare_bucket_usage_for_namespace_change(&bucket, None)
.await
.expect("clear fixture caches");
crate::data_usage::invalidate_data_usage_snapshot_cache().await;
stop_reporting_fixture(&store).await;
let paths = dirs.iter().map(|dir| dir.path().to_path_buf()).collect::<Vec<_>>();
drop(store);
drop(dirs);
assert!(paths.iter().all(|path| !path.exists()));
}
}
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-19", "assertion_id": "USAGE-19-A02", "status": "PASS",
"evidence": {"validated_companion_fixtures": decisions, "legacy_primary_bytes": 1000, "durable_limit_bytes": 4096, "companion_only_legacy_admission": "UsageUnavailable"}
})
);
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-19", "status": "PASS", "fixtures_removed": true})
);
}
@@ -52,9 +52,9 @@ use super::replication_resync_boundary::{
#[cfg(test)]
use super::replication_resync_boundary::{RESYNC_META_FORMAT, RESYNC_META_VERSION, WIRE_ZERO_TIME_UNIX};
use super::replication_storage_boundary::{
EcstoreObjectOperations, GetObjectReader, HTTPPreconditions, HTTPRangeSpec, ObjectInfo, ObjectOptions, ObjectToDelete,
ReplicationObjectIO, ReplicationStatusWritebackCondition, ReplicationStatusWritebackMode, ReplicationStorage,
StorageObjectInfoOrErr, WalkOptions,
AdvancedGetOptions, EcstoreObjectOperations, GetObjectReader, HTTPPreconditions, HTTPRangeSpec, ObjectInfo, ObjectOptions,
ObjectToDelete, ReplicationObjectIO, ReplicationStatusWritebackCondition, ReplicationStatusWritebackMode, ReplicationStorage,
StatObjectOptions, StorageObjectInfoOrErr, WalkOptions,
};
#[cfg(test)]
use super::replication_storage_boundary::{NamespaceLockFence, NamespaceLockSignalTestFence, ReplicationDeletedObject};
@@ -89,9 +89,9 @@ use rmp_serde;
use rustfs_gateway_types::persistence::PersistedReplicationConfiguration;
use rustfs_s3_types::EventName;
use rustfs_utils::http::{
AMZ_OBJECT_LOCK_LEGAL_HOLD, AMZ_OBJECT_LOCK_MODE, AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE, SUFFIX_REPLICATION_RESET,
SUFFIX_REPLICATION_RESET_ARN_PREFIX, SUFFIX_REPLICATION_STATUS, SUFFIX_REPLICATION_TARGET_VERSION_ARN_PREFIX,
has_internal_suffix, insert_str, replication_target_versions,
AMZ_OBJECT_LOCK_LEGAL_HOLD, AMZ_OBJECT_LOCK_MODE, AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE, AMZ_TAGGING_DIRECTIVE,
SUFFIX_REPLICATION_RESET, SUFFIX_REPLICATION_STATUS, SUFFIX_REPLICATION_TARGET_VERSION_ARN_PREFIX, has_internal_suffix,
insert_str, replication_target_versions,
};
use rustfs_utils::{DEFAULT_SIP_HASH_KEY, get_env_usize, sip_hash};
use std::collections::{HashMap, HashSet};
@@ -4116,17 +4116,6 @@ fn replication_status_writeback_mode(state_update_needed: bool) -> ReplicationSt
}
}
/// Source-object metadata a replication worker publishes with its terminal
/// status.
#[derive(Clone, Copy, Default)]
struct ReplicationStatusWriteback<'a> {
replication_internal: Option<&'a String>,
/// `(arn, version id the target assigned)` for targets minting their own ids.
target_version_ledger: &'a [(String, String)],
/// `(arn, resync stamp)` for targets this attempt resynced.
resync_stamps: &'a [(String, String)],
}
/// Publish a worker's status with a storage-enforced compare-and-set token.
/// `put_object_metadata` checks the token while it owns the object write lock,
/// avoiding both a read/write race and any need to hold a hot object lock
@@ -4134,16 +4123,12 @@ struct ReplicationStatusWriteback<'a> {
fn replication_status_writeback_options(
roi: &ReplicateObjectInfo,
replication_lock_guard: &rustfs_lock::NamespaceLockGuard,
writeback: ReplicationStatusWriteback<'_>,
new_replication_internal: Option<&String>,
target_version_ledger: &[(String, String)],
mode: ReplicationStatusWritebackMode,
) -> ObjectOptions {
let ReplicationStatusWriteback {
replication_internal,
target_version_ledger,
resync_stamps,
} = writeback;
let mut eval_metadata = HashMap::new();
if let Some(status) = replication_internal {
if let Some(status) = new_replication_internal {
insert_str(&mut eval_metadata, SUFFIX_REPLICATION_STATUS, status.clone());
}
// One durable key per drifting target: the version id it assigned to this
@@ -4156,12 +4141,6 @@ fn replication_status_writeback_options(
assigned_version_id.clone(),
);
}
// The per-target existing-object resync stamp. Without it the object keeps
// answering "not yet resynced" for the target's reset id, and the scanner
// re-queues it on every cycle.
for (arn, stamp) in resync_stamps {
insert_str(&mut eval_metadata, &format!("{SUFFIX_REPLICATION_RESET_ARN_PREFIX}{arn}"), stamp.clone());
}
let mut write_opts = ObjectOptions {
version_id: roi.version_id.map(|version_id| version_id.to_string()),
eval_metadata: Some(eval_metadata),
@@ -4183,11 +4162,13 @@ async fn persist_replication_state_if_current<S: ReplicationStorage>(
roi: &ReplicateObjectInfo,
storage: &Arc<S>,
replication_lock_guard: &rustfs_lock::NamespaceLockGuard,
writeback: ReplicationStatusWriteback<'_>,
new_replication_internal: Option<&String>,
target_version_ledger: &[(String, String)],
mode: ReplicationStatusWritebackMode,
object_info: &mut ObjectInfo,
) -> Result<ReplicationStatePersistOutcome> {
let write_opts = replication_status_writeback_options(roi, replication_lock_guard, writeback, mode);
let write_opts =
replication_status_writeback_options(roi, replication_lock_guard, new_replication_internal, target_version_ledger, mode);
match storage.put_object_metadata(&roi.bucket, &roi.name, &write_opts).await {
Ok(updated) => {
*object_info = updated;
@@ -4353,12 +4334,6 @@ pub(crate) async fn replicate_object_with_outcome<S: ReplicationStorage>(
.filter(|target| !target.is_empty())
.filter_map(|target| Some((target.arn.clone(), target.target_version_id.clone()?)))
.collect();
let resync_stamps: Vec<(String, String)> = rinfos
.targets
.iter()
.filter(|target| !target.is_empty() && !target.resync_timestamp.is_empty())
.map(|target| (target.arn.clone(), target.resync_timestamp.clone()))
.collect();
let state_update_needed = roi.replication_status_internal != new_replication_internal
|| rinfos.replication_resynced()
|| !target_version_ledger.is_empty();
@@ -4368,11 +4343,8 @@ pub(crate) async fn replicate_object_with_outcome<S: ReplicationStorage>(
&roi,
&storage,
&obj_lock_guard,
ReplicationStatusWriteback {
replication_internal: new_replication_internal.as_ref(),
target_version_ledger: &target_version_ledger,
resync_stamps: &resync_stamps,
},
new_replication_internal.as_ref(),
&target_version_ledger,
writeback_mode,
&mut object_info,
)
@@ -5033,6 +5005,8 @@ impl ReplicateObjectInfoExt for ReplicateObjectInfo {
return rinfo;
}
let _sopts = replicate_all_stat_options(&object_info, &bucket, &tgt_client);
let Some((replication_action, object_info)) = resolve_replicate_all_action(
ReplicateAllActionContext {
siblings: &storage,
@@ -5116,13 +5090,6 @@ impl ReplicateObjectInfoExt for ReplicateObjectInfo {
return rinfo;
}
// The transfer is this target's resync of the object. Stamp it like the
// already-converged outcome above, or the next scanner cycle admits the
// object for the same reset id again.
if self.op_type == ReplicationType::ExistingObject && !tgt_client.reset_id.is_empty() {
apply_replication_resync_timestamp(&mut rinfo, &tgt_client.reset_id);
}
rinfo
}
@@ -5271,6 +5238,34 @@ fn note_replicate_all_target_bucket_empty(bucket: &str, tgt_client: &TargetClien
});
}
/// Build the stat options for the target metadata comparison, logging (without
/// failing) when the tagging directive header cannot be set.
fn replicate_all_stat_options(object_info: &ObjectInfo, bucket: &str, tgt_client: &TargetClient) -> StatObjectOptions {
let mut sopts = StatObjectOptions {
version_id: object_info.version_id.map(|v| v.to_string()).unwrap_or_default(),
internal: AdvancedGetOptions {
replication_proxy_request: "false".to_string(),
..Default::default()
},
..Default::default()
};
if let Err(err) = sopts.set(AMZ_TAGGING_DIRECTIVE, "ACCESS") {
debug!(
event = EVENT_RESYNC_RUNTIME_SKIPPED,
component = LOG_COMPONENT_ECSTORE,
subsystem = LOG_SUBSYSTEM_REPLICATION_RESYNC,
bucket = %bucket,
arn = %tgt_client.arn,
error = %err,
reason = "tagging_directive_header_invalid",
"Skipped replication tagging directive header detail"
);
}
sopts
}
/// Record a failed payload transfer: mark the outcome FAILED, log the target
/// operation failure, and take the target offline when the error is a network
/// failure.
@@ -6400,7 +6395,8 @@ mod tests {
let opts = replication_status_writeback_options(
&ReplicateObjectInfo::default(),
&guard,
ReplicationStatusWriteback::default(),
None,
&[],
ReplicationStatusWritebackMode::ValidateOnly,
);
forced_lost.store(true, std::sync::atomic::Ordering::Release);
@@ -6419,76 +6415,6 @@ mod tests {
);
}
#[tokio::test]
async fn terminal_writeback_persists_resync_stamp_that_ends_existing_object_resync() {
let lock = rustfs_lock::NamespaceLock::new(
"replication-status-writeback-resync-stamp".to_string(),
Arc::new(rustfs_lock::LocalClient::new()),
);
let guard = lock
.get_write_lock(
rustfs_lock::ObjectKey::new("bucket", "/[replicate]/object"),
"worker-a",
std::time::Duration::from_secs(2),
)
.await
.expect("replication lock should be acquired");
let arn = "arn:rustfs:replication::target:bucket";
let reset_before = OffsetDateTime::now_utc();
let mut rinfo = ReplicatedTargetInfo {
arn: arn.to_string(),
replication_status: ReplicationStatusType::Completed,
..Default::default()
};
apply_replication_resync_timestamp(&mut rinfo, "reset-1");
let resync_decision = |user_defined: &HashMap<String, String>, reset_id: &str| {
super::super::replication_object_decision_boundary::resync_target_for_object(
&super::super::replication_object_decision_boundary::ReplicationResyncTargetObject {
mod_time: Some(reset_before - time::Duration::hours(1)),
user_defined,
},
arn,
reset_id,
Some(reset_before),
ReplicationStatusType::Completed,
)
.replicate
};
let persisted = |resync_stamps: &[(String, String)]| {
replication_status_writeback_options(
&ReplicateObjectInfo::default(),
&guard,
ReplicationStatusWriteback {
resync_stamps,
..Default::default()
},
ReplicationStatusWritebackMode::Update,
)
.eval_metadata
.expect("writeback always carries evaluated metadata")
};
let unstamped = persisted(&[]);
assert!(
resync_decision(&unstamped, "reset-1"),
"an object older than the reset date stays admitted until it carries the stamp"
);
let stamped = persisted(&[(rinfo.arn.clone(), rinfo.resync_timestamp.clone())]);
let suffix = format!("{SUFFIX_REPLICATION_RESET_ARN_PREFIX}{arn}");
for prefix in [
rustfs_utils::http::RUSTFS_INTERNAL_PREFIX,
rustfs_utils::http::MINIO_INTERNAL_PREFIX,
] {
assert_eq!(stamped.get(&format!("{prefix}{suffix}")), Some(&rinfo.resync_timestamp));
}
assert!(
!resync_decision(&stamped, "reset-1"),
"the persisted stamp must end the resync for the same reset id"
);
assert!(resync_decision(&stamped, "reset-2"), "a new reset id must admit the object again");
}
#[test]
fn unavailable_object_target_is_persisted_as_failed() {
let arn = "arn:object-target";
@@ -33,6 +33,7 @@ pub(crate) use crate::storage_api_contracts::object::{
};
pub(crate) use crate::storage_api_contracts::range::HTTPRangeSpec;
pub(crate) use rustfs_replication::{DeletedObject as ReplicationDeletedObject, ObjectToDelete as ReplicationObjectToDelete};
pub(crate) use rustfs_s3_client::api_get_options::{AdvancedGetOptions, StatObjectOptions};
type ListObjectsV2Info = StorageListObjectsV2Info<ObjectInfo>;
type ListObjectVersionsInfo = StorageListObjectVersionsInfo<ObjectInfo>;
File diff suppressed because it is too large Load Diff
+52 -488
View File
@@ -60,7 +60,7 @@ use time::OffsetDateTime;
use tracing::{error, info, warn};
use uuid::Uuid;
pub(crate) const SIGNATURE_HEADER: &str = "x-rustfs-signature";
const SIGNATURE_HEADER: &str = "x-rustfs-signature";
pub const RPC_BACKGROUND_ADMISSION_HEADER: &str = "x-rustfs-rpc-background-admission";
const RPC_BACKGROUND_ADMISSION_V1: &str = "v1";
const RPC_BACKGROUND_ADMISSION_DOMAIN: &[u8] = b"rustfs-rpc-background-admission-v1\0";
@@ -78,9 +78,6 @@ pub const RPC_BOOT_EPOCH_CHALLENGE_HEADER: &str = "x-rustfs-rpc-boot-epoch-chall
pub const RPC_BOOT_EPOCH_PROOF_HEADER: &str = "x-rustfs-rpc-boot-epoch-proof";
pub(crate) const RPC_REPLAY_CACHE_CAPABILITY_HEADER: &str = "x-rustfs-rpc-replay-cache-capability";
pub(crate) const RPC_REPLAY_CACHE_CAPABILITY_PROOF_HEADER: &str = "x-rustfs-rpc-replay-cache-capability-proof";
pub(crate) const RPC_MSGPACK_MANIFEST_CAPABILITY_REQUEST_HEADER: &str = "x-rustfs-rpc-msgpack-manifest-request";
pub(crate) const RPC_MSGPACK_MANIFEST_CAPABILITY_HEADER: &str = "x-rustfs-rpc-msgpack-manifest-capability";
pub(crate) const RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_HEADER: &str = "x-rustfs-rpc-msgpack-manifest-capability-proof";
const RPC_REPLAY_SCOPE_VERSION_V3: &str = "3";
const RPC_RESPONSE_PROOF_DOMAIN: &[u8] = b"rustfs-rpc-response-proof-v1\0";
@@ -127,8 +124,6 @@ const RPC_REPLAY_SCOPE_DOMAIN: &[u8] = b"rustfs-rpc-replay-scope-v3\0";
const RPC_BOOT_EPOCH_PROOF_DOMAIN: &[u8] = b"rustfs-rpc-boot-epoch-proof-v1\0";
const RPC_REPLAY_CACHE_CAPABILITY_PROOF_DOMAIN: &[u8] = b"rustfs-rpc-replay-cache-capability-proof-v1\0";
const RPC_REPLAY_CACHE_CAPABILITY_V1: &str = "dynamic-replay-cache-v1";
const RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_DOMAIN: &[u8] = b"rustfs-rpc-msgpack-manifest-capability-proof-v1\0";
pub(crate) const RPC_MSGPACK_MANIFEST_CAPABILITY_V1: &str = "msgpack-compat-manifest-v1";
const HTTP_PUT_FILE_AUTH_DOMAIN: &[u8] = b"rustfs-http-put-file-auth-v1\0";
const HTTP_PUT_FILE_CAPABILITY_AUTH_DOMAIN: &[u8] = b"rustfs-http-put-file-capability-v1\0";
const UNSIGNED_PAYLOAD: &str = "UNSIGNED-PAYLOAD";
@@ -144,8 +139,6 @@ const REPLAY_CACHE_AUTO_MEMORY_PERCENT: u64 = 13;
const REPLAY_CACHE_METADATA_BYTES: u64 = 1024 * 1024;
const REPLAY_CACHE_TABLE_OVERHEAD_BYTES: u64 = 512;
const NS_SCANNER_CAPABILITY_AUTH_DOMAIN: &[u8] = b"rustfs-ns-scanner-capability-v3";
const NS_SCANNER_COMPLETE_OBSERVATION_AUTH_DOMAIN: &[u8] = b"rustfs-ns-scanner-complete-observation-v1";
const NS_SCANNER_DURABLE_PROGRESS_AUTH_DOMAIN: &[u8] = b"rustfs-ns-scanner-durable-progress-v1";
const NS_SCANNER_CHECKPOINT_COVERAGE_AUTH_DOMAIN: &[u8] = b"rustfs-ns-scanner-checkpoint-coverage-v1";
const NS_SCANNER_TIER_REGISTRY_GENERATION_AUTH_DOMAIN: &[u8] = b"rustfs-ns-scanner-tier-registry-generation-v1";
pub const TONIC_RPC_PREFIX: &str = "/node_service.NodeService";
@@ -802,8 +795,6 @@ fn update_ns_scanner_capability_mac(
server_epoch: Uuid,
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
supports_durable_progress: bool,
supports_complete_observation: bool,
) {
mac.update(NS_SCANNER_CAPABILITY_AUTH_DOMAIN);
mac.update(&NS_SCANNER_PROTOCOL_VERSION.to_be_bytes());
@@ -818,89 +809,52 @@ fn update_ns_scanner_capability_mac(
if supports_checkpoint_coverage {
mac.update(NS_SCANNER_CHECKPOINT_COVERAGE_AUTH_DOMAIN);
}
if supports_durable_progress {
mac.update(NS_SCANNER_DURABLE_PROGRESS_AUTH_DOMAIN);
}
if supports_complete_observation {
mac.update(NS_SCANNER_COMPLETE_OBSERVATION_AUTH_DOMAIN);
}
}
fn generate_ns_scanner_capability_proof_with_observation(
secret: &str,
challenge: Uuid,
server_epoch: Uuid,
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
supports_durable_progress: bool,
supports_complete_observation: bool,
) -> std::io::Result<Vec<u8>> {
if challenge.is_nil() || server_epoch.is_nil() {
return Err(std::io::Error::other("Invalid namespace scanner capability scope"));
}
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
update_ns_scanner_capability_mac(
&mut mac,
challenge,
server_epoch,
supports_tier_registry_generation,
supports_checkpoint_coverage,
supports_durable_progress,
supports_complete_observation,
);
Ok(mac.finalize().into_bytes().to_vec())
}
#[allow(clippy::too_many_arguments)]
fn verify_ns_scanner_capability_proof_with_observation(
secret: &str,
challenge: Uuid,
server_epoch: Uuid,
proof: &[u8],
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
supports_durable_progress: bool,
supports_complete_observation: bool,
) -> std::io::Result<()> {
if challenge.is_nil() || server_epoch.is_nil() {
return Err(std::io::Error::other("Invalid namespace scanner capability scope"));
}
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
update_ns_scanner_capability_mac(
&mut mac,
challenge,
server_epoch,
supports_tier_registry_generation,
supports_checkpoint_coverage,
supports_durable_progress,
supports_complete_observation,
);
mac.verify_slice(proof)
.map_err(|_| std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Invalid namespace scanner capability proof"))
}
fn generate_ns_scanner_capability_proof(
secret: &str,
challenge: Uuid,
server_epoch: Uuid,
tier: bool,
checkpoint: bool,
progress: bool,
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
) -> std::io::Result<Vec<u8>> {
generate_ns_scanner_capability_proof_with_observation(secret, challenge, server_epoch, tier, checkpoint, progress, false)
if challenge.is_nil() || server_epoch.is_nil() {
return Err(std::io::Error::other("Invalid namespace scanner capability scope"));
}
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
update_ns_scanner_capability_mac(
&mut mac,
challenge,
server_epoch,
supports_tier_registry_generation,
supports_checkpoint_coverage,
);
Ok(mac.finalize().into_bytes().to_vec())
}
fn verify_ns_scanner_capability_proof(
secret: &str,
challenge: Uuid,
server_epoch: Uuid,
proof: &[u8],
tier: bool,
checkpoint: bool,
progress: bool,
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
) -> std::io::Result<()> {
verify_ns_scanner_capability_proof_with_observation(secret, challenge, server_epoch, proof, tier, checkpoint, progress, false)
if challenge.is_nil() || server_epoch.is_nil() {
return Err(std::io::Error::other("Invalid namespace scanner capability scope"));
}
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
update_ns_scanner_capability_mac(
&mut mac,
challenge,
server_epoch,
supports_tier_registry_generation,
supports_checkpoint_coverage,
);
mac.verify_slice(proof)
.map_err(|_| std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Invalid namespace scanner capability proof"))
}
pub fn sign_ns_scanner_capability(challenge: Uuid, server_epoch: Uuid) -> std::io::Result<Vec<u8>> {
@@ -924,22 +878,6 @@ pub fn sign_ns_scanner_capability_with_checkpoint_coverage(
server_epoch: Uuid,
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
) -> std::io::Result<Vec<u8>> {
sign_ns_scanner_capability_with_durable_progress(
challenge,
server_epoch,
supports_tier_registry_generation,
supports_checkpoint_coverage,
false,
)
}
pub fn sign_ns_scanner_capability_with_durable_progress(
challenge: Uuid,
server_epoch: Uuid,
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
supports_durable_progress: bool,
) -> std::io::Result<Vec<u8>> {
generate_ns_scanner_capability_proof(
&get_shared_secret()?,
@@ -947,7 +885,6 @@ pub fn sign_ns_scanner_capability_with_durable_progress(
server_epoch,
supports_tier_registry_generation,
supports_checkpoint_coverage,
supports_durable_progress,
)
}
@@ -972,24 +909,6 @@ pub fn verify_ns_scanner_capability_with_checkpoint_coverage(
proof: &[u8],
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
) -> std::io::Result<()> {
verify_ns_scanner_capability_with_durable_progress(
challenge,
server_epoch,
proof,
supports_tier_registry_generation,
supports_checkpoint_coverage,
false,
)
}
pub fn verify_ns_scanner_capability_with_durable_progress(
challenge: Uuid,
server_epoch: Uuid,
proof: &[u8],
supports_tier_registry_generation: bool,
supports_checkpoint_coverage: bool,
supports_durable_progress: bool,
) -> std::io::Result<()> {
verify_ns_scanner_capability_proof(
&get_shared_secret()?,
@@ -998,74 +917,6 @@ pub fn verify_ns_scanner_capability_with_durable_progress(
proof,
supports_tier_registry_generation,
supports_checkpoint_coverage,
supports_durable_progress,
)
}
pub fn sign_ns_scanner_capability_with_usage_capabilities(
challenge: Uuid,
server_epoch: Uuid,
tier: bool,
checkpoint: bool,
progress: bool,
observation: bool,
) -> std::io::Result<Vec<u8>> {
generate_ns_scanner_capability_proof_with_observation(
&get_shared_secret()?,
challenge,
server_epoch,
tier,
checkpoint,
progress,
observation,
)
}
fn ns_scanner_usage_watch_capability_mac(secret: &str, challenge: Uuid, server_epoch: Uuid) -> std::io::Result<HmacSha256> {
if challenge.is_nil() || server_epoch.is_nil() {
return Err(std::io::Error::other("Invalid namespace scanner usage watch capability scope"));
}
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
mac.update(b"rustfs-ns-scanner-usage-watch-capability-v1\0");
mac.update(&NS_SCANNER_PROTOCOL_VERSION.to_be_bytes());
mac.update(challenge.as_bytes());
mac.update(server_epoch.as_bytes());
Ok(mac)
}
/// Sign the independent worker capability to validate bucket watches before
/// reusing or durably publishing a complete scanner cache.
pub fn sign_ns_scanner_usage_watch_capability(challenge: Uuid, server_epoch: Uuid) -> std::io::Result<Vec<u8>> {
Ok(ns_scanner_usage_watch_capability_mac(&get_shared_secret()?, challenge, server_epoch)?
.finalize()
.into_bytes()
.to_vec())
}
pub fn verify_ns_scanner_usage_watch_capability(challenge: Uuid, server_epoch: Uuid, proof: &[u8]) -> std::io::Result<()> {
ns_scanner_usage_watch_capability_mac(&get_shared_secret()?, challenge, server_epoch)?
.verify_slice(proof)
.map_err(|_| std::io::Error::other("Invalid namespace scanner usage watch capability proof"))
}
pub fn verify_ns_scanner_capability_with_usage_capabilities(
challenge: Uuid,
server_epoch: Uuid,
proof: &[u8],
tier: bool,
checkpoint: bool,
progress: bool,
observation: bool,
) -> std::io::Result<()> {
verify_ns_scanner_capability_proof_with_observation(
&get_shared_secret()?,
challenge,
server_epoch,
proof,
tier,
checkpoint,
progress,
observation,
)
}
@@ -1243,50 +1094,6 @@ fn verify_replay_cache_capability_proof(
.map_err(|_| std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Invalid RPC replay cache capability proof"))
}
fn update_msgpack_manifest_capability_proof(mac: &mut HmacSha256, audience: &str, challenge: Uuid, boot_epoch: Uuid) {
mac.update(RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_DOMAIN);
for part in [
audience.as_bytes(),
b"|",
challenge.as_bytes(),
b"|",
boot_epoch.as_bytes(),
b"|",
RPC_MSGPACK_MANIFEST_CAPABILITY_V1.as_bytes(),
] {
mac.update(part);
}
}
fn generate_msgpack_manifest_capability_proof(
secret: &str,
audience: &str,
challenge: Uuid,
boot_epoch: Uuid,
) -> std::io::Result<String> {
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
update_msgpack_manifest_capability_proof(&mut mac, audience, challenge, boot_epoch);
Ok(base64_simd::STANDARD.encode_to_string(mac.finalize().into_bytes()))
}
fn verify_msgpack_manifest_capability_proof(
secret: &str,
audience: &str,
challenge: Uuid,
boot_epoch: Uuid,
proof: &str,
) -> std::io::Result<()> {
let proof = base64_simd::STANDARD
.decode_to_vec(proof)
.map_err(|_| std::io::Error::other("Invalid RPC msgpack manifest capability proof"))?;
let mut mac =
<HmacSha256 as KeyInit>::new_from_slice(secret.as_bytes()).map_err(|_| std::io::Error::other("Invalid RPC HMAC key"))?;
update_msgpack_manifest_capability_proof(&mut mac, audience, challenge, boot_epoch);
mac.verify_slice(&proof)
.map_err(|_| std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Invalid RPC msgpack manifest capability proof"))
}
fn non_nil_uuid(value: &str, name: &str) -> std::io::Result<Uuid> {
let value = Uuid::parse_str(value).map_err(|_| std::io::Error::other(format!("Invalid {name}")))?;
(!value.is_nil())
@@ -1386,24 +1193,8 @@ pub fn tonic_boot_epoch_challenge(headers: &HeaderMap) -> std::io::Result<Option
.transpose()
}
/// Whether the request opts into the optional msgpack manifest capability proof.
pub fn tonic_msgpack_manifest_capability_requested(headers: &HeaderMap) -> bool {
headers
.get(RPC_MSGPACK_MANIFEST_CAPABILITY_REQUEST_HEADER)
.is_some_and(|value| value == RPC_MSGPACK_MANIFEST_CAPABILITY_V1)
}
/// Build the authenticated response headers for a client boot-epoch challenge.
pub fn tonic_boot_epoch_response_headers(audience: &str, challenge: Uuid) -> std::io::Result<HeaderMap> {
tonic_boot_epoch_response_headers_with_msgpack_capability(audience, challenge, false)
}
/// Build authenticated boot-epoch headers and, when requested, the msgpack manifest capability.
pub fn tonic_boot_epoch_response_headers_with_msgpack_capability(
audience: &str,
challenge: Uuid,
include_msgpack_manifest: bool,
) -> std::io::Result<HeaderMap> {
let boot_epoch = tonic_rpc_boot_epoch();
let secret = get_shared_secret()?;
let proof = generate_boot_epoch_proof(&secret, audience, challenge, boot_epoch)?;
@@ -1419,17 +1210,6 @@ pub fn tonic_boot_epoch_response_headers_with_msgpack_capability(
RPC_REPLAY_CACHE_CAPABILITY_PROOF_HEADER,
header_value(&capability_proof, RPC_REPLAY_CACHE_CAPABILITY_PROOF_HEADER)?,
);
if include_msgpack_manifest {
let msgpack_capability_proof = generate_msgpack_manifest_capability_proof(&secret, audience, challenge, boot_epoch)?;
headers.insert(
RPC_MSGPACK_MANIFEST_CAPABILITY_HEADER,
HeaderValue::from_static(RPC_MSGPACK_MANIFEST_CAPABILITY_V1),
);
headers.insert(
RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_HEADER,
header_value(&msgpack_capability_proof, RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_HEADER)?,
);
}
Ok(headers)
}
@@ -1463,12 +1243,6 @@ pub(crate) struct AuthenticatedPeerReplayCapabilities {
pub(crate) dynamic_replay_cache: bool,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct AuthenticatedPeerMsgpackCapabilities {
pub(crate) boot_epoch: Uuid,
pub(crate) msgpack_compat_manifest: bool,
}
pub(crate) fn verify_tonic_peer_replay_capabilities_response(
audience: &str,
challenge: Uuid,
@@ -1500,57 +1274,6 @@ pub(crate) fn verify_tonic_peer_replay_capabilities_response(
})
}
#[cfg(test)]
pub(crate) fn verify_tonic_peer_msgpack_capabilities_response(
audience: &str,
challenge: Uuid,
headers: &HeaderMap,
) -> std::io::Result<AuthenticatedPeerMsgpackCapabilities> {
let secret = get_shared_secret()?;
let boot_epoch = verify_tonic_boot_epoch_response_with_secret(&secret, audience, challenge, headers)?;
verify_tonic_peer_msgpack_capability_for_epoch_with_secret(&secret, audience, challenge, boot_epoch, headers)
}
pub(crate) fn verify_tonic_peer_msgpack_capability_for_authenticated_epoch(
audience: &str,
challenge: Uuid,
boot_epoch: Uuid,
headers: &HeaderMap,
) -> std::io::Result<AuthenticatedPeerMsgpackCapabilities> {
verify_tonic_peer_msgpack_capability_for_epoch_with_secret(&get_shared_secret()?, audience, challenge, boot_epoch, headers)
}
fn verify_tonic_peer_msgpack_capability_for_epoch_with_secret(
secret: &str,
audience: &str,
challenge: Uuid,
boot_epoch: Uuid,
headers: &HeaderMap,
) -> std::io::Result<AuthenticatedPeerMsgpackCapabilities> {
let capability = headers.get(RPC_MSGPACK_MANIFEST_CAPABILITY_HEADER);
let proof = headers.get(RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_HEADER);
if capability.is_none() && proof.is_none() {
return Ok(AuthenticatedPeerMsgpackCapabilities {
boot_epoch,
msgpack_compat_manifest: false,
});
}
let capability = capability
.and_then(|value| value.to_str().ok())
.ok_or_else(|| std::io::Error::other("Missing RPC msgpack manifest capability"))?;
if capability != RPC_MSGPACK_MANIFEST_CAPABILITY_V1 {
return Err(std::io::Error::other("Unsupported RPC msgpack manifest capability"));
}
let proof = proof
.and_then(|value| value.to_str().ok())
.ok_or_else(|| std::io::Error::other("Missing RPC msgpack manifest capability proof"))?;
verify_msgpack_manifest_capability_proof(secret, audience, challenge, boot_epoch, proof)?;
Ok(AuthenticatedPeerMsgpackCapabilities {
boot_epoch,
msgpack_compat_manifest: true,
})
}
fn valid_content_sha256(value: &str) -> bool {
value == UNSIGNED_PAYLOAD
|| (value.len() == 64
@@ -1586,7 +1309,7 @@ fn tonic_rpc_metric_operation(path: &str) -> &'static str {
Some("ReadMultiple") => INTERNODE_OPERATION_GRPC_READ_MULTIPLE,
Some("ReadVersion") => INTERNODE_OPERATION_GRPC_READ_VERSION,
Some("BatchReadVersion") => INTERNODE_OPERATION_GRPC_BATCH_READ_VERSION,
Some("WriteAll" | "WriteFormatControl") => INTERNODE_OPERATION_GRPC_WRITE_ALL,
Some("WriteAll") => INTERNODE_OPERATION_GRPC_WRITE_ALL,
Some("CompareAndUpdateFile") => INTERNODE_OPERATION_GRPC_COMPARE_AND_UPDATE_FILE,
Some("Lock") => INTERNODE_OPERATION_GRPC_LOCK,
Some("UnLock") => INTERNODE_OPERATION_GRPC_UNLOCK,
@@ -2479,119 +2202,13 @@ mod tests {
let secret = "test-scanner-capability-secret";
let challenge = Uuid::new_v4();
let server_epoch = Uuid::new_v4();
let proof = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, false, false, false)
let proof = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, false, false)
.expect("capability proof should be generated");
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, false, false, false).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, Uuid::new_v4(), server_epoch, &proof, false, false, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, Uuid::new_v4(), &proof, false, false, false).is_err());
assert!(
verify_ns_scanner_capability_proof("different-secret", challenge, server_epoch, &proof, false, false, false).is_err()
);
}
#[test]
fn namespace_scanner_watch_capability_is_independent_and_rejects_replay() {
let _ = rustfs_credentials::set_global_rpc_secret("usage-watch-capability-test-secret".into());
let challenge = Uuid::new_v4();
let epoch = Uuid::new_v4();
let proof = sign_ns_scanner_usage_watch_capability(challenge, epoch).expect("watch capability");
verify_ns_scanner_usage_watch_capability(challenge, epoch, &proof).expect("exact watch capability scope");
assert!(verify_ns_scanner_usage_watch_capability(Uuid::new_v4(), epoch, &proof).is_err());
assert!(verify_ns_scanner_usage_watch_capability(challenge, Uuid::new_v4(), &proof).is_err());
for progress in [false, true] {
for observation in [false, true] {
let other =
sign_ns_scanner_capability_with_usage_capabilities(challenge, epoch, true, true, progress, observation)
.expect("independent older capabilities");
assert!(verify_ns_scanner_usage_watch_capability(challenge, epoch, &other).is_err());
assert!(
verify_ns_scanner_capability_with_usage_capabilities(
challenge,
epoch,
&proof,
true,
true,
progress,
observation
)
.is_err()
);
}
}
}
#[test]
fn namespace_scanner_observation_and_progress_scopes_are_independent() {
let challenge = Uuid::new_v4();
let epoch = Uuid::new_v4();
let secret = "independent-usage-capabilities";
for progress in [false, true] {
for observation in [false, true] {
let proof = generate_ns_scanner_capability_proof_with_observation(
secret,
challenge,
epoch,
true,
true,
progress,
observation,
)
.expect("proof");
assert!(
verify_ns_scanner_capability_proof_with_observation(
secret,
challenge,
epoch,
&proof,
true,
true,
progress,
observation
)
.is_ok()
);
assert!(
verify_ns_scanner_capability_proof_with_observation(
secret,
challenge,
epoch,
&proof,
true,
true,
!progress,
observation
)
.is_err()
);
assert!(
verify_ns_scanner_capability_proof_with_observation(
secret,
challenge,
epoch,
&proof,
true,
true,
progress,
!observation
)
.is_err()
);
}
}
}
#[test]
fn namespace_scanner_capability_proof_binds_durable_progress_independently() {
let challenge = Uuid::new_v4();
let epoch = Uuid::new_v4();
let secret = "durable-progress-test";
for supported in [false, true] {
let proof = generate_ns_scanner_capability_proof(secret, challenge, epoch, true, true, supported).expect("proof");
assert!(verify_ns_scanner_capability_proof(secret, challenge, epoch, &proof, true, true, supported).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, challenge, epoch, &proof, true, true, !supported).is_err());
assert!(verify_ns_scanner_capability_proof(secret, Uuid::new_v4(), epoch, &proof, true, true, supported).is_err());
}
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, false, false).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, Uuid::new_v4(), server_epoch, &proof, false, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, Uuid::new_v4(), &proof, false, false).is_err());
assert!(verify_ns_scanner_capability_proof("different-secret", challenge, server_epoch, &proof, false, false).is_err());
}
#[test]
@@ -2599,16 +2216,16 @@ mod tests {
let secret = "checkpoint-capability-test-secret";
let challenge = Uuid::new_v4();
let server_epoch = Uuid::new_v4();
let proof = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, true, true, false)
let proof = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, true, true)
.expect("checkpoint capability proof");
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, true, true, false).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, true, false, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, false, true, false).is_err());
let legacy = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, true, false, false)
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, true, true).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, true, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, false, true).is_err());
let legacy = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, true, false)
.expect("legacy generation capability proof");
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &legacy, true, true, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &[], true, true, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, Uuid::new_v4(), server_epoch, &proof, true, true, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &legacy, true, true).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &[], true, true).is_err());
assert!(verify_ns_scanner_capability_proof(secret, Uuid::new_v4(), server_epoch, &proof, true, true).is_err());
}
#[test]
@@ -2616,14 +2233,14 @@ mod tests {
let secret = "test-scanner-capability-secret";
let challenge = Uuid::new_v4();
let server_epoch = Uuid::new_v4();
let proof = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, true, false, false)
let proof = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, true, false)
.expect("generation capability proof should be generated");
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, true, false, false).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, false, false, false).is_err());
let legacy = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, false, false, false)
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, true, false).is_ok());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &proof, false, false).is_err());
let legacy = generate_ns_scanner_capability_proof(secret, challenge, server_epoch, false, false)
.expect("legacy capability proof should be generated");
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &legacy, true, false, false).is_err());
assert!(verify_ns_scanner_capability_proof(secret, challenge, server_epoch, &legacy, true, false).is_err());
}
/// Security regression for GHSA-r5qv-rc46-hv8q (internode RPC fail-closed,
@@ -3280,55 +2897,6 @@ mod tests {
assert!(verify_tonic_peer_replay_capabilities_response("node-a:9000", challenge, &changed_capability).is_err());
}
#[test]
fn msgpack_manifest_capability_is_requested_explicitly_and_proved_for_one_epoch() {
ensure_test_rpc_secret();
let challenge = Uuid::new_v4();
let mut request_headers = HeaderMap::new();
assert!(!tonic_msgpack_manifest_capability_requested(&request_headers));
request_headers.insert(
RPC_MSGPACK_MANIFEST_CAPABILITY_REQUEST_HEADER,
HeaderValue::from_static(RPC_MSGPACK_MANIFEST_CAPABILITY_V1),
);
assert!(tonic_msgpack_manifest_capability_requested(&request_headers));
request_headers.insert(
RPC_MSGPACK_MANIFEST_CAPABILITY_REQUEST_HEADER,
HeaderValue::from_static("msgpack-compat-manifest-v2"),
);
assert!(!tonic_msgpack_manifest_capability_requested(&request_headers));
let legacy_headers = tonic_boot_epoch_response_headers("node-a:9000", challenge).expect("legacy capability headers");
let legacy = verify_tonic_peer_msgpack_capabilities_response("node-a:9000", challenge, &legacy_headers)
.expect("authenticated response without msgpack capability");
assert_eq!(legacy.boot_epoch, tonic_rpc_boot_epoch());
assert!(!legacy.msgpack_compat_manifest);
let headers = tonic_boot_epoch_response_headers_with_msgpack_capability("node-a:9000", challenge, true)
.expect("msgpack capability headers");
let capability = verify_tonic_peer_msgpack_capabilities_response("node-a:9000", challenge, &headers)
.expect("matching msgpack capability proof");
assert_eq!(capability.boot_epoch, tonic_rpc_boot_epoch());
assert!(capability.msgpack_compat_manifest);
assert!(verify_tonic_peer_msgpack_capabilities_response("node-b:9000", challenge, &headers).is_err());
assert!(verify_tonic_peer_msgpack_capabilities_response("node-a:9000", Uuid::new_v4(), &headers).is_err());
let mut changed_capability = headers.clone();
changed_capability.insert(
RPC_MSGPACK_MANIFEST_CAPABILITY_HEADER,
HeaderValue::from_static("msgpack-compat-manifest-v2"),
);
assert!(verify_tonic_peer_msgpack_capabilities_response("node-a:9000", challenge, &changed_capability).is_err());
let mut forged_proof = headers;
forged_proof.insert(RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_HEADER, HeaderValue::from_static("forged"));
assert!(verify_tonic_peer_msgpack_capabilities_response("node-a:9000", challenge, &forged_proof).is_err());
let mut missing_proof = forged_proof.clone();
missing_proof.remove(RPC_MSGPACK_MANIFEST_CAPABILITY_PROOF_HEADER);
assert!(verify_tonic_peer_msgpack_capabilities_response("node-a:9000", challenge, &missing_proof).is_err());
let mut missing_value = forged_proof;
missing_value.remove(RPC_MSGPACK_MANIFEST_CAPABILITY_HEADER);
assert!(verify_tonic_peer_msgpack_capabilities_response("node-a:9000", challenge, &missing_value).is_err());
}
#[test]
fn tonic_rpc_auth_failure_reason_maps_security_relevant_errors() {
for (message, reason) in [
@@ -3627,10 +3195,6 @@ mod tests {
tonic_rpc_metric_operation("/node_service.NodeService/WriteAll"),
INTERNODE_OPERATION_GRPC_WRITE_ALL
);
assert_eq!(
tonic_rpc_metric_operation("/node_service.NodeService/WriteFormatControl"),
INTERNODE_OPERATION_GRPC_WRITE_ALL
);
assert_eq!(
tonic_rpc_metric_operation("/node_service.NodeService/CompareAndUpdateFile"),
INTERNODE_OPERATION_GRPC_COMPARE_AND_UPDATE_FILE
@@ -14,16 +14,14 @@
use crate::cluster::rpc::{
build_auth_headers, build_put_file_auth_trailer, verify_ns_scanner_capability_with_checkpoint_coverage,
verify_ns_scanner_capability_with_durable_progress, verify_ns_scanner_capability_with_tier_registry_generation,
verify_ns_scanner_capability_with_usage_capabilities, verify_put_file_capability,
verify_ns_scanner_capability_with_tier_registry_generation, verify_put_file_capability,
};
use crate::disk::error::{Error, Result};
use crate::disk::{FileReader, FileWriter};
use crate::storage_api_contracts::internode::{
NS_SCANNER_BODY_SHA256_QUERY, NS_SCANNER_CAPABILITY_CHALLENGE_QUERY, NS_SCANNER_CHECKPOINT_COVERAGE_QUERY,
NS_SCANNER_COMPLETE_OBSERVATION_QUERY, NS_SCANNER_CYCLE_QUERY, NS_SCANNER_DURABLE_PROGRESS_QUERY,
NS_SCANNER_LEADER_EPOCH_QUERY, NS_SCANNER_PROTOCOL_VERSION, NS_SCANNER_PROTOCOL_VERSION_QUERY, NS_SCANNER_REQUEST_ID_QUERY,
NS_SCANNER_SERVER_EPOCH_QUERY, NS_SCANNER_SESSION_ID_QUERY, NS_SCANNER_SESSION_SEQUENCE_QUERY,
NS_SCANNER_CYCLE_QUERY, NS_SCANNER_LEADER_EPOCH_QUERY, NS_SCANNER_PROTOCOL_VERSION, NS_SCANNER_PROTOCOL_VERSION_QUERY,
NS_SCANNER_REQUEST_ID_QUERY, NS_SCANNER_SERVER_EPOCH_QUERY, NS_SCANNER_SESSION_ID_QUERY, NS_SCANNER_SESSION_SEQUENCE_QUERY,
NS_SCANNER_TIER_REGISTRY_GENERATION_QUERY, NsScannerCapabilityResponse, PUT_FILE_AUTH_QUERY, PUT_FILE_AUTH_V1,
PUT_FILE_CAPABILITY_CHALLENGE_QUERY, PUT_FILE_CAPABILITY_QUERY, PUT_FILE_CAPABILITY_VERSION, PUT_FILE_NONCE_QUERY,
PUT_FILE_SERVER_EPOCH_QUERY, PutFileCapabilityResponse, WALK_DIR_BODY_SHA256_QUERY, WALK_DIR_STREAM_COMPLETION_QUERY,
@@ -32,8 +30,8 @@ use crate::storage_api_contracts::internode::{
use async_trait::async_trait;
use http::{HeaderMap, HeaderValue, Method, header::CONTENT_TYPE};
use rustfs_config::{
DEFAULT_INTERNODE_DATA_TRANSPORT, ENV_RUSTFS_INTERNODE_DATA_TRANSPORT, INTERNODE_DATA_TRANSPORT_NIXL,
INTERNODE_DATA_TRANSPORT_TCP, KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS,
DEFAULT_INTERNODE_DATA_TRANSPORT, ENV_RUSTFS_INTERNODE_DATA_TRANSPORT, INTERNODE_DATA_TRANSPORT_TCP,
KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS,
};
use rustfs_rio::{
ChunkReaderBox, HttpChunkReader, HttpReader, HttpWriter, HttpWriterMemoryReservation, HttpWriterMemoryReserver,
@@ -65,7 +63,7 @@ const NS_SCANNER_PATH: &str = "/rustfs/rpc/ns_scanner";
const NS_SCANNER_MAX_CAPABILITY_RESPONSE_SIZE: usize = 1024;
const PUT_FILE_MAX_CAPABILITY_RESPONSE_SIZE: usize = 1024;
const PUT_FILE_LEGACY_CAPABILITY_TTL: Duration = Duration::from_secs(30);
pub(super) const PUT_FILE_V1_CAPABILITY_TTL: Duration = Duration::from_secs(30);
const PUT_FILE_V1_CAPABILITY_TTL: Duration = Duration::from_secs(30);
const PUT_FILE_CAPABILITY_PROBE_TIMEOUT: Duration = Duration::from_secs(5);
const CONTENT_TYPE_JSON: &str = "application/json";
const CONTENT_TYPE_MSGPACK: &str = "application/msgpack";
@@ -91,7 +89,7 @@ fn unsupported_transport_message(transport: &str) -> String {
}
#[derive(Debug, Clone, Copy)]
pub(super) enum PutFileCapabilityState {
enum PutFileCapabilityState {
LegacyUntil(Instant),
V1 { server_epoch: Uuid, revalidate_after: Instant },
}
@@ -120,8 +118,8 @@ struct PutFileCapabilityFlight {
}
#[derive(Debug, Default)]
pub(super) struct PutFileCapabilityCacheState {
pub(super) cached: Option<PutFileCapabilityState>,
struct PutFileCapabilityCacheState {
cached: Option<PutFileCapabilityState>,
generation: u64,
in_flight: Option<PutFileCapabilityFlight>,
rejected_server_epoch: Option<Uuid>,
@@ -130,12 +128,12 @@ pub(super) struct PutFileCapabilityCacheState {
// The registry lock is released before taking an entry lock. Entry guards cover
// only cache transitions, never a probe or await; poll-based writers must be
// able to reject an epoch atomically with those transitions.
pub(super) type PutFileCapabilityCacheEntry = Arc<parking_lot::RwLock<PutFileCapabilityCacheState>>;
type PutFileCapabilityCacheEntry = Arc<parking_lot::RwLock<PutFileCapabilityCacheState>>;
static PUT_FILE_CAPABILITY_CACHE: LazyLock<parking_lot::RwLock<HashMap<String, PutFileCapabilityCacheEntry>>> =
LazyLock::new(|| parking_lot::RwLock::new(HashMap::new()));
pub(super) fn put_file_capability_cache_entry(endpoint: &str) -> PutFileCapabilityCacheEntry {
fn put_file_capability_cache_entry(endpoint: &str) -> PutFileCapabilityCacheEntry {
if let Some(entry) = PUT_FILE_CAPABILITY_CACHE.read().get(endpoint).cloned() {
return entry;
}
@@ -157,7 +155,7 @@ fn fresh_put_file_capability(state: Option<PutFileCapabilityState>, now: Instant
}
}
pub(super) fn reject_put_file_server_epoch(endpoint: &str, server_epoch: Uuid) {
fn reject_put_file_server_epoch(endpoint: &str, server_epoch: Uuid) {
let entry = PUT_FILE_CAPABILITY_CACHE.read().get(endpoint).cloned();
if let Some(entry) = entry {
let mut state = entry.write();
@@ -279,9 +277,6 @@ pub struct NsScannerCapabilityRequest {
pub endpoint: String,
pub supports_tier_registry_generation: bool,
pub supports_checkpoint_coverage: bool,
pub supports_durable_progress: bool,
pub supports_complete_observation: bool,
pub supports_usage_watch: bool,
}
/// Data-plane stream opener used by `RemoteDisk`.
@@ -322,9 +317,6 @@ pub trait InternodeDataTransport: Send + Sync + std::fmt::Debug {
proof: Vec::new(),
supports_tier_registry_generation: None,
supports_checkpoint_coverage: None,
supports_durable_progress: None,
supports_complete_observation: None,
usage_watch_proof: None,
})
}
// Interface facet nobody calls yet: every transport implements both, but no
@@ -419,53 +411,11 @@ impl InternodeDataTransport for TcpHttpInternodeDataTransport {
}
async fn probe_ns_scanner_capability(&self, request: NsScannerCapabilityRequest) -> Result<NsScannerCapabilityResponse> {
let request = if request.supports_usage_watch {
match self.probe_ns_scanner_capability_once(&request).await {
Ok(response) => return Ok(response),
Err(error) if ns_scanner_capability_error_allows_legacy(&error) => NsScannerCapabilityRequest {
supports_usage_watch: false,
..request
},
Err(error) => return Err(error),
}
} else {
request
};
let request = if request.supports_complete_observation {
match self.probe_ns_scanner_capability_once(&request).await {
Ok(response) => return Ok(response),
Err(error) if ns_scanner_capability_error_allows_legacy(&error) => NsScannerCapabilityRequest {
supports_complete_observation: false,
supports_usage_watch: false,
..request
},
Err(error) => return Err(error),
}
} else {
request
};
let request = if request.supports_durable_progress {
match self.probe_ns_scanner_capability_once(&request).await {
Ok(response) => return Ok(response),
Err(error) if ns_scanner_capability_error_allows_legacy(&error) => NsScannerCapabilityRequest {
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
..request
},
Err(error) => return Err(error),
}
} else {
request
};
let request = if request.supports_checkpoint_coverage {
match self.probe_ns_scanner_capability_once(&request).await {
Ok(response) => return Ok(response),
Err(error) if ns_scanner_capability_error_allows_legacy(&error) => NsScannerCapabilityRequest {
supports_checkpoint_coverage: false,
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
..request
},
Err(error) => return Err(error),
@@ -485,9 +435,6 @@ impl InternodeDataTransport for TcpHttpInternodeDataTransport {
endpoint: request.endpoint.clone(),
supports_tier_registry_generation: false,
supports_checkpoint_coverage: false,
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
};
match self.probe_ns_scanner_capability_once(&legacy_request).await {
Ok(mut response) => {
@@ -545,62 +492,13 @@ impl TcpHttpInternodeDataTransport {
if response.version != NS_SCANNER_PROTOCOL_VERSION || response.server_epoch.is_nil() {
return Err(Error::other("incompatible remote namespace scanner capability response"));
}
if request.supports_usage_watch {
if let Some(proof) = response.usage_watch_proof.as_deref() {
crate::cluster::rpc::verify_ns_scanner_usage_watch_capability(challenge, response.server_epoch, proof)
.map_err(|_| Error::other("remote namespace scanner usage watch capability authentication failed"))?;
}
} else {
response.usage_watch_proof = None;
}
if let Err(err) = verify_ns_scanner_capability_with_usage_capabilities(
if let Err(err) = verify_ns_scanner_capability_with_checkpoint_coverage(
challenge,
response.server_epoch,
&response.proof,
request.supports_tier_registry_generation,
request.supports_checkpoint_coverage,
request.supports_durable_progress,
request.supports_complete_observation,
) {
if request.supports_complete_observation
&& verify_ns_scanner_capability_with_durable_progress(
challenge,
response.server_epoch,
&response.proof,
request.supports_tier_registry_generation,
request.supports_checkpoint_coverage,
request.supports_durable_progress,
)
.is_ok()
{
normalize_ns_scanner_capability_response(
&mut response,
request.supports_tier_registry_generation,
request.supports_checkpoint_coverage,
request.supports_durable_progress,
false,
);
return Ok(response);
}
if request.supports_durable_progress
&& verify_ns_scanner_capability_with_checkpoint_coverage(
challenge,
response.server_epoch,
&response.proof,
request.supports_tier_registry_generation,
request.supports_checkpoint_coverage,
)
.is_ok()
{
normalize_ns_scanner_capability_response(
&mut response,
request.supports_tier_registry_generation,
request.supports_checkpoint_coverage,
false,
false,
);
return Ok(response);
}
if request.supports_checkpoint_coverage
&& verify_ns_scanner_capability_with_tier_registry_generation(
challenge,
@@ -610,13 +508,7 @@ impl TcpHttpInternodeDataTransport {
)
.is_ok()
{
normalize_ns_scanner_capability_response(
&mut response,
request.supports_tier_registry_generation,
false,
false,
false,
);
normalize_ns_scanner_capability_response(&mut response, request.supports_tier_registry_generation, false);
return Ok(response);
}
// A permissive older peer can ignore the additive marker and
@@ -626,8 +518,6 @@ impl TcpHttpInternodeDataTransport {
if request.supports_tier_registry_generation && ns_scanner_capability_legacy_proof_is_valid(challenge, &response) {
response.supports_tier_registry_generation = None;
response.supports_checkpoint_coverage = None;
response.supports_durable_progress = None;
response.supports_complete_observation = None;
return Ok(response);
}
return Err(Error::other(format!("remote namespace scanner capability authentication failed: {err}")));
@@ -641,13 +531,11 @@ impl TcpHttpInternodeDataTransport {
&mut response,
request.supports_tier_registry_generation,
request.supports_checkpoint_coverage,
request.supports_durable_progress,
request.supports_complete_observation,
);
Ok(response)
}
pub(super) async fn put_file_auth_capability(&self, endpoint: &str) -> Result<Option<Uuid>> {
async fn put_file_auth_capability(&self, endpoint: &str) -> Result<Option<Uuid>> {
resolve_put_file_auth_capability(endpoint, || async {
tokio::time::timeout(PUT_FILE_CAPABILITY_PROBE_TIMEOUT, self.probe_put_file_auth(endpoint))
.await
@@ -777,7 +665,7 @@ fn verify_put_file_capability_response(challenge: Uuid, body: &[u8]) -> Result<U
Ok(response.server_epoch)
}
pub(super) fn build_read_file_stream_url(request: &ReadStreamRequest) -> String {
fn build_read_file_stream_url(request: &ReadStreamRequest) -> String {
format!(
"{}{}?disk={}&volume={}&path={}&offset={}&length={}",
request.endpoint,
@@ -827,7 +715,7 @@ fn build_put_file_capability_url(endpoint: &str, challenge: Uuid) -> String {
)
}
pub(super) struct PutFileAuthWriter<W> {
struct PutFileAuthWriter<W> {
inner: W,
url: String,
nonce: Uuid,
@@ -840,7 +728,7 @@ pub(super) struct PutFileAuthWriter<W> {
}
impl<W> PutFileAuthWriter<W> {
pub(super) fn new(inner: W, url: String, nonce: Uuid, endpoint: String, server_epoch: Uuid) -> Self {
fn new(inner: W, url: String, nonce: Uuid, endpoint: String, server_epoch: Uuid) -> Self {
Self {
inner,
url,
@@ -977,13 +865,9 @@ fn normalize_ns_scanner_capability_response(
response: &mut NsScannerCapabilityResponse,
requested_generation_support: bool,
requested_checkpoint_coverage: bool,
requested_durable_progress: bool,
requested_complete_observation: bool,
) {
response.supports_tier_registry_generation = requested_generation_support.then_some(true);
response.supports_checkpoint_coverage = requested_checkpoint_coverage.then_some(true);
response.supports_durable_progress = requested_durable_progress.then_some(true);
response.supports_complete_observation = requested_complete_observation.then_some(true);
}
fn ns_scanner_capability_legacy_proof_is_valid(challenge: Uuid, response: &NsScannerCapabilityResponse) -> bool {
@@ -1016,7 +900,7 @@ fn build_ns_scanner_url(request: &NsScannerStreamRequest) -> String {
fn build_ns_scanner_capability_url(request: &NsScannerCapabilityRequest, challenge: Uuid) -> String {
format!(
"{}{}?{}={}&{}={}{}{}{}{}{}",
"{}{}?{}={}&{}={}{}{}",
request.endpoint,
NS_SCANNER_PATH,
NS_SCANNER_PROTOCOL_VERSION_QUERY,
@@ -1032,26 +916,11 @@ fn build_ns_scanner_capability_url(request: &NsScannerCapabilityRequest, challen
format!("&{}=true", NS_SCANNER_CHECKPOINT_COVERAGE_QUERY)
} else {
String::new()
},
if request.supports_durable_progress {
format!("&{}=true", NS_SCANNER_DURABLE_PROGRESS_QUERY)
} else {
String::new()
},
if request.supports_complete_observation {
format!("&{}=true", NS_SCANNER_COMPLETE_OBSERVATION_QUERY)
} else {
String::new()
},
if request.supports_usage_watch {
"&ns_scanner_usage_watch=true".to_string()
} else {
String::new()
}
)
}
pub(super) fn json_headers() -> HeaderMap {
fn json_headers() -> HeaderMap {
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static(CONTENT_TYPE_JSON));
headers
@@ -1074,9 +943,6 @@ fn build_internode_data_transport_result(
{
Ok(Arc::new(TcpHttpInternodeDataTransport))
}
Some(transport) if transport.eq_ignore_ascii_case(INTERNODE_DATA_TRANSPORT_NIXL) => {
Ok(Arc::new(super::nixl_internode::NixlInternodeDataTransport::from_env()))
}
Some(transport) => Err(unsupported_transport_message(transport)),
}
}
@@ -1428,9 +1294,6 @@ mod tests {
endpoint: "http://node1:9000".to_string(),
supports_tier_registry_generation: false,
supports_checkpoint_coverage: false,
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
})
.await
.expect_err("legacy transport should report namespace scanner as unsupported");
@@ -1457,106 +1320,6 @@ mod tests {
assert!(matches!(open_err, Error::MethodNotAllowed));
}
#[tokio::test]
async fn namespace_scanner_watch_capability_preserves_older_capabilities_and_rejects_stale_proof() {
crate::runtime::sources::ensure_test_rpc_secret();
for peer in ["current", "strict-old", "missing-watch", "stale-watch"] {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
.await
.expect("watch capability listener");
let address = listener.local_addr().expect("listener address");
let epoch = Uuid::new_v4();
let server = tokio::spawn(async move {
let requests = if peer == "strict-old" { 2 } else { 1 };
for index in 0..requests {
let (mut socket, _) = listener.accept().await.expect("watch capability request");
let mut bytes = Vec::new();
while !bytes.windows(4).any(|window| window == b"\r\n\r\n") {
let mut chunk = [0; 1024];
let read = socket.read(&mut chunk).await.expect("request headers");
assert!(read > 0 && bytes.len() < 16 * 1024);
bytes.extend_from_slice(&chunk[..read]);
}
let headers = std::str::from_utf8(&bytes).expect("HTTP headers");
let target = headers.split_whitespace().nth(1).expect("target");
let url = reqwest::Url::parse(&format!("http://{address}{target}")).expect("request URL");
let query: HashMap<_, _> = url.query_pairs().into_owned().collect();
assert_eq!(query.contains_key("ns_scanner_usage_watch"), index == 0);
assert!(query.contains_key(NS_SCANNER_DURABLE_PROGRESS_QUERY));
assert!(query.contains_key(NS_SCANNER_COMPLETE_OBSERVATION_QUERY));
if peer == "strict-old" && index == 0 {
socket
.write_all(b"HTTP/1.1 400 Bad Request\r\ncontent-length: 0\r\nconnection: close\r\n\r\n")
.await
.expect("old parser rejects only the new field");
continue;
}
let challenge = query[NS_SCANNER_CAPABILITY_CHALLENGE_QUERY].parse().expect("challenge");
let proof = crate::cluster::rpc::sign_ns_scanner_capability_with_usage_capabilities(
challenge, epoch, true, true, true, true,
)
.expect("prior capability proof");
let usage_watch_proof = match peer {
"current" => Some(
crate::cluster::rpc::sign_ns_scanner_usage_watch_capability(challenge, epoch).expect("watch proof"),
),
"stale-watch" => Some(
crate::cluster::rpc::sign_ns_scanner_usage_watch_capability(Uuid::new_v4(), epoch)
.expect("stale watch proof"),
),
_ => None,
};
let body = rmp_serde::to_vec_named(&NsScannerCapabilityResponse {
version: NS_SCANNER_PROTOCOL_VERSION,
server_epoch: epoch,
proof,
supports_tier_registry_generation: Some(true),
supports_checkpoint_coverage: Some(true),
supports_durable_progress: Some(true),
supports_complete_observation: Some(true),
usage_watch_proof,
})
.expect("capability body");
socket
.write_all(
format!("HTTP/1.1 200 OK\r\ncontent-length: {}\r\nconnection: close\r\n\r\n", body.len()).as_bytes(),
)
.await
.expect("response headers");
socket.write_all(&body).await.expect("response body");
}
requests
});
let response = tokio::time::timeout(
Duration::from_secs(10),
TcpHttpInternodeDataTransport.probe_ns_scanner_capability(NsScannerCapabilityRequest {
endpoint: format!("http://{address}"),
supports_tier_registry_generation: true,
supports_checkpoint_coverage: true,
supports_durable_progress: true,
supports_complete_observation: true,
supports_usage_watch: true,
}),
)
.await
.expect("bounded probe");
if peer == "stale-watch" {
assert!(
response
.expect_err("stale response must fail authentication")
.to_string()
.contains("authentication failed")
);
} else {
let response = response.expect("verified capability result");
assert_eq!(response.usage_watch_proof.is_some(), peer == "current");
assert_eq!(response.supports_durable_progress, Some(true));
assert_eq!(response.supports_complete_observation, Some(true));
}
assert_eq!(server.await.expect("capability server"), if peer == "strict-old" { 2 } else { 1 });
}
}
#[tokio::test]
async fn namespace_scanner_checkpoint_capability_authenticates_new_and_legacy_peers() {
crate::runtime::sources::ensure_test_rpc_secret();
@@ -1609,9 +1372,6 @@ mod tests {
supports_tier_registry_generation: Some(true),
// Strip a supported bit, or forge it for an older peer.
supports_checkpoint_coverage: (peer != "current").then_some(true),
supports_durable_progress: None,
supports_complete_observation: None,
usage_watch_proof: None,
})
.expect("capability response");
socket
@@ -1630,9 +1390,6 @@ mod tests {
endpoint: format!("http://{address}"),
supports_tier_registry_generation: true,
supports_checkpoint_coverage: true,
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
}),
)
.await
@@ -1654,206 +1411,6 @@ mod tests {
}
}
#[tokio::test]
async fn namespace_scanner_durable_progress_capability_authenticates_new_and_legacy_peers() {
crate::runtime::sources::ensure_test_rpc_secret();
for peer in ["current", "strict-old", "permissive-old", "invalid-proof", "missing-proof"] {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
.await
.expect("capability listener");
let address = listener.local_addr().expect("capability listener address");
let server_epoch = Uuid::new_v4();
let server = tokio::spawn(async move {
let requests = if peer == "strict-old" { 2 } else { 1 };
for index in 0..requests {
let (mut socket, _) = listener.accept().await.expect("capability request");
let mut bytes = Vec::new();
while !bytes.windows(4).any(|window| window == b"\r\n\r\n") {
let mut chunk = [0; 1024];
let read = socket.read(&mut chunk).await.expect("capability headers");
assert!(read > 0 && bytes.len() < 16 * 1024, "bounded complete capability headers");
bytes.extend_from_slice(&chunk[..read]);
}
let request = std::str::from_utf8(&bytes).expect("HTTP headers");
let target = request.split_whitespace().nth(1).expect("HTTP request target");
let url = reqwest::Url::parse(&format!("http://{address}{target}")).expect("capability URL");
let query: HashMap<_, _> = url.query_pairs().into_owned().collect();
assert_eq!(query.get(NS_SCANNER_TIER_REGISTRY_GENERATION_QUERY).map(String::as_str), Some("true"));
assert_eq!(query.contains_key(NS_SCANNER_DURABLE_PROGRESS_QUERY), index == 0);
if peer == "strict-old" && index == 0 {
socket
.write_all(b"HTTP/1.1 400 Bad Request\r\ncontent-length: 0\r\nconnection: close\r\n\r\n")
.await
.expect("legacy parser rejection");
continue;
}
let challenge = query[NS_SCANNER_CAPABILITY_CHALLENGE_QUERY].parse().expect("challenge UUID");
let proof = match peer {
"invalid-proof" => vec![0; 32],
"missing-proof" => Vec::new(),
_ => crate::cluster::rpc::sign_ns_scanner_capability_with_durable_progress(
challenge,
server_epoch,
true,
true,
peer == "current",
)
.expect("server capability proof"),
};
let body = rmp_serde::to_vec_named(&NsScannerCapabilityResponse {
version: NS_SCANNER_PROTOCOL_VERSION,
server_epoch,
proof,
supports_tier_registry_generation: Some(true),
// Strip a supported bit, or forge it for an older peer.
supports_checkpoint_coverage: Some(true),
supports_durable_progress: (peer != "current").then_some(true),
supports_complete_observation: None,
usage_watch_proof: None,
})
.expect("capability response");
socket
.write_all(
format!("HTTP/1.1 200 OK\r\ncontent-length: {}\r\nconnection: close\r\n\r\n", body.len()).as_bytes(),
)
.await
.expect("capability response headers");
socket.write_all(&body).await.expect("capability response body");
}
requests
});
let response = tokio::time::timeout(
Duration::from_secs(10),
TcpHttpInternodeDataTransport.probe_ns_scanner_capability(NsScannerCapabilityRequest {
endpoint: format!("http://{address}"),
supports_tier_registry_generation: true,
supports_checkpoint_coverage: true,
supports_durable_progress: true,
supports_complete_observation: false,
supports_usage_watch: false,
}),
)
.await
.expect("bounded capability probe");
if peer.ends_with("proof") {
assert!(
response
.expect_err("unverified capability must fail closed")
.to_string()
.contains("authentication failed")
);
} else {
let response = response.expect("authenticated capability");
assert_eq!(response.server_epoch, server_epoch);
assert_eq!(response.supports_tier_registry_generation, Some(true));
assert_eq!(response.supports_checkpoint_coverage, Some(true));
assert_eq!(response.supports_durable_progress, (peer == "current").then_some(true));
}
assert_eq!(server.await.expect("capability server"), if peer == "strict-old" { 2 } else { 1 });
}
}
#[tokio::test]
async fn namespace_scanner_complete_observation_capability_authenticates_new_and_legacy_peers() {
crate::runtime::sources::ensure_test_rpc_secret();
for peer in ["current", "strict-old", "permissive-old", "invalid-proof", "missing-proof"] {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
.await
.expect("capability listener");
let address = listener.local_addr().expect("capability listener address");
let server_epoch = Uuid::new_v4();
let server = tokio::spawn(async move {
let requests = if peer == "strict-old" { 2 } else { 1 };
for index in 0..requests {
let (mut socket, _) = listener.accept().await.expect("capability request");
let mut bytes = Vec::new();
while !bytes.windows(4).any(|window| window == b"\r\n\r\n") {
let mut chunk = [0; 1024];
let read = socket.read(&mut chunk).await.expect("capability headers");
assert!(read > 0 && bytes.len() < 16 * 1024, "bounded complete capability headers");
bytes.extend_from_slice(&chunk[..read]);
}
let request = std::str::from_utf8(&bytes).expect("HTTP headers");
let target = request.split_whitespace().nth(1).expect("HTTP request target");
let url = reqwest::Url::parse(&format!("http://{address}{target}")).expect("capability URL");
let query: HashMap<_, _> = url.query_pairs().into_owned().collect();
assert_eq!(query.get(NS_SCANNER_TIER_REGISTRY_GENERATION_QUERY).map(String::as_str), Some("true"));
assert_eq!(query.contains_key(NS_SCANNER_COMPLETE_OBSERVATION_QUERY), index == 0);
if peer == "strict-old" && index == 0 {
socket
.write_all(b"HTTP/1.1 400 Bad Request\r\ncontent-length: 0\r\nconnection: close\r\n\r\n")
.await
.expect("legacy parser rejection");
continue;
}
let challenge = query[NS_SCANNER_CAPABILITY_CHALLENGE_QUERY].parse().expect("challenge UUID");
let proof = match peer {
"invalid-proof" => vec![0; 32],
"missing-proof" => Vec::new(),
_ => crate::cluster::rpc::sign_ns_scanner_capability_with_usage_capabilities(
challenge,
server_epoch,
true,
true,
true,
peer == "current",
)
.expect("server capability proof"),
};
let body = rmp_serde::to_vec_named(&NsScannerCapabilityResponse {
version: NS_SCANNER_PROTOCOL_VERSION,
server_epoch,
proof,
supports_tier_registry_generation: Some(true),
// Strip a supported bit, or forge it for an older peer.
supports_checkpoint_coverage: Some(true),
supports_durable_progress: Some(true),
supports_complete_observation: (peer != "current").then_some(true),
usage_watch_proof: None,
})
.expect("capability response");
socket
.write_all(
format!("HTTP/1.1 200 OK\r\ncontent-length: {}\r\nconnection: close\r\n\r\n", body.len()).as_bytes(),
)
.await
.expect("capability response headers");
socket.write_all(&body).await.expect("capability response body");
}
requests
});
let response = tokio::time::timeout(
Duration::from_secs(10),
TcpHttpInternodeDataTransport.probe_ns_scanner_capability(NsScannerCapabilityRequest {
endpoint: format!("http://{address}"),
supports_tier_registry_generation: true,
supports_checkpoint_coverage: true,
supports_durable_progress: true,
supports_complete_observation: true,
supports_usage_watch: false,
}),
)
.await
.expect("bounded capability probe");
if peer.ends_with("proof") {
assert!(
response
.expect_err("unverified capability must fail closed")
.to_string()
.contains("authentication failed")
);
} else {
let response = response.expect("authenticated capability");
assert_eq!(response.server_epoch, server_epoch);
assert_eq!(response.supports_tier_registry_generation, Some(true));
assert_eq!(response.supports_checkpoint_coverage, Some(true));
assert_eq!(response.supports_durable_progress, Some(true));
assert_eq!(response.supports_complete_observation, (peer == "current").then_some(true));
}
assert_eq!(server.await.expect("capability server"), if peer == "strict-old" { 2 } else { 1 });
}
}
#[tokio::test]
async fn walk_dir_restores_explicit_remote_missing_error() {
let _ = rustfs_credentials::set_global_rpc_secret("walk-dir-error-test-secret".to_string());
@@ -2597,9 +2154,6 @@ mod tests {
endpoint: "http://node1:9000".to_string(),
supports_tier_registry_generation: false,
supports_checkpoint_coverage: false,
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
},
challenge,
);
@@ -2620,9 +2174,6 @@ mod tests {
endpoint: "http://node1:9000".to_string(),
supports_tier_registry_generation: true,
supports_checkpoint_coverage: false,
supports_durable_progress: false,
supports_complete_observation: false,
supports_usage_watch: false,
},
challenge,
);
@@ -2662,16 +2213,13 @@ mod tests {
proof: Vec::new(),
supports_tier_registry_generation: None,
supports_checkpoint_coverage: None,
supports_durable_progress: None,
supports_complete_observation: None,
usage_watch_proof: None,
};
normalize_ns_scanner_capability_response(&mut response, true, true, false, false);
normalize_ns_scanner_capability_response(&mut response, true, true);
assert_eq!(response.supports_tier_registry_generation, Some(true));
response.supports_tier_registry_generation = Some(false);
normalize_ns_scanner_capability_response(&mut response, false, false, false, false);
normalize_ns_scanner_capability_response(&mut response, false, false);
assert_eq!(response.supports_tier_registry_generation, None);
}
@@ -2686,9 +2234,6 @@ mod tests {
.expect("placeholder proof should be generated"),
supports_tier_registry_generation: None,
supports_checkpoint_coverage: None,
supports_durable_progress: None,
supports_complete_observation: None,
usage_watch_proof: None,
};
// A proof bound to a different challenge cannot authorize the legacy
// fallback, even though the response has the expected shape.
@@ -2735,24 +2280,13 @@ mod tests {
fn transport_config_known_backends_are_current_oss_values() {
assert_eq!(
KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS,
&[
DEFAULT_INTERNODE_DATA_TRANSPORT,
INTERNODE_DATA_TRANSPORT_TCP,
INTERNODE_DATA_TRANSPORT_NIXL
]
&[DEFAULT_INTERNODE_DATA_TRANSPORT, INTERNODE_DATA_TRANSPORT_TCP]
);
for configured in KNOWN_INTERNODE_DATA_TRANSPORT_BACKENDS {
let transport = build_internode_data_transport(Some(configured)).unwrap();
// NIXL builds everywhere and serves reads over TCP/HTTP until a node
// installs its receive pool; every other known name is the TCP transport.
let expected = if *configured == INTERNODE_DATA_TRANSPORT_NIXL {
INTERNODE_DATA_TRANSPORT_NIXL
} else {
DEFAULT_INTERNODE_DATA_TRANSPORT
};
assert_eq!(transport.name(), expected);
assert_eq!(transport.name(), DEFAULT_INTERNODE_DATA_TRANSPORT);
}
}
+6 -11
View File
@@ -20,7 +20,6 @@ pub(crate) mod context_propagation;
pub(crate) mod http_auth;
pub(crate) mod internode_data_transport;
mod network_probe;
pub(crate) mod nixl_internode;
pub(crate) mod peer_rest_client;
pub(crate) mod peer_s3_client;
pub(crate) mod remote_disk;
@@ -41,16 +40,12 @@ pub use http_auth::{
gen_tonic_signature_headers, normalize_tonic_rpc_audience, rpc_auth_is_resource_exhausted, rpc_background_admission,
set_tonic_canonical_body_digest, set_tonic_mutation_body_digest, set_tonic_rolling_canonical_body_digest,
set_tonic_rolling_mutation_body_digest, sign_ns_scanner_capability, sign_ns_scanner_capability_with_checkpoint_coverage,
sign_ns_scanner_capability_with_durable_progress, sign_ns_scanner_capability_with_tier_registry_generation,
sign_ns_scanner_capability_with_usage_capabilities, sign_ns_scanner_usage_watch_capability, sign_put_file_capability,
sign_tonic_rpc_response_proof, tonic_boot_epoch_challenge, tonic_boot_epoch_response_headers,
tonic_boot_epoch_response_headers_with_msgpack_capability, tonic_msgpack_manifest_capability_requested,
tonic_rpc_auth_failure_reason, verify_ns_scanner_capability, verify_ns_scanner_capability_with_checkpoint_coverage,
verify_ns_scanner_capability_with_durable_progress, verify_ns_scanner_capability_with_tier_registry_generation,
verify_ns_scanner_capability_with_usage_capabilities, verify_ns_scanner_usage_watch_capability, verify_put_file_auth_trailer,
verify_put_file_capability, verify_rpc_signature, verify_tonic_boot_epoch_response, verify_tonic_canonical_body_digest,
verify_tonic_mutation_body_digest, verify_tonic_mutation_body_digest_reject_unsigned, verify_tonic_rpc_response_proof,
verify_tonic_rpc_signature, verify_tonic_rpc_signature_with_bootstrap,
sign_ns_scanner_capability_with_tier_registry_generation, sign_put_file_capability, sign_tonic_rpc_response_proof,
tonic_boot_epoch_challenge, tonic_boot_epoch_response_headers, tonic_rpc_auth_failure_reason, verify_ns_scanner_capability,
verify_ns_scanner_capability_with_checkpoint_coverage, verify_ns_scanner_capability_with_tier_registry_generation,
verify_put_file_auth_trailer, verify_put_file_capability, verify_rpc_signature, verify_tonic_boot_epoch_response,
verify_tonic_canonical_body_digest, verify_tonic_mutation_body_digest, verify_tonic_mutation_body_digest_reject_unsigned,
verify_tonic_rpc_response_proof, verify_tonic_rpc_signature, verify_tonic_rpc_signature_with_bootstrap,
};
#[cfg(test)]
pub(crate) use internode_data_transport::TcpHttpInternodeDataTransport;
@@ -1,928 +0,0 @@
// 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.
//! Internode shard reads whose bytes move over NIXL/UCX.
//!
//! The reading node keeps a pool of receive buffers registered with its NIXL
//! agent. For every chunk of a remote shard stream it sends a signed request
//! over the existing internode HTTP control plane naming the shard range, its
//! agent, one registered buffer and a digest of its agent metadata; the serving
//! node reads the range into its own registered staging memory and writes it
//! into that buffer with a NIXL WRITE, then answers with the byte count. The
//! buffer reaches the decoder as a zero-copy `Bytes`. Several chunk requests
//! run per stream so request latency overlaps the transfers.
//!
//! UCX addresses ports by LID or GID, so this works on InfiniBand rails that
//! have no IP addresses. Writes, walks and any stream whose first chunk cannot
//! be served this way use the TCP/HTTP transport.
//!
//! Buffer safety: the serving node may still write into a buffer whose request
//! was abandoned (a dropped reader, chunks past the end of the file). Such
//! buffers are held for [`ABANDONED_BUFFER_HOLD`] before they return to the
//! pool, which covers the serving node's transfer timeout.
use super::internode_data_transport::{
InternodeDataTransport, InternodeDataTransportCapabilities, NsScannerCapabilityRequest, NsScannerStreamRequest,
ReadStreamRequest, TcpHttpInternodeDataTransport, WalkDirStreamRequest, WriteStreamRequest, build_read_file_stream_url,
json_headers,
};
use crate::cluster::rpc::build_auth_headers;
use crate::disk::error::Result;
use crate::disk::{FileReader, FileWriter};
use crate::storage_api_contracts::internode::NsScannerCapabilityResponse;
use async_trait::async_trait;
use bytes::Bytes;
use futures::future::BoxFuture;
use futures::stream::{FuturesOrdered, Stream};
use http::{HeaderValue, Method};
use rustfs_config::{DEFAULT_RUSTFS_NIXL_INTERNODE_DEPTH, ENV_RUSTFS_NIXL_INTERNODE_DEPTH};
use rustfs_rio::{ChunkReader, ChunkReaderBox};
use std::io;
use std::pin::Pin;
use std::sync::{Arc, OnceLock};
use std::task::{Context, Poll};
use std::time::Duration;
use tokio::io::{AsyncRead, ReadBuf};
use tracing::debug;
use uuid::Uuid;
/// Internode route of a NIXL chunk read.
pub const READ_FILE_NIXL_PATH: &str = "/rustfs/rpc/read_file_nixl";
/// Internode route of a NIXL shard write: the disk's node pulls the named buffers.
pub const WRITE_FILE_NIXL_PATH: &str = "/rustfs/rpc/write_file_nixl";
/// Comma-separated buffers a NIXL shard write pulls, in file order (signed).
pub const NIXL_BUFFERS_QUERY: &str = "nixl_buffers";
/// One-time nonce of a NIXL shard write (signed; recorded to refuse replays).
pub const NIXL_NONCE_QUERY: &str = "nixl_nonce";
/// Buffers a writer fills before it sends a segment; a part's shard file
/// usually fits in one.
const WRITE_SEGMENT_BUFFERS: usize = 4;
/// The route the URL builder emits, replaced by [`READ_FILE_NIXL_PATH`].
const READ_FILE_STREAM_PATH: &str = "/rustfs/rpc/read_file_stream";
/// Query parameters of a NIXL chunk read (signed with the URL).
pub const NIXL_AGENT_QUERY: &str = "nixl_agent";
pub const NIXL_BUFFER_QUERY: &str = "nixl_buffer";
pub const NIXL_METADATA_SHA256_QUERY: &str = "nixl_md";
/// The reader's agent metadata, base64; must hash to the signed digest.
pub const NIXL_METADATA_HEADER: &str = "x-rustfs-nixl-metadata";
/// Bytes the serving node wrote into the buffer; fewer than asked means end of file.
pub const NIXL_BYTES_HEADER: &str = "x-rustfs-nixl-bytes";
/// How long a buffer whose request was abandoned stays out of the pool.
pub const ABANDONED_BUFFER_HOLD: Duration = Duration::from_secs(120);
/// Request timeout when the caller sets no stall timeout.
const DEFAULT_CHUNK_TIMEOUT: Duration = Duration::from_secs(60);
const EVENT_NIXL_INTERNODE_FALLBACK: &str = "nixl_internode_fallback";
const LOG_COMPONENT_INTERNODE: &str = "internode";
const LOG_SUBSYSTEM_NIXL: &str = "nixl";
/// Receive buffers registered with this node's NIXL agent.
pub trait NixlRecvPool: Send + Sync + 'static {
/// This node's agent name.
fn agent_name(&self) -> &str;
/// This node's agent metadata, base64.
fn metadata_base64(&self) -> &str;
/// Lowercase hex SHA-256 of the raw agent metadata.
fn metadata_sha256_hex(&self) -> &str;
/// Size of one receive buffer; one chunk request moves at most this much.
fn chunk_bytes(&self) -> usize;
/// One free buffer, waiting for one when the pool is busy.
fn reserve(&self) -> BoxFuture<'static, io::Result<Box<dyn NixlRecvBuffer>>>;
}
/// One registered buffer, back in the pool when dropped. Reads land in it;
/// writes stage shard bytes in it for the disk's node to pull.
pub trait NixlRecvBuffer: Send + Sync + 'static {
/// `<dram|vram>:<device>:<address>:<length>` as the serving node parses it.
fn descriptor(&self) -> String;
/// The same for the first `len` bytes.
fn descriptor_for(&self, len: usize) -> String;
/// The whole buffer, writable.
fn spare_mut(&mut self) -> &mut [u8];
/// The first `len` bytes as an owned, zero-copy `Bytes`.
fn into_bytes(self: Box<Self>, len: usize) -> io::Result<Bytes>;
}
static RECV_POOL: OnceLock<Arc<dyn NixlRecvPool>> = OnceLock::new();
/// Installs this node's receive pool; only the first installation wins.
pub fn install_nixl_recv_pool(pool: Arc<dyn NixlRecvPool>) -> bool {
RECV_POOL.set(pool).is_ok()
}
fn recv_pool() -> Option<Arc<dyn NixlRecvPool>> {
RECV_POOL.get().cloned()
}
/// Internode transport that reads shard streams over NIXL and delegates
/// everything else to TCP/HTTP.
#[derive(Debug)]
pub struct NixlInternodeDataTransport {
tcp: TcpHttpInternodeDataTransport,
depth: usize,
}
impl NixlInternodeDataTransport {
pub fn from_env() -> Self {
Self {
tcp: TcpHttpInternodeDataTransport,
depth: rustfs_utils::get_env_usize(ENV_RUSTFS_NIXL_INTERNODE_DEPTH, DEFAULT_RUSTFS_NIXL_INTERNODE_DEPTH).clamp(1, 64),
}
}
/// A NIXL chunk reader for `request` with its first chunk already landed,
/// or `None` when this read should use TCP/HTTP.
async fn open_nixl(&self, request: &ReadStreamRequest) -> Option<NixlChunkReader> {
let pool = recv_pool()?;
if request.length == 0 {
// Unbounded reads need the file size; TCP/HTTP streams them.
return None;
}
let mut reader = NixlChunkReader::new(pool, request.clone(), self.depth);
match futures::future::poll_fn(|cx| reader.state_mut().poll_chunk(cx, usize::MAX)).await {
Ok(Some(first)) => {
reader.state_mut().current = first;
Some(reader)
}
Ok(None) => Some(reader),
Err(error) => {
debug!(
event = EVENT_NIXL_INTERNODE_FALLBACK,
component = LOG_COMPONENT_INTERNODE,
subsystem = LOG_SUBSYSTEM_NIXL,
result = "fallback",
endpoint = %request.endpoint,
error = %error,
"nixl internode read fell back to tcp"
);
None
}
}
}
}
#[async_trait]
impl InternodeDataTransport for NixlInternodeDataTransport {
async fn open_read(&self, request: ReadStreamRequest) -> Result<FileReader> {
match self.open_nixl(&request).await {
Some(reader) => Ok(Box::new(reader)),
None => self.tcp.open_read(request).await,
}
}
async fn open_read_fresh(&self, request: ReadStreamRequest) -> Result<FileReader> {
match self.open_nixl(&request).await {
Some(reader) => Ok(Box::new(reader)),
None => self.tcp.open_read_fresh(request).await,
}
}
async fn open_read_chunks(&self, request: ReadStreamRequest) -> Result<Option<ChunkReaderBox>> {
match self.open_nixl(&request).await {
Some(reader) => Ok(Some(Box::new(reader))),
None => self.tcp.open_read_chunks(request).await,
}
}
async fn open_read_chunks_fresh(&self, request: ReadStreamRequest) -> Result<Option<ChunkReaderBox>> {
match self.open_nixl(&request).await {
Some(reader) => Ok(Some(Box::new(reader))),
None => self.tcp.open_read_chunks_fresh(request).await,
}
}
async fn open_write(&self, request: WriteStreamRequest) -> Result<FileWriter> {
match recv_pool() {
Some(pool) => Ok(Box::new(NixlFileWriter::new(pool, request))),
None => self.tcp.open_write(request).await,
}
}
async fn open_walk_dir(&self, request: WalkDirStreamRequest) -> Result<FileReader> {
self.tcp.open_walk_dir(request).await
}
async fn open_ns_scanner(&self, request: NsScannerStreamRequest) -> Result<FileReader> {
self.tcp.open_ns_scanner(request).await
}
async fn probe_ns_scanner(&self, request: NsScannerCapabilityRequest) -> Result<Uuid> {
self.tcp.probe_ns_scanner(request).await
}
async fn probe_ns_scanner_capability(&self, request: NsScannerCapabilityRequest) -> Result<NsScannerCapabilityResponse> {
self.tcp.probe_ns_scanner_capability(request).await
}
fn name(&self) -> &'static str {
"nixl"
}
fn capabilities(&self) -> InternodeDataTransportCapabilities {
InternodeDataTransportCapabilities::tcp_http()
}
}
/// A receive buffer lent to one chunk request. Unless the request completed,
/// dropping it holds the buffer out of the pool for [`ABANDONED_BUFFER_HOLD`]
/// because the serving node may still be writing into it.
struct LentBuffer {
buffer: Option<Box<dyn NixlRecvBuffer>>,
}
impl LentBuffer {
fn complete(mut self, len: usize) -> io::Result<Bytes> {
let buffer = self.buffer.take().expect("buffer present until completion");
buffer.into_bytes(len)
}
/// The peer is done with the buffer: back to the pool now.
fn release(mut self) {
drop(self.buffer.take());
}
}
impl Drop for LentBuffer {
fn drop(&mut self) {
if let Some(buffer) = self.buffer.take() {
match tokio::runtime::Handle::try_current() {
Ok(handle) => {
handle.spawn(async move {
tokio::time::sleep(ABANDONED_BUFFER_HOLD).await;
drop(buffer);
});
}
// No runtime to wait on: never hand the memory back.
Err(_) => std::mem::forget(buffer),
}
}
}
}
/// Fetches one chunk: the requested length and the bytes that landed.
async fn fetch_chunk(pool: Arc<dyn NixlRecvPool>, request: ReadStreamRequest, timeout: Duration) -> io::Result<(usize, Bytes)> {
let buffer = LentBuffer {
buffer: Some(pool.reserve().await?),
};
let descriptor = buffer.buffer.as_ref().map(|buffer| buffer.descriptor()).unwrap_or_default();
let mut url = build_read_file_stream_url(&request).replacen(READ_FILE_STREAM_PATH, READ_FILE_NIXL_PATH, 1);
url.push_str(&format!(
"&{NIXL_AGENT_QUERY}={}&{NIXL_BUFFER_QUERY}={}&{NIXL_METADATA_SHA256_QUERY}={}",
urlencoding::encode(pool.agent_name()),
urlencoding::encode(&descriptor),
pool.metadata_sha256_hex()
));
let mut headers = json_headers();
headers.insert(
NIXL_METADATA_HEADER,
HeaderValue::from_str(pool.metadata_base64())
.map_err(|_| io::Error::other("nixl agent metadata is not a header value"))?,
);
build_auth_headers(&url, &Method::GET, &mut headers)?;
let (status, response_headers, _) = rustfs_rio::internode_http_request(&url, Method::GET, headers, Some(timeout)).await?;
if !status.is_success() {
debug!(
component = LOG_COMPONENT_INTERNODE,
subsystem = LOG_SUBSYSTEM_NIXL,
result = "failed",
status = status.as_u16(),
"nixl internode read refused by peer"
);
return Err(io::Error::other("nixl internode read refused by peer"));
}
let landed = response_headers
.get(NIXL_BYTES_HEADER)
.and_then(|value| value.to_str().ok())
.and_then(|value| value.parse::<usize>().ok())
.ok_or_else(|| io::Error::other("nixl internode read reply lacks the byte count"))?;
if landed > request.length {
return Err(io::Error::other("nixl internode read reports more bytes than requested"));
}
Ok((request.length, buffer.complete(landed)?))
}
type ChunkFuture = BoxFuture<'static, io::Result<(usize, Bytes)>>;
struct ReaderState {
pool: Arc<dyn NixlRecvPool>,
base: ReadStreamRequest,
next: usize,
end: usize,
chunk: usize,
depth: usize,
timeout: Duration,
inflight: FuturesOrdered<ChunkFuture>,
current: Bytes,
done: bool,
}
impl ReaderState {
fn refill(&mut self) {
while !self.done && self.inflight.len() < self.depth && self.next < self.end {
let len = self.chunk.min(self.end - self.next);
let mut request = self.base.clone();
request.offset = self.next;
request.length = len;
self.next += len;
self.inflight
.push_back(Box::pin(fetch_chunk(Arc::clone(&self.pool), request, self.timeout)));
}
}
fn poll_chunk(&mut self, cx: &mut Context<'_>, max: usize) -> Poll<io::Result<Option<Bytes>>> {
loop {
if !self.current.is_empty() {
let take = self.current.len().min(max.max(1));
return Poll::Ready(Ok(Some(self.current.split_to(take))));
}
if self.done {
return Poll::Ready(Ok(None));
}
self.refill();
match Pin::new(&mut self.inflight).poll_next(cx) {
Poll::Ready(Some(Ok((asked, bytes)))) => {
if bytes.len() < asked {
// End of file: later chunks hold nothing; their buffers
// are held back as they are dropped.
self.done = true;
self.inflight = FuturesOrdered::new();
}
if bytes.is_empty() {
self.done = true;
return Poll::Ready(Ok(None));
}
self.current = bytes;
}
Poll::Ready(Some(Err(error))) => {
self.done = true;
self.inflight = FuturesOrdered::new();
return Poll::Ready(Err(error));
}
Poll::Ready(None) => {
self.done = true;
return Poll::Ready(Ok(None));
}
Poll::Pending => return Poll::Pending,
}
}
}
}
/// A remote shard stream read over NIXL in pipelined chunks.
pub struct NixlChunkReader {
// The mutex only makes the reader `Sync`; every access goes through `&mut self`.
state: std::sync::Mutex<ReaderState>,
}
impl NixlChunkReader {
fn new(pool: Arc<dyn NixlRecvPool>, request: ReadStreamRequest, depth: usize) -> Self {
let chunk = pool.chunk_bytes().max(1);
let timeout = request.stall_timeout.unwrap_or(DEFAULT_CHUNK_TIMEOUT);
Self {
state: std::sync::Mutex::new(ReaderState {
next: request.offset,
end: request.offset.saturating_add(request.length),
pool,
base: request,
chunk,
depth,
timeout,
inflight: FuturesOrdered::new(),
current: Bytes::new(),
done: false,
}),
}
}
fn state_mut(&mut self) -> &mut ReaderState {
self.state.get_mut().unwrap_or_else(|poisoned| poisoned.into_inner())
}
}
impl ChunkReader for NixlChunkReader {
fn poll_read_chunk(self: Pin<&mut Self>, cx: &mut Context<'_>, max: usize) -> Poll<io::Result<Option<Bytes>>> {
self.get_mut().state_mut().poll_chunk(cx, max)
}
}
impl AsyncRead for NixlChunkReader {
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<io::Result<()>> {
if buf.remaining() == 0 {
return Poll::Ready(Ok(()));
}
match self.get_mut().state_mut().poll_chunk(cx, buf.remaining()) {
Poll::Ready(Ok(Some(bytes))) => {
buf.put_slice(&bytes);
Poll::Ready(Ok(()))
}
Poll::Ready(Ok(None)) => Poll::Ready(Ok(())),
Poll::Ready(Err(error)) => Poll::Ready(Err(error)),
Poll::Pending => Poll::Pending,
}
}
}
/// Sends one segment of a shard write: the disk's node pulls `buffers` (in
/// file order) and writes them at the end of the file, creating it unless
/// `append`. The buffers return to the pool only after the node answered.
async fn send_segment(
pool: Arc<dyn NixlRecvPool>,
request: WriteStreamRequest,
buffers: Vec<(LentBuffer, usize)>,
append: bool,
last: bool,
timeout: Duration,
) -> io::Result<()> {
let total: usize = buffers.iter().map(|(_, len)| *len).sum();
let descriptors = buffers
.iter()
.map(|(buffer, len)| {
buffer
.buffer
.as_ref()
.map(|buffer| buffer.descriptor_for(*len))
.unwrap_or_default()
})
.collect::<Vec<_>>()
.join(",");
let url = format!(
"{}{WRITE_FILE_NIXL_PATH}?disk={}&volume={}&path={}&append={append}&size={}&last={last}&{NIXL_NONCE_QUERY}={}&{NIXL_AGENT_QUERY}={}&{NIXL_BUFFERS_QUERY}={}&{NIXL_METADATA_SHA256_QUERY}={}",
request.endpoint,
urlencoding::encode(&request.disk),
urlencoding::encode(&request.volume),
urlencoding::encode(&request.path),
request.size,
Uuid::new_v4(),
urlencoding::encode(pool.agent_name()),
urlencoding::encode(&descriptors),
pool.metadata_sha256_hex()
);
let mut headers = json_headers();
headers.insert(
NIXL_METADATA_HEADER,
HeaderValue::from_str(pool.metadata_base64())
.map_err(|_| io::Error::other("nixl agent metadata is not a header value"))?,
);
build_auth_headers(&url, &Method::PUT, &mut headers)?;
let request_started = rustfs_io_metrics::put_stage_timer();
let (status, response_headers, body) = rustfs_rio::internode_http_request(&url, Method::PUT, headers, Some(timeout)).await?;
rustfs_io_metrics::record_put_object_stage_duration_from("nixl_write_segment_request", request_started);
if !status.is_success() {
debug!(
component = LOG_COMPONENT_INTERNODE,
subsystem = LOG_SUBSYSTEM_NIXL,
result = "failed",
status = status.as_u16(),
body_len = body.len(),
"nixl internode write refused by peer"
);
return Err(io::Error::other("nixl internode write refused by peer"));
}
let written = response_headers
.get(NIXL_BYTES_HEADER)
.and_then(|value| value.to_str().ok())
.and_then(|value| value.parse::<usize>().ok());
if written != Some(total) {
debug!(
component = LOG_COMPONENT_INTERNODE,
subsystem = LOG_SUBSYSTEM_NIXL,
result = "failed",
written = ?written,
total,
"nixl internode write stored a different byte count"
);
return Err(io::Error::other("nixl internode write stored a different byte count"));
}
for (buffer, _) in buffers {
buffer.release();
}
Ok(())
}
type SegmentFuture = BoxFuture<'static, io::Result<()>>;
type ReserveFuture = BoxFuture<'static, io::Result<Box<dyn NixlRecvBuffer>>>;
struct WriterState {
pool: Arc<dyn NixlRecvPool>,
base: WriteStreamRequest,
timeout: Duration,
current: Option<(LentBuffer, usize)>,
filled: Vec<(LentBuffer, usize)>,
reserving: Option<ReserveFuture>,
sending: Option<SegmentFuture>,
segments_sent: usize,
shut_down: bool,
}
impl WriterState {
fn start_segment(&mut self, last: bool) {
let buffers = std::mem::take(&mut self.filled);
let append = self.base.append || self.segments_sent > 0;
self.segments_sent += 1;
self.sending = Some(Box::pin(send_segment(
Arc::clone(&self.pool),
self.base.clone(),
buffers,
append,
last,
self.timeout,
)));
}
fn poll_sending(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match self.sending.as_mut() {
None => Poll::Ready(Ok(())),
Some(sending) => match sending.as_mut().poll(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(result) => {
self.sending = None;
Poll::Ready(result)
}
},
}
}
fn poll_write(&mut self, cx: &mut Context<'_>, data: &[u8]) -> Poll<io::Result<usize>> {
if self.shut_down {
return Poll::Ready(Err(io::Error::other("nixl internode writer is shut down")));
}
if data.is_empty() {
return Poll::Ready(Ok(0));
}
if let Err(error) = futures::ready!(self.poll_sending(cx)) {
return Poll::Ready(Err(error));
}
while self.current.is_none() {
let pool = Arc::clone(&self.pool);
let reserving = self.reserving.get_or_insert_with(|| pool.reserve());
match reserving.as_mut().poll(cx) {
Poll::Ready(buffer) => {
self.reserving = None;
self.current = Some((LentBuffer { buffer: Some(buffer?) }, 0));
}
Poll::Pending if !self.filled.is_empty() => {
// Send held buffers before waiting for capacity that their acknowledgement releases.
self.reserving = None;
self.start_segment(false);
futures::ready!(self.poll_sending(cx))?;
}
Poll::Pending => return Poll::Pending,
}
}
let (lent, filled) = self.current.as_mut().expect("buffer reserved above");
let spare = lent.buffer.as_mut().expect("lent buffer present").spare_mut();
let n = data.len().min(spare.len() - *filled);
spare[*filled..*filled + n].copy_from_slice(&data[..n]);
*filled += n;
if *filled == spare.len() {
let full = self.current.take().expect("current buffer");
self.filled.push(full);
if self.filled.len() >= WRITE_SEGMENT_BUFFERS {
self.start_segment(false);
}
}
Poll::Ready(Ok(n))
}
fn poll_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
if !self.shut_down {
if let Err(error) = futures::ready!(self.poll_sending(cx)) {
return Poll::Ready(Err(error));
}
if let Some((buffer, filled)) = self.current.take() {
if filled > 0 {
self.filled.push((buffer, filled));
} else {
buffer.release();
}
}
self.shut_down = true;
if !self.filled.is_empty() || self.segments_sent == 0 {
// The last segment; with nothing written at all it still creates the file.
self.start_segment(true);
}
}
self.poll_sending(cx)
}
}
/// A remote shard file written through NIXL: bytes are staged in registered
/// buffers and the disk's node pulls them, a segment at a time.
pub struct NixlFileWriter {
// The mutex only makes the writer `Sync`; every access goes through `&mut self`.
state: std::sync::Mutex<WriterState>,
}
impl NixlFileWriter {
fn new(pool: Arc<dyn NixlRecvPool>, request: WriteStreamRequest) -> Self {
Self {
state: std::sync::Mutex::new(WriterState {
pool,
base: request,
timeout: DEFAULT_CHUNK_TIMEOUT,
current: None,
filled: Vec::new(),
reserving: None,
sending: None,
segments_sent: 0,
shut_down: false,
}),
}
}
fn state_mut(&mut self) -> &mut WriterState {
self.state.get_mut().unwrap_or_else(|poisoned| poisoned.into_inner())
}
}
impl tokio::io::AsyncWrite for NixlFileWriter {
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, data: &[u8]) -> Poll<io::Result<usize>> {
self.get_mut().state_mut().poll_write(cx, data)
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
// Bytes stay staged until a segment fills or the writer shuts down; a
// flush only waits for a segment already on its way.
self.get_mut().state_mut().poll_sending(cx)
}
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
self.get_mut().state_mut().poll_shutdown(cx)
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::sync::atomic::{AtomicUsize, Ordering};
struct CountingBuffer {
released: Arc<AtomicUsize>,
}
impl NixlRecvBuffer for CountingBuffer {
fn descriptor(&self) -> String {
"dram:0:0x1000:16".to_owned()
}
fn descriptor_for(&self, len: usize) -> String {
format!("dram:0:0x1000:{len}")
}
fn spare_mut(&mut self) -> &mut [u8] {
&mut []
}
fn into_bytes(self: Box<Self>, len: usize) -> io::Result<Bytes> {
Ok(Bytes::from(vec![7u8; len]))
}
}
impl Drop for CountingBuffer {
fn drop(&mut self) {
self.released.fetch_add(1, Ordering::SeqCst);
}
}
/// A buffer backed by a plain vector, for the writer's staging logic.
struct VecBuffer(Vec<u8>);
impl NixlRecvBuffer for VecBuffer {
fn descriptor(&self) -> String {
self.descriptor_for(self.0.len())
}
fn descriptor_for(&self, len: usize) -> String {
format!("dram:0:0x2000:{len}")
}
fn spare_mut(&mut self) -> &mut [u8] {
&mut self.0
}
fn into_bytes(self: Box<Self>, len: usize) -> io::Result<Bytes> {
Ok(Bytes::copy_from_slice(&self.0[..len]))
}
}
struct VecPool;
impl NixlRecvPool for VecPool {
fn agent_name(&self) -> &str {
"test-agent"
}
fn metadata_base64(&self) -> &str {
""
}
fn metadata_sha256_hex(&self) -> &str {
""
}
fn chunk_bytes(&self) -> usize {
8
}
fn reserve(&self) -> BoxFuture<'static, io::Result<Box<dyn NixlRecvBuffer>>> {
Box::pin(async { Ok(Box::new(VecBuffer(vec![0; 8])) as Box<dyn NixlRecvBuffer>) })
}
}
#[tokio::test]
async fn the_writer_stages_bytes_in_order_until_a_segment_fills() {
use tokio::io::AsyncWriteExt;
let request = WriteStreamRequest {
endpoint: "http://127.0.0.1:1".to_owned(),
disk: "disk".to_owned(),
volume: "volume".to_owned(),
path: "path".to_owned(),
append: false,
size: 20,
};
let mut writer = NixlFileWriter::new(Arc::new(VecPool), request);
let data: Vec<u8> = (0u8..20).collect();
writer
.write_all(&data)
.await
.expect("staging never sends below a full segment");
let state = writer.state_mut();
assert!(state.sending.is_none(), "two full 8-byte buffers stay below the four-buffer segment");
let staged: Vec<u8> = state
.filled
.iter_mut()
.chain(state.current.iter_mut())
.flat_map(|(lent, len)| lent.buffer.as_mut().expect("buffer").spare_mut()[..*len].to_vec())
.collect();
assert_eq!(staged, data);
assert_eq!(state.filled.len(), 2);
assert_eq!(state.current.as_ref().map(|(_, len)| *len), Some(4));
}
struct LimitedBuffer {
bytes: VecBuffer,
_permit: tokio::sync::OwnedSemaphorePermit,
}
impl NixlRecvBuffer for LimitedBuffer {
fn descriptor(&self) -> String {
self.bytes.descriptor()
}
fn descriptor_for(&self, len: usize) -> String {
self.bytes.descriptor_for(len)
}
fn spare_mut(&mut self) -> &mut [u8] {
self.bytes.spare_mut()
}
fn into_bytes(self: Box<Self>, len: usize) -> io::Result<Bytes> {
Ok(Bytes::copy_from_slice(&self.bytes.0[..len]))
}
}
struct LimitedPool(Arc<tokio::sync::Semaphore>);
impl NixlRecvPool for LimitedPool {
fn agent_name(&self) -> &str {
"test-agent"
}
fn metadata_base64(&self) -> &str {
""
}
fn metadata_sha256_hex(&self) -> &str {
""
}
fn chunk_bytes(&self) -> usize {
8
}
fn reserve(&self) -> ReserveFuture {
let permits = Arc::clone(&self.0);
Box::pin(async move {
let permit = permits.acquire_owned().await.map_err(io::Error::other)?;
Ok(Box::new(LimitedBuffer {
bytes: VecBuffer(vec![0; 8]),
_permit: permit,
}) as Box<dyn NixlRecvBuffer>)
})
}
}
#[tokio::test]
async fn the_writer_sends_staged_bytes_when_the_pool_is_full() {
use tokio::io::{AsyncReadExt, AsyncWriteExt};
crate::runtime::sources::ensure_test_rpc_secret();
for chunks in 1..=3 {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.expect("segment listener");
let address = listener.local_addr().expect("segment address");
let server = tokio::spawn(async move {
let mut received = 0;
while received < 40 {
let (mut socket, _) = listener.accept().await.expect("segment connection");
let mut request = Vec::new();
while !request.windows(4).any(|bytes| bytes == b"\r\n\r\n") {
let mut bytes = [0; 1024];
let n = socket.read(&mut bytes).await.expect("segment request");
assert!(n > 0 && request.len() < 16384, "bounded request headers");
request.extend_from_slice(&bytes[..n]);
}
let request = std::str::from_utf8(&request).expect("request text");
let target = request.split_whitespace().nth(1).expect("request target");
let url = url::Url::parse(&format!("http://{address}{target}")).expect("segment URL");
let descriptors = url
.query_pairs()
.find(|(name, _)| name == NIXL_BUFFERS_QUERY)
.expect("buffers")
.1;
let bytes: usize = descriptors
.split(',')
.map(|descriptor| {
descriptor
.rsplit(':')
.next()
.expect("buffer length")
.parse::<usize>()
.expect("numeric length")
})
.sum();
assert!(bytes > 0 && bytes <= chunks * 8);
received += bytes;
let response = format!(
"HTTP/1.1 200 OK\r\ncontent-length: 0\r\nconnection: close\r\nx-rustfs-nixl-bytes: {bytes}\r\n\r\n"
);
socket.write_all(response.as_bytes()).await.expect("segment acknowledgement");
}
received
});
let pool = Arc::new(LimitedPool(Arc::new(tokio::sync::Semaphore::new(chunks))));
let request = WriteStreamRequest {
endpoint: format!("http://{address}"),
disk: "disk".to_owned(),
volume: "volume".to_owned(),
path: "path".to_owned(),
append: false,
size: 40,
};
let mut writer = NixlFileWriter::new(pool.clone(), request);
let result = tokio::time::timeout(Duration::from_secs(5), async {
writer.write_all(&[7; 40]).await?;
writer.shutdown().await
})
.await;
if result.is_err() {
server.abort();
}
result
.expect("a writer must dispatch before exhausting its pool")
.expect("shard write");
assert_eq!(server.await.expect("segment server"), 40);
assert_eq!(pool.0.available_permits(), chunks, "acknowledged buffers return to the pool");
}
}
#[tokio::test(start_paused = true)]
async fn abandoned_buffers_return_only_after_the_hold() {
let released = Arc::new(AtomicUsize::new(0));
let lent = LentBuffer {
buffer: Some(Box::new(CountingBuffer {
released: Arc::clone(&released),
})),
};
drop(lent);
tokio::task::yield_now().await;
assert_eq!(released.load(Ordering::SeqCst), 0, "an abandoned buffer must not return at once");
tokio::time::sleep(ABANDONED_BUFFER_HOLD + Duration::from_secs(1)).await;
tokio::task::yield_now().await;
assert_eq!(released.load(Ordering::SeqCst), 1);
}
#[tokio::test]
async fn completed_buffers_return_with_their_bytes() {
let released = Arc::new(AtomicUsize::new(0));
let lent = LentBuffer {
buffer: Some(Box::new(CountingBuffer {
released: Arc::clone(&released),
})),
};
let bytes = lent.complete(5).expect("bytes");
assert_eq!(bytes.len(), 5);
assert_eq!(released.load(Ordering::SeqCst), 1);
}
}
@@ -97,7 +97,6 @@ const PEER_REST_RECOVERY_MAX_ATTEMPTS: u32 = 60;
const PEER_REST_RECOVERY_MAX_BACKOFF: Duration = Duration::from_secs(30);
const SCANNER_ACTIVITY_MAX_MESSAGE_SIZE: usize = 1024;
const SCANNER_SCOPED_DIRTY_USAGE_STAGE_TIMEOUT: Duration = Duration::from_secs(5);
const SCANNER_USAGE_WATCH_PEER_CONCURRENCY: usize = 4;
/// Reserve time for the acquire response's network/clock uncertainty. The
/// server owns the real expiry; this local deadline is intentionally earlier
/// so a coordinator never starts a bounded persistence operation at the edge
@@ -299,22 +298,6 @@ fn scanner_scoped_dirty_usage_ack_payload(
Ok(payload)
}
/// Authentication binds a response to the complete current request before any
/// returned watch can be consumed. Semantic validation still rejects a signed
/// response for the wrong producer session, bucket, or token.
fn validate_scanner_usage_watch_response(
request: &rustfs_protos::proto_gen::node_service::ScannerUsageWatchRequest,
response: &rustfs_protos::proto_gen::node_service::ScannerUsageWatchResponse,
) -> Result<()> {
use rustfs_protos::usage_watch::{
canonical_usage_watch_request, canonical_usage_watch_response, validate_usage_watch_response,
};
let canonical = canonical_usage_watch_request(request).map_err(|error| Error::other(error.to_string()))?;
let body = canonical_usage_watch_response(&canonical, response).map_err(|error| Error::other(error.to_string()))?;
verify_tonic_rpc_response_proof(&body, response.response_proof.as_ref())?;
validate_usage_watch_response(request, response).map_err(|error| Error::other(error.to_string()))
}
fn scanner_scoped_dirty_usage_ack_response_matches(
request: &ScannerScopedDirtyUsageAckRequest,
response: &ScannerScopedDirtyUsageAckResponse,
@@ -758,9 +741,6 @@ pub struct PeerRestClient {
topology_member: String,
offline: Arc<AtomicBool>,
recovery_running: Arc<AtomicBool>,
/// All clones used by admission, keepalive and root verification share
/// this peer's bounded sender capacity.
scanner_usage_watch_admission: Arc<tokio::sync::Semaphore>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -920,20 +900,9 @@ impl PeerRestClient {
topology_member,
offline: Arc::new(AtomicBool::new(false)),
recovery_running: Arc::new(AtomicBool::new(false)),
scanner_usage_watch_admission: Arc::new(tokio::sync::Semaphore::new(SCANNER_USAGE_WATCH_PEER_CONCURRENCY)),
}
}
async fn acquire_usage_watch_send_permit(&self) -> Result<tokio::sync::OwnedSemaphorePermit> {
timeout(
SCANNER_SCOPED_DIRTY_USAGE_STAGE_TIMEOUT,
self.scanner_usage_watch_admission.clone().acquire_owned(),
)
.await
.map_err(|_| Error::other("usage watch sender admission timed out"))?
.map_err(|_| Error::other("usage watch sender admission is closed"))
}
fn parse_topology_host(peer_host_port: &str, grid_host: &str) -> Result<XHost> {
let url = url::Url::parse(grid_host).map_err(|_| Error::other("peer grid host is not a valid URL"))?;
if !matches!(url.scheme(), "http" | "https")
@@ -1256,23 +1225,12 @@ impl PeerRestClient {
impl PeerRestClient {
pub async fn local_storage_info(&self) -> Result<rustfs_madmin::StorageInfo> {
self.local_storage_info_with_metrics(true).await
self.finalize_result(self.local_storage_info_inner().await).await
}
/// Collect fresh local inventory from this peer, optionally including disk metrics.
///
/// # Errors
/// Returns the existing transport, control-plane or inventory decoding error.
pub async fn local_storage_info_with_metrics(&self, include_metrics: bool) -> Result<rustfs_madmin::StorageInfo> {
self.finalize_result(self.local_storage_info_inner(include_metrics).await)
.await
}
async fn local_storage_info_inner(&self, include_metrics: bool) -> Result<rustfs_madmin::StorageInfo> {
async fn local_storage_info_inner(&self) -> Result<rustfs_madmin::StorageInfo> {
let mut client = self.get_client().await?;
let request = Request::new(LocalStorageInfoRequest {
metrics: include_metrics,
});
let request = Request::new(LocalStorageInfoRequest { metrics: true });
let response = client.local_storage_info(request).await?.into_inner();
if !response.success {
@@ -1681,51 +1639,6 @@ impl PeerRestClient {
Err(Error::NotImplemented)
}
/// Routes one authorized MRF operation without retrying ambiguous mutations.
/// `None` means the selected node predates this protocol; it is never an empty result.
pub async fn mrf_lifecycle(
&self,
topology: String,
node_id: String,
command: Vec<u8>,
timeout: std::time::Duration,
) -> Result<Option<Vec<u8>>> {
use rustfs_protos::proto_gen::node_service::MrfLifecycleRequest;
use rustfs_protos::{MRF_LIFECYCLE_MAX_COMMAND_BYTES, MRF_LIFECYCLE_MAX_MESSAGE_BYTES, MRF_LIFECYCLE_PROTOCOL_VERSION};
if command.len() > MRF_LIFECYCLE_MAX_COMMAND_BYTES {
return Err(Error::other("MRF command exceeds size limit"));
}
let payload = MrfLifecycleRequest {
protocol_version: MRF_LIFECYCLE_PROTOCOL_VERSION,
topology_fingerprint: topology,
node_id,
command: command.into(),
challenge: Uuid::new_v4().as_bytes().to_vec().into(),
};
let mut request = Request::new(payload.clone());
request.set_timeout(timeout);
set_tonic_mutation_body_digest(&mut request)?;
let mut client = self
.get_client()
.await?
.max_decoding_message_size(MRF_LIFECYCLE_MAX_MESSAGE_BYTES)
.max_encoding_message_size(MRF_LIFECYCLE_MAX_MESSAGE_BYTES);
let response = match client.mrf_lifecycle(request).await {
Ok(response) => response.into_inner(),
// RUSTFS_COMPAT_TODO(backlog-3177): old peers lack MRF management. Remove after every supported peer implements this RPC.
Err(status) if status.code() == tonic::Code::Unimplemented => return Ok(None),
Err(status) => return Err(status.into()),
};
let canonical = rustfs_protos::canonical_mrf_lifecycle_response_body(&payload, &response)
.map_err(|_| Error::other("MRF response is too large to authenticate"))?;
verify_tonic_rpc_response_proof(&canonical, &response.response_proof)
.map_err(|_| Error::other("MRF response authentication failed"))?;
if response.protocol_version != MRF_LIFECYCLE_PROTOCOL_VERSION {
return Err(Error::other("unsupported MRF response protocol"));
}
Ok(Some(response.result.to_vec()))
}
pub async fn background_heal_status(&self) -> Result<Option<Vec<u8>>> {
self.finalize_result(
async {
@@ -2525,129 +2438,6 @@ impl PeerRestClient {
.await
}
/// Independently negotiated bucket watches; an old peer returns an error
/// and callers retain the global-generation fallback for that bucket.
pub async fn scanner_usage_watch(
&self,
owner_id: Uuid,
mut entries: Vec<crate::runtime::usage_watch::ScannerUsageWatchRequest>,
) -> Result<Vec<crate::runtime::usage_watch::ScannerUsageWatchObservation>> {
use crate::runtime::usage_watch::{
SCANNER_USAGE_WATCH_COVERAGE_VERSION, SCANNER_USAGE_WATCH_LEASE_MS, ScannerUsageWatchKnown,
ScannerUsageWatchObservation,
};
use rustfs_protos::proto_gen::node_service::{ScannerUsageWatchEntry, ScannerUsageWatchRequest};
use rustfs_protos::usage_watch::*;
entries.sort_by(|left, right| left.bucket.cmp(&right.bucket));
if owner_id.is_nil() || entries.windows(2).any(|pair| pair[0].bucket == pair[1].bucket) {
return Err(Error::other("usage watch request contains duplicate buckets or an invalid owner"));
}
// Local queue pressure is not a network failure. Keep admission errors
// outside finalize_result so they cannot mark a healthy peer offline.
let _send_permit = self.acquire_usage_watch_send_permit().await?;
self.finalize_result(
async {
let mut client = super::client::scanner_control_time_out_client(
&self.grid_host,
TonicInterceptor::Signature(gen_tonic_signature_interceptor()),
)
.await?;
let mut observations = Vec::with_capacity(entries.len());
for batch in entries.chunks(USAGE_WATCH_MAX_ENTRIES) {
let payload = ScannerUsageWatchRequest {
challenge: Uuid::new_v4().as_bytes().to_vec().into(),
protocol_version: USAGE_WATCH_PROTOCOL_VERSION,
owner_id: owner_id.to_string(),
entries: batch
.iter()
.map(|entry| ScannerUsageWatchEntry {
bucket: entry.bucket.clone(),
bucket_incarnation: entry.bucket_incarnation.as_bytes().to_vec().into(),
watch_id: entry.watch_id.map_or_else(Bytes::new, |id| id.as_bytes().to_vec().into()),
release: entry.release,
session_id: entry.session_id.map_or_else(Bytes::new, |id| id.as_bytes().to_vec().into()),
})
.collect(),
};
let canonical = canonical_usage_watch_request(&payload).map_err(|error| Error::other(error.to_string()))?;
let mut request = Request::new(payload.clone());
set_tonic_canonical_body_digest(&mut request, &canonical)?;
let started = std::time::Instant::now();
let response = timeout(SCANNER_SCOPED_DIRTY_USAGE_STAGE_TIMEOUT, client.scanner_usage_watch(request))
.await
.map_err(|_| Error::other("usage watch request timed out"))??
.into_inner();
let budget_used = u64::try_from(started.elapsed().as_millis())
.unwrap_or(u64::MAX)
.saturating_add(250);
validate_scanner_usage_watch_response(&payload, &response)?;
let session = Uuid::from_slice(response.session_id.as_ref())
.map_err(|_| Error::other("invalid usage watch session"))?;
if response.protocol_version != USAGE_WATCH_PROTOCOL_VERSION
|| response.owner_id != payload.owner_id
|| session.is_nil()
|| response.entries.len() != payload.entries.len()
{
return Err(Error::other("usage watch response does not match request"));
}
for (requested, entry) in batch.iter().zip(response.entries) {
if entry.bucket != requested.bucket {
return Err(Error::other("usage watch response bucket order differs"));
}
let known = if entry.known {
let token = Uuid::from_slice(entry.watch_id.as_ref())
.map_err(|_| Error::other("invalid usage watch token"))?;
if token.is_nil()
|| entry.bucket_incarnation.as_ref() != requested.bucket_incarnation.as_bytes()
|| requested.watch_id.is_some_and(|expected| expected != token)
|| entry.revision == 0
|| entry.revision == u64::MAX
|| entry.inflight == u64::MAX
|| entry.coverage_version != SCANNER_USAGE_WATCH_COVERAGE_VERSION
|| entry.coverage_epoch == 0
|| entry.lease_remaining_ms == 0
|| entry.lease_remaining_ms > SCANNER_USAGE_WATCH_LEASE_MS
{
return Err(Error::other("usage watch response contains an invalid proof"));
}
let lease_remaining_ms = entry.lease_remaining_ms.saturating_sub(budget_used);
(lease_remaining_ms != 0).then_some(ScannerUsageWatchKnown {
owner_id,
session_id: session,
watch_id: token,
bucket_incarnation: requested.bucket_incarnation,
revision: entry.revision,
inflight: entry.inflight,
coverage_version: entry.coverage_version,
coverage_epoch: entry.coverage_epoch,
lease_remaining_ms,
})
} else {
if !entry.watch_id.is_empty()
|| !entry.bucket_incarnation.is_empty()
|| entry.revision != 0
|| entry.inflight != 0
|| entry.coverage_version != 0
|| entry.coverage_epoch != 0
|| entry.lease_remaining_ms != 0
{
return Err(Error::other("Unknown usage watch entry contains proof fields"));
}
None
};
observations.push(ScannerUsageWatchObservation {
bucket: entry.bucket,
known,
});
}
}
Ok(observations)
}
.await,
)
.await
}
pub async fn acknowledge_scanner_scoped_dirty_usage(
&self,
owner_id: String,
@@ -3482,74 +3272,6 @@ mod tests {
)
}
#[tokio::test]
async fn usage_watch_client_clones_share_receiver_sized_send_admission() {
let receiver = Arc::new(tokio::sync::Semaphore::new(4));
let occupied = (0..4)
.map(|_| receiver.clone().try_acquire_owned().expect("four receiver slots"))
.collect::<Vec<_>>();
assert!(receiver.try_acquire().is_err(), "an uncoordinated fifth request is rejected");
drop(occupied);
let client = test_peer_client();
let active = Arc::new(std::sync::atomic::AtomicUsize::new(0));
let peak = Arc::new(std::sync::atomic::AtomicUsize::new(0));
let tasks = (0..12).map(|_| {
// Simulate the shared client's independent admission, keeper and
// publication callers. Each uses the actual production gate.
let client = client.clone();
let receiver = receiver.clone();
let active = active.clone();
let peak = peak.clone();
tokio::spawn(async move {
let _send = client
.acquire_usage_watch_send_permit()
.await
.expect("bounded sender admission");
let _receive = receiver
.try_acquire_owned()
.expect("coexisting client clones must never send more than the receiver's four slots");
let count = active.fetch_add(1, Ordering::AcqRel) + 1;
peak.fetch_max(count, Ordering::AcqRel);
tokio::time::sleep(Duration::from_millis(10)).await;
active.fetch_sub(1, Ordering::AcqRel);
})
});
for result in futures::future::join_all(tasks).await {
result.expect("all queued callers finish");
}
assert_eq!(peak.load(Ordering::Acquire), 4);
assert_eq!(active.load(Ordering::Acquire), 0);
assert_eq!(client.scanner_usage_watch_admission.available_permits(), 4);
assert_eq!(receiver.available_permits(), 4);
}
#[tokio::test(start_paused = true)]
async fn usage_watch_sender_queue_timeout_does_not_mark_the_peer_offline() {
let client = test_peer_client();
let _occupied = client
.scanner_usage_watch_admission
.clone()
.acquire_many_owned(4)
.await
.unwrap();
let result = client
.scanner_usage_watch(
Uuid::from_u128(1),
vec![crate::runtime::usage_watch::ScannerUsageWatchRequest {
bucket: "bucket".into(),
bucket_incarnation: Uuid::from_u128(2),
watch_id: None,
session_id: None,
release: false,
}],
)
.await;
assert!(result.unwrap_err().to_string().contains("sender admission timed out"));
assert!(!client.offline.load(Ordering::Acquire));
assert!(!client.recovery_running.load(Ordering::Acquire));
}
fn decode_test_scanner_activity(response: ScannerActivityResponse) -> Result<ScannerPeerActivity> {
decode_scanner_activity_with_verifier(response, &[9; 16], |_canonical, proof| {
(proof == b"proof")
@@ -4625,112 +4347,6 @@ mod tests {
assert!(!client.offline.load(Ordering::Acquire));
}
#[test]
fn usage_watch_consumer_authenticates_the_current_request_and_rejects_replay() {
use rustfs_protos::proto_gen::node_service::{
ScannerUsageWatchEntry, ScannerUsageWatchRequest, ScannerUsageWatchResponse, ScannerUsageWatchResult,
};
use rustfs_protos::usage_watch::{canonical_usage_watch_request, canonical_usage_watch_response};
runtime_sources::ensure_test_rpc_secret();
let request = ScannerUsageWatchRequest {
challenge: Uuid::new_v4().as_bytes().to_vec().into(),
protocol_version: 1,
owner_id: Uuid::new_v4().to_string(),
entries: vec![ScannerUsageWatchEntry {
bucket: "usage-watch".into(),
bucket_incarnation: Uuid::new_v4().as_bytes().to_vec().into(),
watch_id: Uuid::new_v4().as_bytes().to_vec().into(),
session_id: Uuid::new_v4().as_bytes().to_vec().into(),
release: false,
}],
};
let sign = |request: &ScannerUsageWatchRequest, response: &mut ScannerUsageWatchResponse| {
let canonical = canonical_usage_watch_request(request).expect("valid request to sign");
let body = canonical_usage_watch_response(&canonical, response).expect("bounded canonical watch response");
response.response_proof = crate::cluster::rpc::sign_tonic_rpc_response_proof(&body)
.expect("real response HMAC")
.into();
};
let mut response = ScannerUsageWatchResponse {
protocol_version: 1,
owner_id: request.owner_id.clone(),
session_id: request.entries[0].session_id.clone(),
entries: vec![ScannerUsageWatchResult {
bucket: request.entries[0].bucket.clone(),
known: true,
bucket_incarnation: request.entries[0].bucket_incarnation.clone(),
watch_id: request.entries[0].watch_id.clone(),
revision: 7,
inflight: 0,
coverage_version: 1,
coverage_epoch: 3,
lease_remaining_ms: 60_000,
}],
response_proof: Bytes::new(),
};
sign(&request, &mut response);
validate_scanner_usage_watch_response(&request, &response).expect("current request accepts its signed response");
let mut rejected_replays = 0;
for field in 0..8 {
let mut current = request.clone();
match field {
0 => current.challenge = Uuid::new_v4().as_bytes().to_vec().into(),
1 => current.owner_id = Uuid::new_v4().to_string(),
2 => current.entries[0].bucket.push('x'),
3 => current.entries[0].bucket_incarnation = Uuid::new_v4().as_bytes().to_vec().into(),
4 => current.entries[0].watch_id = Uuid::new_v4().as_bytes().to_vec().into(),
5 => current.entries[0].session_id = Uuid::new_v4().as_bytes().to_vec().into(),
6 => current.entries[0].release = true,
_ => current.protocol_version += 1,
}
assert!(
validate_scanner_usage_watch_response(&current, &response).is_err(),
"a previously signed response must not authorize request mutation {field}"
);
rejected_replays += 1;
}
let mut tampered = response.clone();
tampered.entries[0].revision += 1;
assert!(validate_scanner_usage_watch_response(&request, &tampered).is_err());
let mut unsigned = response.clone();
unsigned.response_proof = Bytes::new();
assert!(validate_scanner_usage_watch_response(&request, &unsigned).is_err());
let mut rejected_signed_mismatches = 0;
for field in 0..5 {
let mut mismatched = response.clone();
match field {
0 => mismatched.owner_id = Uuid::new_v4().to_string(),
1 => mismatched.session_id = Uuid::new_v4().as_bytes().to_vec().into(),
2 => mismatched.entries[0].bucket_incarnation = Uuid::new_v4().as_bytes().to_vec().into(),
3 => mismatched.entries[0].watch_id = Uuid::new_v4().as_bytes().to_vec().into(),
_ => mismatched.entries[0].known = false,
}
sign(&request, &mut mismatched);
assert!(
validate_scanner_usage_watch_response(&request, &mismatched).is_err(),
"an authentic HMAC cannot replace requested watch identity or authorize malformed Unknown: {field}"
);
rejected_signed_mismatches += 1;
}
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-12", "assertion_id": "USAGE-12-A07", "status": "PASS",
"evidence": {"current_response_authenticated": true, "replayed_requests_rejected": rejected_replays,
"signed_identity_mismatches_rejected": rejected_signed_mismatches,
"tampered_response_rejected": true, "missing_hmac_rejected": true}
})
);
drop((request, response, tampered, unsigned));
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-12", "status": "PASS", "scope": "process-local"})
);
}
#[test]
fn heal_control_capability_proof_must_authenticate_exact_ack() {
runtime_sources::ensure_test_rpc_secret();
File diff suppressed because it is too large Load Diff
@@ -29,7 +29,7 @@ use rustfs_protos::proto_gen::node_service::{
LockAcquireStatus, LockReleaseStatus, PingRequest,
};
use rustfs_protos::{
ChannelRebuildReason, ConnectionEvictionLogLevel, evict_failed_connection_with_reason, models::PingBodyBuilder,
ConnectionEvictionLogLevel, evict_failed_connection_with_log_level, models::PingBodyBuilder,
proto_gen::node_service::node_service_client::NodeServiceClient,
};
use std::collections::HashMap;
@@ -498,7 +498,7 @@ impl RemoteClient {
))
}
async fn evict_connection(&self, op: &'static str, reason: &str, resource_summary: &str, trigger: EvictionTrigger) {
async fn evict_connection(&self, op: &'static str, reason: &str, resource_summary: &str) {
let log_level = if Self::is_scanner_leader_lock(resource_summary) {
debug!(
addr = %self.addr,
@@ -518,11 +518,7 @@ impl RemoteClient {
);
ConnectionEvictionLogLevel::Warn
};
let rebuild_reason = match trigger {
EvictionTrigger::Timeout => ChannelRebuildReason::LockTimeout,
EvictionTrigger::Transport => ChannelRebuildReason::LockTransport,
};
evict_failed_connection_with_reason(&self.addr, rebuild_reason, log_level).await;
evict_failed_connection_with_log_level(&self.addr, log_level).await;
}
fn summarize_resources(requests: &[LockRequest]) -> String {
@@ -776,7 +772,7 @@ impl RemoteClient {
});
if verdict == EvictionVerdict::Evict {
rustfs_io_metrics::lock_metrics::record_remote_lock_channel_eviction(&self.addr, trigger.as_str());
self.evict_connection(op, reason, resource_summary, trigger).await;
self.evict_connection(op, reason, resource_summary).await;
return;
}
rustfs_io_metrics::lock_metrics::record_remote_lock_channel_eviction_suppressed(&self.addr, verdict.as_str());
-10
View File
@@ -314,16 +314,6 @@ mod tests {
assert_eq!(scanner_kvs.get(SCANNER_DELAY), "");
assert_eq!(scanner_kvs.get(SCANNER_MAX_WAIT), "");
assert_eq!(scanner_kvs.get(SCANNER_CYCLE_MAX_OBJECTS), "0");
for key in [
rustfs_config::SCANNER_BUCKET_QUANTUM_DURATION,
rustfs_config::SCANNER_BUCKET_QUANTUM_OBJECTS,
rustfs_config::SCANNER_BUCKET_QUANTUM_DIRECTORIES,
rustfs_config::SCANNER_BUCKET_QUANTUM_ENTRIES,
rustfs_config::SCANNER_BUCKET_QUANTUM_NAME_BYTES,
] {
assert!(rustfs_config::SCANNER_KEYS.contains(&key), "admin key {key} is registered");
assert_eq!(scanner_kvs.get(key), "0", "quantum dimension {key} stays disabled until rollout");
}
let heal_kvs = cfg
.get_value(HEAL_SUB_SYS, DEFAULT_DELIMITER)
-31
View File
@@ -25,12 +25,6 @@ use rustfs_config::{
SCANNER_MAX_CONCURRENT_SET_SCANS, SCANNER_MAX_WAIT, SCANNER_RECOVERY_BACKOFF_CAP, SCANNER_SPEED, SCANNER_START_DELAY,
SCANNER_WALKERS_PER_DISK, SCANNER_YIELD_EVERY_N_OBJECTS,
};
use rustfs_config::{
DEFAULT_SCANNER_BUCKET_QUANTUM_DIRECTORIES, DEFAULT_SCANNER_BUCKET_QUANTUM_DURATION_SECS,
DEFAULT_SCANNER_BUCKET_QUANTUM_ENTRIES, DEFAULT_SCANNER_BUCKET_QUANTUM_NAME_BYTES, DEFAULT_SCANNER_BUCKET_QUANTUM_OBJECTS,
SCANNER_BUCKET_QUANTUM_DIRECTORIES, SCANNER_BUCKET_QUANTUM_DURATION, SCANNER_BUCKET_QUANTUM_ENTRIES,
SCANNER_BUCKET_QUANTUM_NAME_BYTES, SCANNER_BUCKET_QUANTUM_OBJECTS,
};
use std::sync::LazyLock;
pub static DEFAULT_KVS: LazyLock<KVS> = LazyLock::new(|| {
@@ -75,31 +69,6 @@ pub static DEFAULT_KVS: LazyLock<KVS> = LazyLock::new(|| {
value: DEFAULT_SCANNER_CYCLE_MAX_DIRECTORIES.to_string(),
hidden_if_empty: false,
},
KV {
key: SCANNER_BUCKET_QUANTUM_DURATION.to_owned(),
value: DEFAULT_SCANNER_BUCKET_QUANTUM_DURATION_SECS.to_string(),
hidden_if_empty: false,
},
KV {
key: SCANNER_BUCKET_QUANTUM_OBJECTS.to_owned(),
value: DEFAULT_SCANNER_BUCKET_QUANTUM_OBJECTS.to_string(),
hidden_if_empty: false,
},
KV {
key: SCANNER_BUCKET_QUANTUM_DIRECTORIES.to_owned(),
value: DEFAULT_SCANNER_BUCKET_QUANTUM_DIRECTORIES.to_string(),
hidden_if_empty: false,
},
KV {
key: SCANNER_BUCKET_QUANTUM_ENTRIES.to_owned(),
value: DEFAULT_SCANNER_BUCKET_QUANTUM_ENTRIES.to_string(),
hidden_if_empty: false,
},
KV {
key: SCANNER_BUCKET_QUANTUM_NAME_BYTES.to_owned(),
value: DEFAULT_SCANNER_BUCKET_QUANTUM_NAME_BYTES.to_string(),
hidden_if_empty: false,
},
KV {
key: SCANNER_BITROT_CYCLE.to_owned(),
value: DEFAULT_SCANNER_BITROT_CYCLE_SECS.to_string(),
+7 -37
View File
@@ -6400,7 +6400,7 @@ pub(crate) struct PoolMetaWriteState {
pool_meta_absent: bool,
bootstrap_authority: PoolMetaBootstrapAuthority,
/// First-hand bootstrap authority this process holds for each pool
/// (index = pool index): `Fresh` for pools it formatted or resumed from a complete durable plan,
/// (index = pool index): `Fresh` only for pools it formatted itself,
/// `LegacyAdoption` only for pools whose migration it verified. Empty when
/// the caller tracks deployment-wide authority only.
pool_bootstrap_authorities: Vec<PoolMetaBootstrapAuthority>,
@@ -6478,7 +6478,8 @@ impl PoolMetaWriteState {
}
/// Startup state for a process that loaded every pool format itself and
/// remembers, per pool, whether it created, durably resumed, or adopted that pool. Deployment-wide authority is the conjunction across pools:
/// remembers, per pool, whether it created (or adopted) that pool
/// first-hand. Deployment-wide authority is the conjunction across pools:
/// any pool this process merely read yields `None`, exactly as before.
pub(crate) fn for_startup_with_pool_bootstrap_authorities(
cluster_id: uuid::Uuid,
@@ -6509,7 +6510,7 @@ impl PoolMetaWriteState {
.is_some_and(|authority| authority.is_proven())
}
/// Pools this process formatted, durably resumed, or adopted during startup.
/// Pools this process formatted or adopted first-hand during this startup.
pub(crate) fn attested_pool_indices(&self) -> Vec<usize> {
self.pool_bootstrap_authorities
.iter()
@@ -6526,7 +6527,7 @@ impl PoolMetaWriteState {
/// [`PoolMetaIdentityWriteScope::Pools`]), so a complete, agreeing pending
/// set proves that every pool joined this bootstrap fresh. A missing,
/// corrupt, or disagreeing replica keeps the writer fail-closed, and a
/// restart requires a complete durable format plan to recover creator proof.
/// restart without first-hand proof never reopens bootstrap on its own.
fn pending_identity_attested_by_every_pool(&self) -> bool {
self.elected_bootstrap_writer == Some(true)
&& self.pool_bootstrap_authority_proven(0)
@@ -6758,27 +6759,6 @@ impl PoolMetaWriteState {
self.expected_cluster_id.is_some() && (self.identity_needs_repair || self.identity_initialized != Some(true))
}
/// A committed predecessor authorizes repairing an established identity
/// before the next metadata write. A pending fresh identity must remain
/// pending until its initial metadata commit is recoverable.
pub(crate) fn startup_identity_precedes_metadata_write(&self) -> bool {
!self.pool_meta_absent && !self.identity_is_pending()
}
pub(crate) fn ensure_startup_identity_initialized(&self) -> Result<()> {
if self.expected_cluster_id.is_none()
|| (self.identity_initialized == Some(true)
&& !self.identity_needs_repair
&& !self.identity_replicas_missing
&& !self.identity_replicas_invalid)
{
return Ok(());
}
Err(Error::other(
"pool metadata bootstrap pending: waiting for the elected writer to initialize the identity on every pool",
))
}
pub(crate) fn ensure_write_safe(&self, operation: &str) -> Result<()> {
let (Some(mut context), _) = self.write_block() else {
return Ok(());
@@ -10166,8 +10146,6 @@ impl PoolMeta {
self.save_for_startup_observing(pools, &mut write_state).await.map(|_| ())
}
/// Commits a complete startup snapshot while leaving identity finalization
/// to the caller, after durable format-bootstrap authority is retired.
pub(crate) async fn save_for_startup_observing<S>(
&self,
pools: Vec<Arc<S>>,
@@ -10182,8 +10160,6 @@ impl PoolMeta {
Ok(outcome.into_committed())
}
/// Commits a complete startup snapshot under the writer fence. The caller
/// retires format-bootstrap authority before finalizing initialized identity.
pub(crate) async fn save_for_startup_guarded<S>(
&self,
pools: Vec<Arc<S>>,
@@ -10386,10 +10362,7 @@ impl PoolMeta {
selection.revision.epoch, identity.epoch
)));
}
// Full-snapshot saves belong to startup. Their caller retires
// durable format authority before publishing initialized identity.
// Runtime scoped saves retain their existing identity repair.
if indices.is_some() && !selection.absent && write_state.identity_requires_repair() {
if !selection.absent && write_state.identity_requires_repair() {
let initialized = write_state.identity_initialized != Some(false) || selection.revision.is_generation_protocol();
persist_pool_meta_identity(
pools.clone(),
@@ -10667,10 +10640,7 @@ impl PoolMeta {
confirmed
};
if confirmed.revision == revision && confirmed.canonical.as_ref() == Some(&durable) {
if indices.is_some() {
persist_pool_meta_identity(pools, write_state, true, PoolMetaIdentityWriteScope::All, fence, transaction_arm)
.await?;
}
persist_pool_meta_identity(pools, write_state, true, PoolMetaIdentityWriteScope::All, fence, transaction_arm).await?;
#[cfg(feature = "e2e-test-hooks")]
startup_cas_test_observe(serde_json::json!({
"kind": "confirmed", "object": POOL_META_NAME,
+3 -3
View File
@@ -477,18 +477,18 @@ impl Sets {
}
}
pub(crate) async fn local_storage_info_snapshot(&self, include_metrics: bool) -> rustfs_madmin::StorageInfo {
pub(crate) async fn local_storage_info_snapshot(&self) -> rustfs_madmin::StorageInfo {
let mut futures = Vec::with_capacity(self.disk_set.len());
for set in self.disk_set.iter() {
futures.push(set.local_storage_info_snapshot(include_metrics))
futures.push(set.local_storage_info_snapshot())
}
let results = join_all(futures).await;
let mut disks = Vec::new();
for res in results.into_iter() {
disks.extend(res.disks);
disks.extend_from_slice(&res.disks);
}
rustfs_madmin::StorageInfo {
+8 -74
View File
@@ -56,8 +56,6 @@ pub const DATA_USAGE_ROOT: &str = SLASH_SEPARATOR;
const DATA_COMPRESSION_TOTAL_NAME: &str = ".compression.json";
pub const DATA_USAGE_CACHE_NAME: &str = ".usage-cache.bin";
const DATA_USAGE_CACHE_TTL_SECS: u64 = 30;
const ADMIN_USAGE_INCARNATION_CONCURRENCY: usize = 4;
const ADMIN_USAGE_INCARNATION_TIMEOUT: Duration = Duration::from_secs(2);
// A scanner save invalidates only the saving process's snapshot cache; every
// other node sees it only after reloading. A fail-closed usage lookup for a
// bucket the cached snapshot does not mention at all may reload a copy this
@@ -507,7 +505,6 @@ fn stale_data_usage_persist_reason_for_source(
/// Store data usage info to backend storage
#[instrument(skip(store))]
pub async fn store_data_usage_in_backend(data_usage_info: DataUsageInfo, store: Arc<ECStore>) -> Result<(), Error> {
reject_admin_usage_projection(&data_usage_info)?;
if data_usage_info.usage_snapshot_converged == Some(false) {
return Err(Error::other(
"nonconverged data usage observations cannot replace the quota-authoritative snapshot",
@@ -537,7 +534,6 @@ async fn save_data_usage_in_backend(
store: Arc<ECStore>,
expected_publication_epoch: u64,
) -> Result<(), Error> {
reject_admin_usage_projection(&data_usage_info)?;
let data =
serde_json::to_vec(&data_usage_info).map_err(|e| Error::other(format!("Failed to serialize data usage info: {e}")))?;
@@ -667,9 +663,8 @@ fn remove_bucket_usage_from_info(data_usage_info: &mut DataUsageInfo, bucket: &s
let removed_usage = data_usage_info.buckets_usage.remove(bucket).is_some();
let removed_size = data_usage_info.bucket_sizes.remove(bucket).is_some();
let removed_observation = data_usage_info.usage_snapshot_bucket_observations.remove(bucket).is_some();
if !removed_usage && !removed_size && !removed_observation {
if !removed_usage && !removed_size {
return false;
}
@@ -821,9 +816,7 @@ fn map_data_usage_metadata_read_error(err: Error, object: &str) -> Error {
}
fn data_usage_contains_bucket(data_usage_info: &DataUsageInfo, bucket: &str) -> bool {
data_usage_info.buckets_usage.contains_key(bucket)
|| data_usage_info.bucket_sizes.contains_key(bucket)
|| data_usage_info.usage_snapshot_bucket_observations.contains_key(bucket)
data_usage_info.buckets_usage.contains_key(bucket) || data_usage_info.bucket_sizes.contains_key(bucket)
}
fn advance_data_usage_last_update(data_usage_info: &mut DataUsageInfo) {
@@ -1144,26 +1137,14 @@ fn record_usage_snapshot_decode_failure(operation: &'static str, object: &str, e
}
fn parse_usage_snapshot(buf: &[u8]) -> Result<DataUsageInfo, Error> {
let mut info: DataUsageInfo = serde_json::from_slice(buf).map_err(|e| {
serde_json::from_slice(buf).map_err(|e| {
Error::other(format!(
"Failed to deserialize data usage info: {:?} at line {} column {}",
e.classify(),
e.line(),
e.column()
))
})?;
reject_admin_usage_projection(&info)?;
for usage in info.buckets_usage.values_mut() {
usage.normalize_usage_provenance();
}
Ok(info)
}
fn reject_admin_usage_projection(info: &DataUsageInfo) -> Result<(), Error> {
if info.usage_snapshot_admin_projection {
return Err(Error::other("admin usage projections cannot be persisted or used as a storage baseline"));
}
Ok(())
})
}
/// Decide which usage snapshot to serve: a primary usage object or its
@@ -1346,9 +1327,6 @@ async fn load_data_usage_from_backend_with_baseline(store: Arc<ECStore>) -> Resu
/// Fill quota-baseline gaps from an observed (nonconverged) snapshot without
/// overriding any bucket the authoritative baseline already covers.
fn backfill_degraded_baseline_from_observed(degraded_baseline: &mut HashMap<String, u64>, observed: &DataUsageInfo) {
if observed.usage_snapshot_admin_projection {
return;
}
for (bucket, usage) in &observed.buckets_usage {
degraded_baseline.entry(bucket.clone()).or_insert(usage.size);
}
@@ -1441,7 +1419,6 @@ fn merge_partial_observation_for_admin(mut authoritative: DataUsageInfo, observe
authoritative.usage_snapshot_converged = Some(false);
authoritative.usage_snapshot_authoritative_baseline = observed.usage_snapshot_authoritative_baseline;
authoritative.usage_snapshot_set_states = observed.usage_snapshot_set_states;
authoritative.usage_snapshot_bucket_observations = observed.usage_snapshot_bucket_observations;
authoritative.usage_snapshot_bootstrap_pending = false;
authoritative.buckets_count = authoritative.buckets_usage.len() as u64;
authoritative.bucket_sizes = authoritative
@@ -1460,48 +1437,10 @@ async fn load_admin_data_usage_from_backend(store: Arc<ECStore>) -> Result<DataU
let (authoritative, source) = load_data_usage_snapshot(store.clone()).await?;
// For the one-shot admin view a failed observed read degrades to "no
// observation", same as before the read was fallible.
let observed = load_observed_data_usage_snapshot(store.clone()).await.ok().flatten();
let observed = load_observed_data_usage_snapshot(store).await.ok().flatten();
let (selected, selected_is_current_format) =
select_admin_data_usage_snapshot(authoritative, source.is_authoritative(), observed);
let mut response = normalize_loaded_data_usage(selected, selected_is_current_format).await.0;
use futures::StreamExt as _;
let deadline = tokio::time::Instant::now() + ADMIN_USAGE_INCARNATION_TIMEOUT;
let mut incarnations = HashMap::new();
{
// Display-only identity reads must not serialize every bucket behind a
// slow metadata lock while holding the shared admin refresh permit.
// The common deadline bounds their total added latency; dropping this
// stream cancels all unfinished reads without spawning detached work.
// Own the names and store across awaits so this future remains Send
// when composed into spawned metrics collectors.
let buckets = response
.usage_snapshot_bucket_observations
.keys()
.cloned()
.collect::<Vec<_>>();
let mut identities = futures::stream::iter(buckets)
.map(move |bucket| {
let store = store.clone();
async move {
let identity = store.bucket_incarnation_id_from_disk(&bucket).await;
(bucket, identity)
}
})
.buffer_unordered(ADMIN_USAGE_INCARNATION_CONCURRENCY);
while tokio::time::Instant::now() < deadline {
let Ok(Some((bucket, identity))) = tokio::time::timeout_at(deadline, identities.next()).await else {
break;
};
// Unavailable, timed-out or recreated buckets retain canonical values.
if let Ok(incarnation) = identity
&& !incarnation.is_nil()
{
incarnations.insert(bucket, incarnation.to_string());
}
}
}
response.project_bucket_observations_for_admin(&incarnations);
Ok(response)
Ok(normalize_loaded_data_usage(selected, selected_is_current_format).await.0)
}
fn discard_incomplete_bucket_usage(data_usage_info: &mut DataUsageInfo) {
@@ -2143,9 +2082,7 @@ where
fn apply_live_bucket_usage_to_response(data_usage_info: &mut DataUsageInfo, bucket: &str, usage: &BucketUsageInfo) {
let inserted_bucket = !data_usage_info.buckets_usage.contains_key(bucket);
data_usage_info.bucket_sizes.insert(bucket.to_string(), usage.size);
let mut observed = usage.clone();
observed.mark_observed();
data_usage_info.buckets_usage.insert(bucket.to_string(), observed);
data_usage_info.buckets_usage.insert(bucket.to_string(), usage.clone());
if inserted_bucket {
data_usage_info.usage_snapshot_complete = false;
}
@@ -2837,9 +2774,7 @@ async fn apply_bucket_usage_memory_overlay_if_authoritative(data_usage_info: &mu
}
added_bucket |= !data_usage_info.buckets_usage.contains_key(bucket);
let mut observed = cached.usage.clone();
observed.mark_observed();
data_usage_info.buckets_usage.insert(bucket.clone(), observed);
data_usage_info.buckets_usage.insert(bucket.clone(), cached.usage.clone());
data_usage_info.bucket_sizes.insert(bucket.clone(), cached.usage.size);
changed = true;
}
@@ -3089,7 +3024,6 @@ pub async fn init_compression_total_memory_from_backend(store: Arc<ECStore>) {
#[cfg(test)]
mod tests {
mod companion_projection;
mod snapshot_projection;
use super::*;
@@ -1,310 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
use super::*;
use rustfs_data_usage::{
BucketUsageCertification, BucketUsageValueState, DATA_USAGE_BUCKET_OBSERVATION_VERSION, DataUsageBucketObservation,
DataUsageBucketObservationSource, DataUsageSnapshotSetState,
};
mod native_compatibility;
fn companion_snapshot(bucket: &str, incarnation: uuid::Uuid) -> DataUsageInfo {
let completed_at = SystemTime::UNIX_EPOCH + Duration::from_secs(40);
let mut snapshot = data_usage_info_for_test(bucket, 10, 100, completed_at + Duration::from_secs(10));
snapshot.scanner_epoch = Some(2);
snapshot.scanner_cycle = Some(9);
snapshot.usage_snapshot_converged = Some(false);
snapshot.usage_snapshot_pending_buckets = vec![bucket.to_string()];
snapshot.usage_snapshot_pending_bucket_count = 1;
let canonical = snapshot.buckets_usage.get_mut(bucket).expect("canonical bucket");
canonical.bucket_incarnation = Some(incarnation.to_string());
canonical.certify(BucketUsageCertification {
epoch: 2,
cycle: 3,
certified_at: SystemTime::UNIX_EPOCH + Duration::from_secs(30),
});
canonical.mark_carried();
snapshot.usage_snapshot_set_states = vec![DataUsageSnapshotSetState {
pool_index: 0,
set_index: 0,
scanner_epoch: Some(2),
scanner_cycle: Some(9),
scan_plan_digest: Some([1; 32]),
complete: true,
..Default::default()
}];
let mut observed = BucketUsageInfo {
size: 250,
objects_count: 25,
versions_count: 25,
bucket_incarnation: Some(incarnation.to_string()),
..Default::default()
};
observed.mark_observed();
snapshot.usage_snapshot_bucket_observations.insert(
bucket.to_string(),
DataUsageBucketObservation {
version: DATA_USAGE_BUCKET_OBSERVATION_VERSION,
usage: observed,
snapshot_identity: snapshot.snapshot_identity(),
completed_at,
sources: vec![DataUsageBucketObservationSource {
pool_index: 0,
set_index: 0,
bucket_incarnation: incarnation.to_string(),
scanner_epoch: 2,
scanner_cycle: 4,
scan_plan_digest: [1; 32],
started_plan: [2; 32],
requested_plan: [3; 32],
completed_at,
}],
},
);
snapshot
}
#[test]
fn companion_cannot_backfill_quota_and_projection_is_rejected_at_storage_boundaries() {
let incarnation = uuid::Uuid::from_u128(31);
let mut snapshot = companion_snapshot("bucket", incarnation);
let mut canonical_quota = HashMap::new();
backfill_degraded_baseline_from_observed(&mut canonical_quota, &snapshot);
assert_eq!(canonical_quota.get("bucket"), Some(&100), "quota reads only the unchanged main map");
assert_eq!(
snapshot.project_bucket_observations_for_admin(&HashMap::from([("bucket".to_string(), incarnation.to_string())])),
1
);
let mut accidental_quota = HashMap::new();
backfill_degraded_baseline_from_observed(&mut accidental_quota, &snapshot);
assert!(accidental_quota.is_empty());
assert!(reject_admin_usage_projection(&snapshot).is_err());
assert!(certified_bucket_usage(&snapshot, "bucket", incarnation).is_none());
let wire = serde_json::to_vec(&snapshot).expect("admin response remains serializable");
assert!(parse_usage_snapshot(&wire).is_err(), "a serialized response is not a persisted snapshot");
}
#[test]
fn companion_only_observed_snapshot_does_not_create_a_legacy_quota_baseline() {
let incarnation = uuid::Uuid::from_u128(31);
let mut snapshot = companion_snapshot("bucket", incarnation);
snapshot.buckets_usage.clear();
snapshot.bucket_sizes.clear();
snapshot.buckets_count = 0;
snapshot.calculate_totals();
snapshot.usage_snapshot_complete = false;
snapshot.usage_snapshot_partial = true;
snapshot.usage_snapshot_observational = true;
snapshot.usage_snapshot_set_states[0].complete = false;
let decoded = parse_usage_snapshot(&serde_json::to_vec(&snapshot).expect("encode companion-only snapshot"))
.expect("read valid partial snapshot");
assert!(decoded.is_valid_partial_snapshot());
let mut baseline = HashMap::new();
backfill_degraded_baseline_from_observed(&mut baseline, &decoded);
assert!(baseline.is_empty(), "unknown usage must not become either zero or mixed quota usage");
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-08", "assertion_id": "USAGE-08-A02", "status": "PASS",
"evidence": {"primary_buckets": decoded.buckets_usage.len(), "legacy_bucket_sizes": decoded.bucket_sizes.len(), "quota_baseline_buckets": baseline.len(), "companion_buckets": decoded.usage_snapshot_bucket_observations.len(), "partial": decoded.is_valid_partial_snapshot()}
})
);
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-08", "status": "PASS", "scope": "process-local"})
);
}
#[test]
fn bucket_removal_discards_companions_even_without_a_canonical_entry() {
let mut snapshot = companion_snapshot("bucket", uuid::Uuid::from_u128(31));
snapshot.buckets_usage.clear();
snapshot.bucket_sizes.clear();
assert!(data_usage_contains_bucket(&snapshot, "bucket"));
assert!(remove_bucket_usage_from_info(&mut snapshot, "bucket"));
assert!(!data_usage_contains_bucket(&snapshot, "bucket"));
assert!(snapshot.usage_snapshot_bucket_observations.is_empty());
}
#[test]
fn partial_selection_replaces_value_provenance_together() {
let incarnation = uuid::Uuid::from_u128(31);
let authoritative = companion_snapshot("bucket", incarnation);
let mut observed = authoritative.clone();
observed.usage_snapshot_authoritative_baseline = Some(authoritative.snapshot_identity());
observed.scanner_cycle = Some(10);
observed.last_update = Some(SystemTime::UNIX_EPOCH + Duration::from_secs(60));
observed.usage_snapshot_complete = false;
observed.usage_snapshot_partial = true;
observed.usage_snapshot_observational = true;
observed.usage_snapshot_bucket_observations.clear();
let usage = observed.buckets_usage.get_mut("bucket").expect("observed main bucket");
usage.size = 175;
usage.mark_observed();
let (selected, _) = select_admin_data_usage_snapshot(authoritative, true, Some(observed));
assert_eq!(selected.buckets_usage["bucket"].size, 175);
assert_eq!(selected.buckets_usage["bucket"].usage_value_state, Some(BucketUsageValueState::Observed));
assert_eq!(selected.buckets_usage["bucket"].usage_certification, None);
assert!(
selected.usage_snapshot_bucket_observations.is_empty(),
"old root companions cannot cross a baseline change"
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[serial]
async fn companion_admin_cache_isolated_from_quota_memory_and_persistence() {
use crate::bucket::metadata_sys::{init_bucket_metadata_sys, test_support::isolated_store_over_temp_disks};
use crate::config::com::save_config;
use crate::storage_api_contracts::bucket::MakeBucketOptions;
let (_dirs, store) = isolated_store_over_temp_disks().await;
init_bucket_metadata_sys(store.clone(), Vec::new()).await;
let bucket = "usage-companion";
store
.make_bucket(bucket, &MakeBucketOptions::default())
.await
.expect("create bucket for incarnation validation");
let incarnation = store
.bucket_incarnation_id_from_disk(bucket)
.await
.expect("trusted incarnation");
let canonical = companion_snapshot(bucket, incarnation);
let bytes = serde_json::to_vec(&canonical).expect("encode canonical root with companion");
save_config(store.clone(), DATA_USAGE_OBJ_NAME_PATH.as_str(), bytes.clone())
.await
.expect("save canonical root");
clear_usage_memory_cache_for_test().await;
invalidate_data_usage_snapshot_cache().await;
let mut samples = Vec::new();
let mut rejected_writes = 0;
for _ in 0..2 {
let response = load_admin_data_usage_from_backend_cached(store.clone())
.await
.expect("read admin cache");
assert_eq!(response.buckets_usage[bucket].size, 250);
assert!(response.usage_snapshot_admin_projection);
replace_bucket_usage_memory_from_info(&response).await;
assert!(memory_cache().read().await.is_empty(), "response cannot seed quota memory");
let admin_bytes = response.buckets_usage[bucket].size;
let rejected = store_data_usage_in_backend(response, store.clone()).await.is_err();
assert!(rejected);
rejected_writes += usize::from(rejected);
let quota = load_data_usage_from_backend_cached(store.clone())
.await
.expect("read independent quota cache");
assert_eq!(quota.buckets_usage[bucket].size, 100);
assert!(!quota.usage_snapshot_admin_projection);
samples.push((admin_bytes, quota.buckets_usage[bucket].size));
invalidate_data_usage_snapshot_cache().await;
}
let persisted = read_config(store, DATA_USAGE_OBJ_NAME_PATH.as_str())
.await
.expect("read unchanged canonical root");
assert_eq!(persisted, bytes);
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-18", "assertion_id": "USAGE-18-A03", "status": "PASS",
"evidence": {"admin_and_quota_byte_samples": samples, "rejected_projected_writes": rejected_writes, "quota_memory_entries": memory_cache().read().await.len(), "persisted_canonical_unchanged": persisted == bytes}
})
);
let paths = _dirs.iter().map(|dir| dir.path().to_path_buf()).collect::<Vec<_>>();
drop(_dirs);
assert!(paths.iter().all(|path| !path.exists()));
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-18", "status": "PASS", "fixtures_removed": paths.iter().all(|path| !path.exists())})
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[serial]
async fn blocked_companion_identity_keeps_canonical_without_delaying_healthy_buckets() {
use crate::bucket::metadata_sys::{
acquire_metadata_transaction_guard, init_bucket_metadata_sys, test_support::isolated_store_over_temp_disks,
};
use crate::config::com::save_config;
use crate::storage_api_contracts::bucket::MakeBucketOptions;
// Admin reads also feed spawned metrics collectors across crate boundaries.
fn assert_send<T: Send>(future: T) -> T {
future
}
let (_dirs, store) = isolated_store_over_temp_disks().await;
init_bucket_metadata_sys(store.clone(), Vec::new()).await;
let blocked = "usage-blocked-identity";
let healthy = "usage-healthy-identity";
let mut snapshots = Vec::new();
for bucket in [blocked, healthy] {
store
.make_bucket(bucket, &MakeBucketOptions::default())
.await
.expect("create companion identity fixture");
let incarnation = store.bucket_incarnation_id_from_disk(bucket).await.expect("real incarnation");
snapshots.push(companion_snapshot(bucket, incarnation));
}
let mut canonical = snapshots.remove(0);
let other = snapshots.remove(0);
canonical.buckets_usage.extend(other.buckets_usage);
canonical.bucket_sizes.extend(other.bucket_sizes);
canonical
.usage_snapshot_bucket_observations
.extend(other.usage_snapshot_bucket_observations);
canonical.usage_snapshot_pending_buckets.push(healthy.to_string());
canonical.usage_snapshot_pending_bucket_count = 2;
canonical.buckets_count = 2;
canonical.calculate_totals();
save_config(
store.clone(),
DATA_USAGE_OBJ_NAME_PATH.as_str(),
serde_json::to_vec(&canonical).expect("encode both canonical values and companions"),
)
.await
.expect("persist usage fixture");
invalidate_data_usage_snapshot_cache().await;
let blocked_guard = acquire_metadata_transaction_guard(
store.clone(),
blocked,
"admin_identity_timeout_test",
rustfs_lock::LockType::Exclusive,
)
.await
.expect("hold the real bucket metadata writer lock");
let response = tokio::time::timeout(
ADMIN_USAGE_INCARNATION_TIMEOUT + Duration::from_secs(3),
assert_send(load_admin_data_usage_from_backend_cached(store.clone())),
)
.await
.expect("optional projection must return before the blocked metadata lock's long timeout")
.expect("canonical admin response stays available");
assert_eq!(response.buckets_usage[blocked].size, 100);
assert_eq!(response.buckets_usage[blocked].usage_value_state, Some(BucketUsageValueState::Carried));
assert_eq!(response.buckets_usage[healthy].size, 250);
assert_eq!(response.buckets_usage[healthy].usage_value_state, Some(BucketUsageValueState::Observed));
assert!(response.usage_snapshot_admin_projection);
assert!(
ADMIN_DATA_USAGE_SNAPSHOT_REFRESH
.get()
.expect("admin refresh mutex")
.try_lock()
.is_ok()
);
drop(blocked_guard);
invalidate_data_usage_snapshot_cache().await;
let recovered = load_admin_data_usage_from_backend_cached(store.clone())
.await
.expect("refresh after lock recovery");
assert_eq!(
recovered.buckets_usage[blocked].size, 250,
"unavailable identity can recover on the next refresh"
);
assert_eq!(recovered.buckets_usage[healthy].size, 250);
let quota = load_data_usage_from_backend_cached(store)
.await
.expect("separate canonical quota read");
assert_eq!(quota.buckets_usage[blocked].size, 100);
assert_eq!(quota.buckets_usage[healthy].size, 100);
}
@@ -1,96 +0,0 @@
// Copyright 2026 RustFS Team
// SPDX-License-Identifier: Apache-2.0
use super::*;
// Freeze the pre-companion reader's primary fields. Serde's unknown-field
// behavior models the existing JSON reader without importing the new schema.
#[derive(serde::Deserialize)]
struct LegacyPrimarySnapshot {
buckets_usage: HashMap<String, LegacyPrimaryBucket>,
bucket_sizes: HashMap<String, u64>,
objects_total_count: u64,
objects_total_size: u64,
#[serde(default)]
usage_snapshot_complete: bool,
}
#[derive(serde::Deserialize)]
struct LegacyPrimaryBucket {
size: u64,
objects_count: u64,
}
#[test]
fn usage_legacy_reader_never_promotes_companion_values_into_primary_lkg() {
let incarnation = uuid::Uuid::from_u128(31);
let mut snapshot = companion_snapshot("bucket", incarnation);
let original_certificate = snapshot.buckets_usage["bucket"].usage_certification;
let mut decoded_sizes = Vec::new();
for cycle in 10..=12 {
snapshot.scanner_cycle = Some(cycle);
let identity = snapshot.snapshot_identity();
snapshot
.usage_snapshot_bucket_observations
.get_mut("bucket")
.unwrap()
.snapshot_identity = identity;
let bytes = serde_json::to_vec(&snapshot).expect("production persisted snapshot encoding");
let old: LegacyPrimarySnapshot = serde_json::from_slice(&bytes).expect("old reader tolerates additive fields");
assert!(old.usage_snapshot_complete);
assert_eq!(old.buckets_usage["bucket"].size, 100);
assert_eq!(old.buckets_usage["bucket"].objects_count, 10);
assert_eq!(old.bucket_sizes["bucket"], 100);
assert_eq!(old.objects_total_size, 100);
assert_eq!(old.objects_total_count, 10);
let current = parse_usage_snapshot(&bytes).expect("current reader accepts persisted primary plus companion");
assert_eq!(current.buckets_usage["bucket"].usage_certification, original_certificate);
assert_eq!(current.usage_snapshot_bucket_observations["bucket"].usage.size, 250);
decoded_sizes.push(old.buckets_usage["bucket"].size);
}
snapshot.buckets_usage.clear();
snapshot.bucket_sizes.clear();
snapshot.buckets_count = 0;
snapshot.calculate_totals();
snapshot.usage_snapshot_complete = false;
snapshot.usage_snapshot_partial = true;
snapshot.usage_snapshot_observational = true;
snapshot.usage_snapshot_set_states[0].complete = false;
let bytes = serde_json::to_vec(&snapshot).expect("persisted companion-only encoding");
let old: LegacyPrimarySnapshot = serde_json::from_slice(&bytes).expect("old reader handles the absent baseline");
assert!(old.buckets_usage.is_empty() && old.bucket_sizes.is_empty());
assert!(!old.usage_snapshot_complete);
assert_eq!((old.objects_total_count, old.objects_total_size), (0, 0));
let current = parse_usage_snapshot(&bytes).expect("valid current observational snapshot");
assert!(current.is_valid_partial_snapshot());
assert_eq!(current.usage_snapshot_bucket_observations["bucket"].usage.size, 250);
assert_eq!(
snapshot.project_bucket_observations_for_admin(&HashMap::from([("bucket".into(), incarnation.to_string())])),
1
);
let response_bytes = serde_json::to_vec(&snapshot).expect("admin response encoding");
assert!(
parse_usage_snapshot(&response_bytes).is_err(),
"a projected response cannot be written as a baseline"
);
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-16", "assertion_id": "USAGE-16-A01", "status": "PASS",
"evidence": {
"wire_format": "production JSON, frozen legacy named primary fields",
"legacy_primary_sizes_across_rounds": decoded_sizes,
"new_companion_size": 250,
"companion_only_legacy_primary_count": old.buckets_usage.len(),
"companion_only_legacy_complete": old.usage_snapshot_complete,
"projected_response_rejected_by_persistence_parser": true
}
})
);
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-16", "status": "PASS", "scope": "process-local"})
);
}
-11
View File
@@ -345,7 +345,6 @@ const DISK_OPERATION_NAMES: &[&str] = &[
"read_parts",
"read_multiple",
"write_all",
"write_format_control",
"compare_and_update_file",
"read_all",
];
@@ -3663,16 +3662,6 @@ impl DiskAPI for LocalDiskWrapper {
.await
}
async fn write_format_control(&self, path: &str, data: Bytes) -> Result<()> {
self.track_disk_health_mutation(
"write_format_control",
DiskMetricMutation::Write,
|| async { self.disk.write_format_control(path, data).await },
get_max_timeout_duration(),
)
.await
}
async fn compare_and_update_file(
&self,
volume: &str,
-1
View File
@@ -179,7 +179,6 @@ fn is_windows_dir_access_denied(_path: &Path, _e: &io::Error) -> bool {
false
}
#[cfg(test)]
#[tracing::instrument(level = "debug", skip_all)]
pub async fn remove(path: impl AsRef<Path>) -> io::Result<()> {
let path = path.as_ref().to_path_buf();
File diff suppressed because it is too large Load Diff
+46 -61
View File
@@ -504,10 +504,6 @@ impl LocalDisk {
dst_path: &str,
state: &mut RenameDataState,
) -> Result<RenameDataResp> {
state.namespace_owner = self.usage_watch_binding.owner(dst_volume, state.namespace_owner.take());
if src_volume != dst_volume {
state.namespace_owner = self.usage_watch_binding.owner(src_volume, state.namespace_owner.take());
}
super::multipart_staging::reject_noncanonical_scope(&self.root, self.io_root(), src_volume, src_path).inspect_err(
|_| {
state.preflight_rejection = Some(LocalRenamePreflightRejection(()));
@@ -845,20 +841,17 @@ impl LocalDisk {
run_inline_before_file_sync_admission(dst_path);
}
let sync_data_shards = no_inline && durability.syncs_data_shards();
let sync_metadata_files = durability.syncs_metadata_files();
let sync_commit_directories = durability.syncs_commit_directories();
let sync_recovery_protocol = durability.syncs_recovery_protocol_state();
let file_sync_admission =
if sync_data_shards || sync_metadata_files || sync_commit_directories || sync_recovery_protocol {
Some(
os::acquire_file_sync_admission(self.file_sync_permits.clone())
.await
.map_err(to_file_error)
.map_err(DiskError::from)?,
)
} else {
None
};
let sync_commit_metadata = durability.syncs_commit_metadata();
let file_sync_admission = if sync_data_shards || sync_commit_metadata {
Some(
os::acquire_file_sync_admission(self.file_sync_permits.clone())
.await
.map_err(to_file_error)
.map_err(DiskError::from)?,
)
} else {
None
};
let src_parent_owned = src_file_parent.to_path_buf();
let dst_parent_owned = dst_file_parent.to_path_buf();
let src_file_path_owned = src_file_path.clone();
@@ -969,7 +962,7 @@ impl LocalDisk {
&dst_file_path_owned,
&src_file_path_owned,
old_metadata,
sync_recovery_protocol,
sync_commit_metadata,
) {
Ok(path) => path,
Err(err) => {
@@ -982,33 +975,15 @@ impl LocalDisk {
}
if no_inline {
let presynced_data_dir = sync_data_shards
&& !probe_active
&& has_data_dir_path_owned
.as_ref()
.is_some_and(|(src_data_path, _)| super::take_presynced_tmp_data_dir(src_data_path));
if !presynced_data_dir
&& sync_data_shards
&& let Some((src_data_path, _)) = has_data_dir_path_owned.as_ref()
&& let Err(err) = os::sync_dir_files_std(src_data_path)
&& err.kind() != ErrorKind::NotFound
{
if let Some(backup_path) = staged_rollback_path.as_ref().map(StagedRollbackBackup::path) {
let _ = remove_file_if_exists(backup_path);
}
return Err(err);
}
if sync_metadata_files && let Err(err) = prepared_metadata_source.sync_data() {
if let Some(backup_path) = staged_rollback_path.as_ref().map(StagedRollbackBackup::path) {
let _ = remove_file_if_exists(backup_path);
}
return Err(err);
}
if presynced_data_dir && let Some((src_data_path, _)) = has_data_dir_path_owned.as_ref() {
// The payload was synced, and prepared_metadata_source.sync_data()
// committed the active journal transaction; persist src_data_path's
// directory entry before moving the data directory.
if let Err(err) = os::fsync_dir_std(src_data_path)
if sync_data_shards && let Some((src_data_path, _)) = has_data_dir_path_owned.as_ref() {
let sync_result = if !probe_active && super::take_presynced_tmp_data_dir(src_data_path) {
// The payload was synced, but its part.1 directory entry
// must also be persisted before moving the data directory.
os::fsync_dir_std(src_data_path)
} else {
os::sync_dir_files_std(src_data_path)
};
if let Err(err) = sync_result
&& err.kind() != ErrorKind::NotFound
{
if let Some(backup_path) = staged_rollback_path.as_ref().map(StagedRollbackBackup::path) {
@@ -1017,7 +992,13 @@ impl LocalDisk {
return Err(err);
}
}
} else if sync_metadata_files && let Err(err) = prepared_metadata_source.sync_data() {
if sync_commit_metadata && let Err(err) = prepared_metadata_source.sync_data() {
if let Some(backup_path) = staged_rollback_path.as_ref().map(StagedRollbackBackup::path) {
let _ = remove_file_if_exists(backup_path);
}
return Err(err);
}
} else if sync_commit_metadata && let Err(err) = prepared_metadata_source.sync_data() {
drop(prepared_metadata_source);
cleanup_flat_tmp();
if let Some(backup_path) = staged_rollback_path.as_ref().map(StagedRollbackBackup::path) {
@@ -1108,8 +1089,8 @@ impl LocalDisk {
if let Err(err) = backup_path_guard.write_file_for_path_access(
&backup_path,
dst_buf.as_ref(),
sync_recovery_protocol,
sync_recovery_protocol,
sync_commit_metadata,
sync_commit_metadata,
) {
return Ok(FusedCommitAttempt::RestoreDataSource(guard, to_file_error(err).into()));
}
@@ -1128,7 +1109,7 @@ impl LocalDisk {
&skip_parent,
&publication_root_owned,
None,
sync_recovery_protocol,
sync_commit_metadata,
) {
drop(prepared_metadata_source);
cleanup_flat_tmp();
@@ -1181,7 +1162,7 @@ impl LocalDisk {
return Ok(FusedCommitAttempt::CommitErr(DiskError::Unexpected));
}
if sync_commit_directories {
if sync_commit_metadata {
if staged_rollback_path.is_none()
&& rollback_data_dir.is_none()
&& let Some(ref old_metadata) = has_dst_buf
@@ -1323,7 +1304,7 @@ impl LocalDisk {
let publication_root_owned = self.publication_root.clone();
let has_data_dir_path_owned = has_data_dir_path.clone();
let sync_data_shards = durability.syncs_data_shards();
let sync_commit_directories = durability.syncs_commit_directories();
let sync_commit_metadata = durability.syncs_commit_metadata();
let staging_cleanup = multipart_staging.as_ref().map(|s| s.cleanup_handle());
let dst_volume_str = dst_volume.to_string();
let dst_path_str = dst_path.to_string();
@@ -1475,7 +1456,7 @@ impl LocalDisk {
if crash_inject::should_crash_at(CrashPoint::RenameAfterMetaCommit, &dst_path_str) {
return Ok(MultipartFusedCommitOutcome::AbortBeforeDataRename(DiskError::Unexpected));
}
if sync_commit_directories {
if sync_commit_metadata {
if let Some(parent) = dst_file_path_owned.parent()
&& let Err(err) = os::fsync_commit_directory_limited_std(parent, &directory_guard_owned)
{
@@ -1508,7 +1489,7 @@ impl LocalDisk {
}
}
match publication_owned.finish_on_thread(
durability.fully_syncs_commit_target(),
sync_commit_metadata,
!cfg!(test),
staging_cleanup,
Some(&directory_guard_owned),
@@ -1627,7 +1608,7 @@ impl LocalDisk {
.await?;
// This is system metadata authority, so use its existing strict
// durability policy even when the object payload is relaxed.
if effective_durability(src_volume).syncs_recovery_protocol_state() {
if effective_durability(src_volume).syncs_commit_metadata() {
os::fsync_dir_with_owner(recovery.parent().ok_or(DiskError::InvalidPath)?, Some(authority_owner.clone()))
.await
.map_err(to_file_error)?;
@@ -1734,7 +1715,7 @@ impl LocalDisk {
shard_sync_res?;
prepared_metadata_source
} else {
let tmp_meta_sync = if durability.syncs_metadata_files() {
let tmp_meta_sync = if durability.syncs_commit_metadata() {
SyncMode::FileOnly
} else {
SyncMode::None
@@ -1881,7 +1862,11 @@ impl LocalDisk {
// it keeps SyncMode::FileAndDir: contents and directory entry both
// durable. It is part of the metadata commit machinery, so relaxed
// tiers leave it to the page cache like the xl.meta it mirrors.
let backup_sync = durability.recovery_sync_mode();
let backup_sync = if durability.syncs_commit_metadata() {
SyncMode::FileAndDir
} else {
SyncMode::None
};
if let (Some(old_data_dir), Some(dst_buf)) = (rollback_data_dir, has_dst_buf.as_ref())
&& multipart_publication.as_ref().is_none_or(|publication| publication.legacy)
{
@@ -1998,7 +1983,7 @@ impl LocalDisk {
// Persist the directory entries for both the data dir and xl.meta renames;
// without this the commit itself can vanish on power loss. Relaxed tiers
// accept that window (documented in docs/operations/durability-modes.md).
if durability.syncs_commit_directories()
if durability.syncs_commit_metadata()
&& let Some(parent) = dst_file_path.parent()
{
let fsync_started = rustfs_io_metrics::put_stage_timer();
@@ -2038,7 +2023,7 @@ impl LocalDisk {
// are durable. Overwrites already have a durable object dir. The
// starts_with guard bounds the walk to the bucket subtree. Relaxed/none
// accept the wider window, like the commit fsync above.
if has_dst_buf.is_none() && durability.syncs_commit_directories() {
if has_dst_buf.is_none() && durability.syncs_commit_metadata() {
let mut ancestor = dst_file_path.parent().and_then(|object_dir| object_dir.parent());
while let Some(dir) = ancestor {
if !dir.starts_with(&dst_volume_dir) {
@@ -2105,7 +2090,7 @@ impl LocalDisk {
let multipart_source = match multipart_publication.as_ref() {
Some(publication) => {
let target_already_synced = durability.fully_syncs_commit_target();
let target_already_synced = durability.syncs_commit_metadata();
let staging_cleanup = multipart_staging.as_ref().map(|s| s.cleanup_handle());
match pin_multipart_future(|| {
publication.finish(commit.mutation_lease.clone(), target_already_synced, staging_cleanup)
@@ -2151,7 +2136,7 @@ impl LocalDisk {
#[cfg(windows)]
let source_parent = src_file_parent.to_path_buf();
let rename_commit_guard_for_preparation = commit.directory_guard.clone();
let sync = durability.syncs_recovery_protocol_state();
let sync = durability.syncs_commit_metadata();
#[cfg(unix)]
let receipt_identity = if sync
&& pool_meta_condition
+29 -444
View File
@@ -1867,7 +1867,7 @@ impl LocalDisk {
let destination = root.join(transaction.to_string());
let destination_was_absent = original.is_none();
let original = original.map(<[u8]>::to_vec);
let sync = effective_durability(volume).syncs_recovery_protocol_state();
let sync = effective_durability(volume).syncs_commit_metadata();
#[cfg(test)]
let record_destination = destination.clone();
let staging_root = temporary;
@@ -1925,40 +1925,28 @@ impl LocalDisk {
// The directory owner accompanies the blocking rename, so cancelling
// its waiter cannot delete staged files while activation is running.
let publication_owner: Option<Arc<dyn Send + Sync>> = Some(Arc::new((owner.clone(), staged.clone())));
os::rename_all_with_owner(staged.path(), &destination, &bucket, &self.publication_root, publication_owner).await?;
if sync {
// Rename and its directory syncs share one fsync-lane closure; the
// one-worker foreground lane serves metadata reads. The pinned
// parent is `root`; a new object also persists its ancestors.
let mut ancestors = Vec::new();
if destination_was_absent {
let mut path = root.as_path();
while path != bucket {
path = path.parent().ok_or(DiskError::InvalidPath)?;
ancestors.push(path.to_path_buf());
let mut dirs_to_sync = Vec::new();
let mut path = root.as_path();
loop {
dirs_to_sync.push(path.to_path_buf());
if !destination_was_absent || path == bucket {
break;
}
path = path.parent().ok_or(DiskError::InvalidPath)?;
}
let source = staged.path().to_path_buf();
let publication_root = self.publication_root.clone();
os::record_native_publication(&destination);
let lease = os::acquire_namespace_mutation_lease_with_owner(&destination, publication_owner).await;
os::run_blocking_namespace_operation_with_sync(lease, true, move || {
os::rename_all_with_precondition_and_parent_sync_std(
&source,
&destination,
&bucket,
&publication_root,
None,
true,
)?;
for dir in ancestors {
os::fsync_dir_std(&dir)?;
}
Ok(())
})
.await
.map_err(to_file_error)?;
} else {
os::rename_all_with_owner(staged.path(), &destination, &bucket, &self.publication_root, publication_owner).await?;
let sync_owner = owner.clone();
self.blocking_queue
.run_fsync_cancellable(move |_| {
let _owner = sync_owner;
for dir in dirs_to_sync {
os::fsync_dir_std(&dir)?;
}
Ok(())
})
.await
.map_err(to_file_error)?;
}
self.delete_recovery_barrier(volume, object, transaction, "PREPARED").await?;
Ok(target)
@@ -2150,7 +2138,6 @@ impl LocalDisk {
action: DeleteRecoveryAction,
owner: Option<Arc<dyn Send + Sync>>,
) -> Result<DeleteRecoveryInspection> {
let owner = self.usage_watch_binding.owner(volume, owner);
self.reject_multipart_delete_recovery_mutation(volume, object)?;
if let Ok(root) = self.io_get_object_path(volume, object) {
let tx_dir = root.join(transaction.to_string());
@@ -2344,7 +2331,7 @@ impl LocalDisk {
Err(err) if err.kind() == ErrorKind::NotFound => {}
Err(err) => return Err(to_file_error(err).into()),
}
if effective_durability(volume).syncs_recovery_protocol_state() {
if effective_durability(volume).syncs_commit_metadata() {
os::fsync_dir_with_owner(&dir, owner.clone()).await.map_err(to_file_error)?;
}
if self
@@ -2372,9 +2359,7 @@ impl LocalDisk {
Err(err) => return Err(to_file_error(err).into()),
}
}
if effective_durability(volume).syncs_recovery_protocol_state()
&& fs::try_exists(&rollback).await.map_err(to_file_error)?
{
if effective_durability(volume).syncs_commit_metadata() && fs::try_exists(&rollback).await.map_err(to_file_error)? {
os::fsync_dir_with_owner(&rollback, owner.clone())
.await
.map_err(to_file_error)?;
@@ -2458,7 +2443,7 @@ impl LocalDisk {
None,
)
.await?;
if effective_durability(volume).syncs_recovery_protocol_state() {
if effective_durability(volume).syncs_commit_metadata() {
os::fsync_dir_with_owner(&root, owner.clone()).await.map_err(to_file_error)?;
}
}
@@ -2469,7 +2454,7 @@ impl LocalDisk {
os::remove_files_and_fsync_with_owner(
&rollback,
&[STORAGE_FORMAT_FILE_BACKUP, DELETE_MARKER_ROLLBACK_FILE],
effective_durability(volume).syncs_recovery_protocol_state(),
effective_durability(volume).syncs_commit_metadata(),
None,
owner.clone(),
)
@@ -2502,7 +2487,7 @@ impl LocalDisk {
Err(err) if err.kind() == ErrorKind::NotFound => {}
Err(err) => return Err(to_file_error(err).into()),
}
if effective_durability(volume).syncs_recovery_protocol_state() {
if effective_durability(volume).syncs_commit_metadata() {
os::fsync_dir_with_owner(&staged, owner.clone())
.await
.map_err(to_file_error)?;
@@ -2583,7 +2568,7 @@ impl LocalDisk {
let lease = os::acquire_namespace_mutation_lease_with_owner(&dir, owner.clone()).await;
prune_dirs.push((dir, lease));
}
let sync = effective_durability(volume).syncs_recovery_protocol_state();
let sync = effective_durability(volume).syncs_commit_metadata();
let (rollback_buf, root_buf, volume_str, object_str) =
(rollback.clone(), root.clone(), volume.to_owned(), object.to_owned());
let publication_root = self.publication_root.clone();
@@ -2804,7 +2789,7 @@ impl LocalDisk {
} else {
self.io_get_bucket_path(RUSTFS_META_TMP_BUCKET)?
};
let sync = effective_durability(volume).syncs_recovery_protocol_state();
let sync = effective_durability(volume).syncs_commit_metadata();
let incarnation = opts.delete_recovery_bucket_incarnation;
let lease = os::acquire_namespace_mutation_lease_with_owner(&destination, owner).await;
let fi_clone = fi.clone();
@@ -3190,7 +3175,6 @@ impl LocalDisk {
namespace_owner: Option<Arc<dyn Send + Sync>>,
work_budget: Option<Arc<crate::object_api::DeleteRecoveryWorkBudget>>,
) -> Result<Option<(DeleteRecoveryJournal, bool, bool)>> {
let namespace_owner = self.usage_watch_binding.owner(volume, namespace_owner);
if transaction.is_nil() {
return Err(DiskError::InvalidPath);
}
@@ -3237,7 +3221,7 @@ impl LocalDisk {
let owner: Option<Arc<dyn Send + Sync>> = Some(Arc::new((metadata_owner, volume_guard)));
let rollback = root.join(transaction.to_string());
let receipt_path = rollback.join(DELETE_QUORUM_COMMITTED_FILE);
let sync = effective_durability(volume).syncs_recovery_protocol_state();
let sync = effective_durability(volume).syncs_commit_metadata();
let lease = os::acquire_namespace_mutation_lease_with_owner(&receipt_path, owner).await;
let volume_str = volume.to_owned();
let object_str = object.to_owned();
@@ -3413,7 +3397,6 @@ impl LocalDisk {
namespace_owner: Option<Arc<dyn Send + Sync>>,
work_budget: Option<Arc<crate::object_api::DeleteRecoveryWorkBudget>>,
) -> Result<bool> {
let namespace_owner = self.usage_watch_binding.owner(volume, namespace_owner);
fn ignore_not_found(res: std::io::Result<()>) -> std::io::Result<()> {
match res {
Ok(()) => Ok(()),
@@ -3480,7 +3463,7 @@ impl LocalDisk {
let owner: Option<Arc<dyn Send + Sync>> = Some(Arc::new((metadata_owner, volume_guard)));
let rollback = root.join(transaction.to_string());
let receipt_path = rollback.join(DELETE_QUORUM_COMMITTED_FILE);
let sync = effective_durability(volume).syncs_recovery_protocol_state();
let sync = effective_durability(volume).syncs_commit_metadata();
let mut claims: Vec<SnapshotLeaseDeleteClaim> = Vec::with_capacity(journal.data_dirs.len());
for data_dir in &journal.data_dirs {
@@ -4833,404 +4816,6 @@ mod tests {
assert!(temp.path().join("recovery").is_dir(), "finalization must preserve its original volume");
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_activation_leaves_metadata_reads_on_foreground_lane() {
assert_activation_leaves_metadata_reads_on_foreground_lane("object", |disk, transaction| async move {
let result = disk
.delete_versions_recoverable(
"recovery",
vec![super::super::FileInfoVersions {
name: "object".to_owned(),
versions: vec![request()],
..Default::default()
}],
DeleteOptions {
old_data_dir: Some(transaction),
..Default::default()
},
)
.await;
if result.len() == 1 && result[0].is_none() {
Ok(())
} else {
Err(format!("{result:?}"))
}
})
.await;
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_missing_original_activation_leaves_metadata_reads_on_foreground_lane() {
assert_activation_leaves_metadata_reads_on_foreground_lane("prefix/missing", |disk, transaction| async move {
let marker = FileInfo {
name: "prefix/missing".to_owned(),
version_id: Some(Uuid::new_v4()),
deleted: true,
mod_time: Some(OffsetDateTime::now_utc()),
..Default::default()
};
let context = DeletePreparationContext {
transaction,
bucket_incarnation: None,
namespace_owner: None,
};
match disk
.prepare_delete_recovery("recovery", "prefix/missing", None, &[marker], None, context)
.await
{
Ok(Some(_)) => Ok(()),
other => Err(format!("{other:?}")),
}
})
.await;
}
/// Pause the actual activation rename and require an unrelated metadata
/// read on the same disk to complete before the rename is released.
#[cfg(unix)]
async fn assert_activation_leaves_metadata_reads_on_foreground_lane<Fut>(
object: &str,
activate: impl FnOnce(Arc<LocalDisk>, Uuid) -> Fut,
) where
Fut: std::future::Future<Output = std::result::Result<(), String>> + Send + 'static,
{
use crate::disk::os::prepared_publication_test_hooks as hooks;
let _mode = durability_mode_override::set(DurabilityMode::Strict);
let (temp, disk, _, _) = fixture().await;
let disk = Arc::new(disk);
let metadata = temp.path().join("unrelated-metadata");
fs::write(&metadata, b"readable during activation")
.await
.expect("unrelated metadata fixture");
let transaction = Uuid::new_v4();
let destination = disk
.io_get_object_path("recovery", &format!("{object}/{transaction}"))
.expect("transaction path");
let staging_root = disk.io_get_bucket_path(RUSTFS_META_TMP_BUCKET).expect("staging root");
let (observer_tx, observer_rx) = tokio::sync::oneshot::channel();
let (entered_tx, entered_rx) = tokio::sync::oneshot::channel();
let (release_tx, release_rx) = std::sync::mpsc::channel();
let expected_destination = destination.clone();
set_owned_file_before_open(&destination.join(PREPARED), move || {
let stages: Vec<_> = std::fs::read_dir(&staging_root)
.expect("staging directory")
.map(|entry| entry.expect("staging entry").path())
.filter(|path| {
path.file_name()
.is_some_and(|name| name.to_string_lossy().starts_with("delete-preparation-"))
})
.collect();
assert_eq!(stages.len(), 1, "the isolated fixture has one pending preparation");
// Unlike a Stage::Rename pause, this observer does not add a replacement lane worker.
let observer = hooks::observe_rename_destination(&stages[0], move |destination| {
assert_eq!(destination, expected_destination);
let _ = entered_tx.send(());
let _ = release_rx.recv_timeout(Duration::from_secs(10));
});
let _ = observer_tx.send(observer);
});
let task = tokio::spawn(activate(Arc::clone(&disk), transaction));
let observer = tokio::time::timeout(Duration::from_secs(5), observer_rx).await;
let entered = tokio::time::timeout(Duration::from_secs(5), entered_rx).await;
let read = tokio::time::timeout(
Duration::from_secs(1),
disk.run_metadata_read(None, metadata, |opened| {
let mut file = opened?;
let mut bytes = Vec::new();
std::io::Read::read_to_end(&mut file, &mut bytes)?;
Ok::<_, std::io::Error>(bytes)
}),
)
.await;
let _ = release_tx.send(());
let activated = tokio::time::timeout(Duration::from_secs(5), task)
.await
.expect("activation finishes after release")
.expect("activation task joined");
drop(observer.expect("preparation registered observer").expect("observer received"));
entered.expect("actual rename reached").expect("rename observation received");
activated.expect("recoverable activation succeeds");
assert_eq!(
read.expect("metadata reads must progress while activation is paused")
.expect("metadata read queued")
.expect("metadata read completed"),
b"readable during activation"
);
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_activation_preserves_sync_modes_and_rollback() {
for mode in [DurabilityMode::Strict, DurabilityMode::Relaxed, DurabilityMode::None] {
let _mode = durability_mode_override::set(mode);
let (_temp, disk, _, original) = fixture().await;
let root = disk.io_get_object_path("recovery", "object").expect("object path");
// The next fixture can reuse this disk's fd alias; compare physical paths.
let recorded_root = root.canonicalize().expect("physical object path");
assert!(!os::fsync_dir_recorder::was_fsynced(&recorded_root), "fresh object sync history");
let transaction = Uuid::new_v4();
let result = disk
.delete_versions_recoverable(
"recovery",
vec![super::super::FileInfoVersions {
name: "object".to_owned(),
versions: vec![request()],
..Default::default()
}],
DeleteOptions {
old_data_dir: Some(transaction),
..Default::default()
},
)
.await;
assert_eq!(result.len(), 1);
assert!(result[0].is_none(), "prepare deletion in {mode:?}: {result:?}");
assert_eq!(
os::fsync_dir_recorder::was_fsynced(&recorded_root),
mode == DurabilityMode::Strict,
"activation must preserve the selected metadata sync mode"
);
let prepared = disk
.inspect_delete_transaction("recovery", "object", transaction)
.await
.expect("inspect applied preparation");
assert_eq!(prepared.state, DeleteRecoveryState::NewPrepared);
assert_eq!(prepared.backup_digest, Some(digest(&original)));
assert!(prepared.current_digest.is_none(), "delete is applied before its receipt is published");
let restored = disk
.settle_delete_transaction(
"recovery",
"object",
transaction,
prepared.fingerprint,
DeleteRecoveryAction::Rollback,
)
.await
.expect("roll back unpublished deletion");
assert_eq!(restored.state, DeleteRecoveryState::Absent);
assert_eq!(fs::read(root.join(STORAGE_FORMAT_FILE)).await.expect("restored metadata"), original);
assert!(!root.join(transaction.to_string()).exists(), "rollback removes its transaction");
}
}
#[cfg(target_os = "linux")]
#[tokio::test]
async fn delete_recovery_existing_activation_records_native_publication_before_rename() {
use crate::disk::os::prepared_publication_test_hooks as hooks;
use std::sync::atomic::{AtomicBool, Ordering};
let _mode = durability_mode_override::set(DurabilityMode::Strict);
let (_temp, disk, _, original) = fixture().await;
let bucket = format!("activation-history-{}", Uuid::new_v4());
let object = "prefix/object";
let witness = disk
.publication_history
.as_ref()
.expect("native publication history")
.witness(&bucket, Uuid::new_v4(), Arc::clone(&disk.io_backend))
.expect("fresh bucket publication history");
let root = disk.io_get_object_path(&bucket, object).expect("existing nested object path");
// Seed existing parents without consuming the history being tested at activation.
std::fs::create_dir_all(&root).expect("raw existing hierarchy");
std::fs::write(root.join(STORAGE_FORMAT_FILE), &original).expect("raw original metadata");
assert!(os::validate_native_creation_witnesses(std::slice::from_ref(&witness)));
let transaction = Uuid::new_v4();
let observed = Arc::new(AtomicBool::new(false));
let hook_observed = Arc::clone(&observed);
let _hook = hooks::install_at(hooks::Stage::Rename, &root.join(transaction.to_string()), move || {
assert!(
!os::validate_native_creation_witnesses(std::slice::from_ref(&witness)),
"activation must consume history before the native rename runs"
);
hook_observed.store(true, Ordering::Release);
});
disk.prepare_delete_recovery(
&bucket,
object,
Some(&original),
&[request()],
None,
DeletePreparationContext {
transaction,
bucket_incarnation: None,
namespace_owner: None,
},
)
.await
.expect("activate existing nested object preparation");
assert!(observed.load(Ordering::Acquire), "the actual activation rename hook must run");
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_activation_sync_failure_preserves_original_and_preparation() {
let _mode = durability_mode_override::set(DurabilityMode::Strict);
let (_temp, disk, _, original) = fixture().await;
let root = disk.io_get_object_path("recovery", "object").expect("object path");
let transaction = Uuid::new_v4();
os::fsync_dir_recorder::set_failure(&root, ErrorKind::Other);
let result = disk
.delete_versions_recoverable(
"recovery",
vec![super::super::FileInfoVersions {
name: "object".to_owned(),
versions: vec![request()],
..Default::default()
}],
DeleteOptions {
old_data_dir: Some(transaction),
..Default::default()
},
)
.await;
assert_eq!(result.len(), 1);
assert!(result[0].is_some(), "activation sync failure must reach the caller");
assert!(os::fsync_dir_recorder::take_failure(&root).is_none(), "the injected failure was consumed");
assert_eq!(fs::read(root.join(STORAGE_FORMAT_FILE)).await.expect("unchanged head"), original);
let prepared = disk
.inspect_delete_transaction("recovery", "object", transaction)
.await
.expect("inspect failed activation");
assert_eq!(prepared.state, DeleteRecoveryState::NewPrepared);
assert_eq!(prepared.backup_digest, Some(digest(&original)));
assert_eq!(prepared.current_digest, Some(digest(&original)));
let restored = disk
.settle_delete_transaction("recovery", "object", transaction, prepared.fingerprint, DeleteRecoveryAction::Rollback)
.await
.expect("retry can settle failed activation");
assert_eq!(restored.state, DeleteRecoveryState::Absent);
assert_eq!(fs::read(root.join(STORAGE_FORMAT_FILE)).await.expect("settled head"), original);
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_activation_owner_outlives_cancelled_parent_sync() {
use crate::disk::os::prepared_publication_test_hooks as hooks;
use futures::FutureExt;
let _mode = durability_mode_override::set(DurabilityMode::Strict);
let (temp, disk, _, original) = fixture().await;
let disk = Arc::new(disk);
let transaction = Uuid::new_v4();
let root = disk.io_get_object_path("recovery", "object").expect("object path");
let (entered_tx, entered_rx) = tokio::sync::oneshot::channel();
let (release_tx, release_rx) = std::sync::mpsc::channel();
let hook = hooks::install_at(hooks::Stage::DirFsync, &root, move || {
let _ = entered_tx.send(());
let _ = release_rx.recv_timeout(Duration::from_secs(10));
});
let deleting = Arc::clone(&disk);
let task = tokio::spawn(async move {
deleting
.delete_versions_recoverable(
"recovery",
vec![super::super::FileInfoVersions {
name: "object".to_owned(),
versions: vec![request()],
..Default::default()
}],
DeleteOptions {
old_data_dir: Some(transaction),
..Default::default()
},
)
.await
});
let mut removal = None;
let observations = std::panic::AssertUnwindSafe(async {
tokio::time::timeout(Duration::from_secs(5), entered_rx)
.await
.expect("activation reached parent sync")
.expect("parent sync observation received");
assert!(root.join(transaction.to_string()).join(PREPARED).is_file());
assert_eq!(fs::read(root.join(STORAGE_FORMAT_FILE)).await.expect("head before sync"), original);
task.abort();
assert!(task.await.expect_err("delete waiter was cancelled").is_cancelled());
let removing = Arc::clone(&disk);
removal = Some(tokio::spawn(async move { removing.delete_volume("recovery", true).await }));
assert!(
tokio::time::timeout(Duration::from_millis(100), removal.as_mut().expect("volume removal started"))
.await
.is_err(),
"the active sync must retain the volume mutation owner after cancellation"
);
assert!(root.join(transaction.to_string()).join(STORAGE_FORMAT_FILE_BACKUP).is_file());
})
.catch_unwind()
.await;
let _ = release_tx.send(());
drop(hook);
if let Some(removal) = removal {
tokio::time::timeout(Duration::from_secs(5), removal)
.await
.expect("volume removal resumes after sync")
.expect("volume removal joined")
.expect("volume removal succeeds");
}
if let Err(panic) = observations {
std::panic::resume_unwind(panic);
}
disk.make_volume("recovery")
.await
.expect("recreate volume after sync drained");
assert!(
!temp.path().join("recovery/object").exists(),
"cancelled activation cannot publish into the new volume"
);
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_missing_original_preparation_syncs_ancestors() {
let _mode = durability_mode_override::set(DurabilityMode::Strict);
let (_temp, disk, _, _) = fixture().await;
let object = "prefix/missing";
let root = disk.io_get_object_path("recovery", object).expect("missing object path");
let transaction = Uuid::new_v4();
let marker = FileInfo {
name: object.to_owned(),
version_id: Some(Uuid::new_v4()),
deleted: true,
mod_time: Some(OffsetDateTime::now_utc()),
..Default::default()
};
let target = disk
.prepare_delete_recovery(
"recovery",
object,
None,
&[marker],
None,
DeletePreparationContext {
transaction,
bucket_incarnation: None,
namespace_owner: None,
},
)
.await
.expect("prepare missing-object marker");
assert!(target.is_some(), "the marker has a planned metadata target");
for directory in [
&root,
root.parent().expect("prefix"),
root.parent().and_then(Path::parent).expect("bucket"),
] {
// Physical paths: a reused fd alias from another test cannot match.
let physical = directory.canonicalize().expect("physical ancestor path");
assert!(os::fsync_dir_recorder::was_fsynced(&physical), "persist created ancestors: {physical:?}");
}
let prepared = disk
.inspect_delete_transaction("recovery", object, transaction)
.await
.expect("inspect missing-object preparation");
assert_eq!(prepared.state, DeleteRecoveryState::NewPrepared);
assert!(prepared.backup_digest.is_none());
assert!(prepared.current_digest.is_none());
}
#[cfg(unix)]
#[tokio::test]
async fn delete_recovery_activation_is_complete_before_metadata_mutation_even_after_cancel() {
@@ -125,80 +125,6 @@ async fn commit_actual_abort(fixture: &Fixture, certificate: &MultipartAbortCert
}
}
#[cfg(target_os = "linux")]
#[tokio::test]
async fn native_abort_late_part_settlement_preserves_the_retired_tree() {
use crate::disk::{PartTransactionAction, RUSTFS_META_TMP_BUCKET};
let fixture = heap_native(Fixture::new).await;
let disk = &fixture.disks[0];
for volume in [RUSTFS_META_TMP_BUCKET, RUSTFS_META_TMP_DELETED_BUCKET] {
match disk.make_volume(volume).await {
Ok(()) | Err(DiskError::VolumeExists) => {}
Err(error) => panic!("prepare the part/retirement volume: {error}"),
}
}
let snapshot = heap_native(|| fixture.snapshot(0)).await;
let destination = format!("{}/{}/part.1", fixture.path, snapshot.lineage.original_data_dir);
let body = bytes::Bytes::from_static(b"replacement shard");
let part = ObjectPartInfo {
number: 1,
size: body.len(),
actual_size: i64::try_from(body.len()).expect("fixture shard size fits i64"),
etag: "replacement".to_owned(),
..Default::default()
};
let metadata = bytes::Bytes::from(part.marshal_msg().expect("part transaction metadata"));
disk.write_all(RUSTFS_META_TMP_BUCKET, "late-settle/part.1", body)
.await
.expect("stage the replacement shard");
disk.prepare_part_transaction(
RUSTFS_META_TMP_BUCKET,
"late-settle/part.1",
RUSTFS_META_MULTIPART_BUCKET,
&destination,
metadata.clone(),
)
.await
.expect("prepare the replacement transaction");
disk.rename_part(
RUSTFS_META_TMP_BUCKET,
"late-settle/part.1",
RUSTFS_META_MULTIPART_BUCKET,
&destination,
metadata,
)
.await
.expect("publish the replacement before retaining its settlement");
let transaction = disk
.io_get_object_open_path(RUSTFS_META_MULTIPART_BUCKET, &crate::disk::part_transaction_path(&destination))
.expect("published transaction cache key");
assert!(
crate::disk::local::PUBLISHED_PART_TXN_RECEIPTS
.with_get(&transaction, |receipt| receipt.txn_parent_fd.is_some())
.unwrap_or(false),
"the real part APIs must retain their pinned transaction parent"
);
let certificate = heap_native(|| prepare_actual_abort(&fixture)).await;
heap_native(|| commit_actual_abort(&fixture, &certificate)).await;
disk.recover_multipart_source(fixture.request(MultipartSourceOperation::DeleteAborted {
expected: heap_native(|| fixture.snapshot(0)).await,
certificate,
}))
.await
.expect("retire the actual upload into its ordinary trash tree");
assert!(!source_root(&fixture, 0).exists());
let trash = disk.root.join(RUSTFS_META_TMP_DELETED_BUCKET);
let before = exact_tree(&trash);
assert!(!before.is_empty(), "retirement must retain the real transaction in trash");
disk.settle_part_transaction(RUSTFS_META_MULTIPART_BUCKET, &destination, PartTransactionAction::Commit)
.await
.expect("an absent canonical transaction is already settled");
assert!(!source_root(&fixture, 0).exists(), "late settlement must not recreate the upload");
assert_eq!(exact_tree(&trash), before, "late settlement must preserve the exact retired bytes");
}
async fn assert_generic_deletes_preserve_source(fixture: &Fixture, slot: usize) {
let before = exact_tree(&source_root(fixture, slot));
let disk = &fixture.disks[slot];
@@ -1578,7 +1578,7 @@ impl LocalDisk {
let object_path = self.io_get_object_path(&volume, &object)?;
let directory = object_path.join(proof.publication.final_data_dir.to_string());
let lease = os::acquire_namespace_mutation_lease_with_owner(&directory, Some(metadata_owner)).await;
let sync = super::effective_durability(&volume).syncs_recovery_protocol_state();
let sync = super::effective_durability(&volume).syncs_commit_metadata();
let result = os::run_blocking_namespace_operation_with_sync(lease, sync, move || {
let result = (|| {
let base = &proof.base;
@@ -221,22 +221,6 @@ impl MultipartSourceAdmission {
super::multipart_source_state::validate_source_mutation(&self.source, &self.base, &self.publication_root, self.initial)
.map_err(std::io::Error::other)
}
pub(super) fn validate_part_settlement(&self, transaction: &Path) -> std::io::Result<bool> {
match self.validate() {
Ok(()) => Ok(true),
Err(error) => {
// A cached parent FD can still name the transaction after Abort
// moved its upload to trash. With SourceRW held, an absent
// canonical transaction is already settled. Resolve beneath the
// publication root so aliases and access errors remain failures.
match os::pin_multipart_source_directory(transaction, &self.base, &self.publication_root) {
Err(missing) if missing.kind() == std::io::ErrorKind::NotFound => Ok(false),
_ => Err(error),
}
}
}
}
}
/// The retirement record is native-only, even through raw file RPCs.
@@ -1288,39 +1272,6 @@ mod tests {
assert!(!directory.exists(), "a per-upload safety guard must not strand empty hash directories");
}
#[cfg(unix)]
#[tokio::test]
async fn multipart_source_settlement_admission_distinguishes_absence_from_aliases() {
let (root, disk, info, _) = fixture().await;
let part = format!("upload/{}/part.1", info.data_dir.expect("fixture data directory"));
let transaction = disk
.io_get_object_path(RUSTFS_META_MULTIPART_BUCKET, &crate::disk::part_transaction_path(&part))
.expect("canonical transaction path");
let admission = disk
.multipart_source_admission(RUSTFS_META_MULTIPART_BUCKET, &part, true, false)
.expect("canonical source admission")
.expect("multipart admission");
std::fs::remove_file(root.path().join(RUSTFS_META_MULTIPART_BUCKET).join("upload/xl.meta"))
.expect("retire the source head");
assert!(admission.validate().is_err(), "the closed source must reject mutations");
std::fs::create_dir_all(&transaction).expect("an existing transaction under the closed source");
assert!(
admission.validate_part_settlement(&transaction).is_err(),
"an existing transaction still requires active-source authority"
);
std::fs::remove_dir(&transaction).expect("remove only the fixture transaction");
assert!(
!admission
.validate_part_settlement(&transaction)
.expect("an absent transaction is already settled")
);
std::os::unix::fs::symlink(root.path().join("absent"), &transaction).expect("inject a dangling transaction alias");
assert!(
admission.validate_part_settlement(&transaction).is_err(),
"a dangling alias must retain the source admission failure"
);
}
#[tokio::test]
async fn multipart_source_active_head_cache_populates_and_invalidates_across_part_and_delete_paths() {
use crate::disk::{DiskAPI as _, PartTransactionAction, ReadOptions};
@@ -1733,7 +1733,7 @@ mod tests {
async fn protected_object_aliases(disk: &LocalDisk) -> Vec<(String, String)> {
let object = disk.root.join(RUSTFS_META_BUCKET).join(OBJECT);
let aliases = vec![
let mut aliases = vec![
(format!("{RUSTFS_META_BUCKET}/."), OBJECT.to_string()),
(format!("{RUSTFS_META_BUCKET}/"), OBJECT.to_string()),
(format!("{RUSTFS_META_BUCKET}/{OBJECT}"), String::new()),
@@ -1743,9 +1743,8 @@ mod tests {
(object.to_str().expect("UTF-8 object path").to_string(), String::new()),
];
#[cfg(unix)]
let aliases = {
{
use std::os::unix::fs::MetadataExt;
let mut aliases = aliases;
let head = fs::metadata(object.join(STORAGE_FORMAT_FILE))
.await
.expect("canonical head metadata");
@@ -1762,8 +1761,7 @@ mod tests {
aliases.push((volume, path));
}
}
aliases
};
}
aliases
}
@@ -1,234 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
use super::*;
use crate::runtime::usage_watch::{ScannerUsageWatchRequest, UsageWatchRegistry};
fn watch_request(bucket: &str) -> ScannerUsageWatchRequest {
ScannerUsageWatchRequest {
bucket: bucket.into(),
bucket_incarnation: Uuid::from_u128(2),
watch_id: None,
release: false,
session_id: None,
}
}
async fn fixture() -> (tempfile::TempDir, Arc<LocalDisk>, Arc<UsageWatchRegistry>) {
let root = tempfile::tempdir().expect("watch physical fixture directory");
let endpoint = Endpoint::try_from(root.path().to_string_lossy().as_ref()).expect("watch physical endpoint");
let disk = Arc::new(LocalDisk::new(&endpoint, false).await.expect("watch physical disk"));
disk.make_volume("bucket").await.expect("watch test bucket");
let registry = Arc::new(UsageWatchRegistry::default());
disk.usage_watch_binding.bind(&registry);
(root, disk, registry)
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn usage_watch_stays_inflight_after_metadata_is_visible_and_waiter_is_canceled() {
let (_root, disk, registry) = fixture().await;
let target = disk
.io_get_object_path("bucket", "object")
.expect("target metadata directory");
let (entered, wait_for_enter) = tokio::sync::oneshot::channel();
let (release, hold) = std::sync::mpsc::channel::<()>();
let _hook = os::prepared_publication_test_hooks::install_at(
os::prepared_publication_test_hooks::Stage::DirFsync,
&target,
move || {
let _ = entered.send(());
let _ = hold.recv();
},
);
let writer_disk = Arc::clone(&disk);
let mut writer = tokio::spawn(async move {
let info =
super::test::test_file_info("object", Uuid::new_v4(), Some(Uuid::new_v4()), Some(Bytes::from_static(b"payload")));
writer_disk.write_metadata("", "bucket", "object", info).await
});
tokio::time::timeout(Duration::from_secs(10), wait_for_enter)
.await
.expect("reach physical fsync barrier")
.expect("barrier entered");
assert!(
target.join(STORAGE_FORMAT_FILE).exists(),
"metadata is already visible at the blocked fsync"
);
let during = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("install during active physical mutation");
assert!(during.inflight > 0, "installation must include pre-existing writes");
writer.abort();
assert!((&mut writer).await.expect_err("cancel logical waiter").is_cancelled());
let canceled = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("watch survives logical cancellation");
assert!(canceled.inflight > 0, "physical tail retains its guard");
drop(release);
let settled = tokio::time::timeout(Duration::from_secs(10), async {
loop {
let observation = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("settlement proof");
if observation.inflight == 0 {
break observation;
}
tokio::task::yield_now().await;
}
})
.await
.expect("physical tail settles");
assert!(settled.revision > during.revision);
assert!(!settled.unchanged_since(&during));
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-12", "assertion_id": "USAGE-12-A03", "status": "PASS",
"evidence": {"inflight_at_install": during.inflight, "inflight_after_waiter_cancel": canceled.inflight, "inflight_after_physical_end": settled.inflight, "revision_at_install": during.revision, "revision_after_physical_end": settled.revision}
})
);
drop(disk);
drop(registry);
let root_path = _root.path().to_path_buf();
drop(_root);
assert!(!root_path.exists());
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-12", "status": "PASS", "fixture_removed": !root_path.exists()})
);
}
#[tokio::test]
async fn usage_watch_status_only_metadata_keeps_maintenance_semantics() {
let (_root, disk, registry) = fixture().await;
let info = super::test::test_file_info("object", Uuid::new_v4(), Some(Uuid::new_v4()), Some(Bytes::from_static(b"payload")));
disk.write_metadata("", "bucket", "object", info.clone())
.await
.expect("initial counted version");
let before = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("idle watch");
let mut status = info.clone();
status.metadata.clear();
rustfs_utils::http::metadata_compat::insert_str(
&mut status.metadata,
rustfs_utils::http::SUFFIX_REPLICATION_STATUS,
"arn=COMPLETED;".into(),
);
disk.update_metadata("bucket", "object", status, &UpdateMetadataOpts::default())
.await
.expect("status-class metadata update");
let after = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("status result watch");
assert!(after.unchanged_since(&before), "replication counters retain maintenance cadence");
let mut next = info;
next.version_id = Some(Uuid::new_v4());
disk.write_metadata("", "bucket", "object", next).await.expect("new version");
let changed = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("new version watch");
assert!(changed.revision > after.revision);
assert_eq!(changed.inflight, 0);
}
#[tokio::test]
async fn usage_watch_raw_live_stream_revokes_coverage_and_internal_staging_does_not() {
let (_root, disk, registry) = fixture().await;
let before = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("idle watch");
disk.usage_watch_binding.mark_uncovered_user_stream(RUSTFS_META_TMP_BUCKET);
assert!(
registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("internal staging stays covered")
.unchanged_since(&before)
);
let _stream = disk.create_file("bucket", "bucket", "raw-file", 0).await;
assert_eq!(registry.observe(Uuid::from_u128(1), &watch_request("bucket")), None);
assert!(!disk.usage_watch_binding.matches(&registry));
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn usage_watch_delete_paths_retains_ownership_through_canceled_trash_rename() {
let (_root, disk, registry) = fixture().await;
let target = disk.io_get_object_path("bucket", "delete-me").expect("delete source");
std::fs::write(&target, b"payload").expect("initial source");
let trash = disk.io_get_bucket_path(RUSTFS_META_TMP_DELETED_BUCKET).expect("trash volume");
std::fs::create_dir_all(&trash).expect("trash directory");
let before = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("initial proof");
let (entered, wait_for_enter) = tokio::sync::oneshot::channel();
let (release, hold) = std::sync::mpsc::channel::<()>();
let _hook =
os::prepared_publication_test_hooks::install_at(os::prepared_publication_test_hooks::Stage::Rename, &target, move || {
let _ = entered.send(());
let _ = hold.recv();
});
let deleting_disk = Arc::clone(&disk);
let mut deleting = tokio::spawn(async move { deleting_disk.delete_paths("bucket", &["delete-me".into()]).await });
tokio::time::timeout(Duration::from_secs(10), wait_for_enter)
.await
.expect("reach raw trash rename")
.expect("rename entered");
deleting.abort();
assert!((&mut deleting).await.expect_err("logical waiter canceled").is_cancelled());
let during = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("active proof");
assert!(during.inflight > 0, "trash syscall owns the watch after waiter cancellation");
assert!(during.revision > before.revision);
drop(release);
let after = tokio::time::timeout(Duration::from_secs(10), async {
loop {
let observation = registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("draining proof");
if observation.inflight == 0 {
break observation;
}
tokio::task::yield_now().await;
}
})
.await
.expect("physical rename settles");
assert!(!target.exists());
assert!(after.revision > during.revision);
assert!(!after.unchanged_since(&before));
}
#[tokio::test]
async fn owned_stale_destination_removal_preserves_file_directory_and_symlink_semantics() {
let (_root, disk, registry) = fixture().await;
let target = disk.io_get_object_path("bucket", "stale").expect("stale destination");
std::fs::write(&target, b"stale-file").expect("stale file");
os::remove_with_owner(&target, disk.usage_watch_binding.owner("bucket", None))
.await
.expect("remove stale file");
assert!(!target.exists());
std::fs::create_dir(&target).expect("stale directory");
os::remove_with_owner(&target, disk.usage_watch_binding.owner("bucket", None))
.await
.expect("remove empty directory");
assert!(!target.exists());
#[cfg(unix)]
{
let referent = disk.io_get_object_path("bucket", "retained").expect("symlink referent");
std::fs::write(&referent, b"retained").expect("retained file");
std::os::unix::fs::symlink(&referent, &target).expect("stale symlink");
os::remove_with_owner(&target, disk.usage_watch_binding.owner("bucket", None))
.await
.expect("remove symlink itself");
assert!(!target.exists());
assert_eq!(std::fs::read(referent).expect("referent remains"), b"retained");
}
assert_eq!(
registry
.observe(Uuid::from_u128(1), &watch_request("bucket"))
.expect("all work drained")
.inflight,
0
);
}
+2 -74
View File
@@ -30,7 +30,6 @@ pub mod local;
pub mod multipart_index;
pub mod multipart_source;
pub mod os;
mod usage_watch;
pub(crate) use io_admission::memory as background_memory;
pub(crate) use io_admission::remote as remote_io_admission;
@@ -59,21 +58,6 @@ pub const BUCKET_META_PREFIX: &str = "buckets";
/// a user bucket of the same name, so bucket deletion must leave it in place.
pub const HEAL_REPLACEMENT_RECOVERY_DIR: &str = "ahm-replacement";
pub const FORMAT_CONFIG_FILE: &str = "format.json";
pub(crate) const FORMAT_BOOTSTRAP_FILE: &str = "format.json.bootstrap";
pub(crate) const FORMAT_BOOTSTRAP_DONE_FILE: &str = "format.json.bootstrap.done";
/// Validate an internal format control filename for atomic publication.
///
/// # Errors
/// Returns [`DiskError::MethodNotAllowed`] for every other path.
pub fn validate_format_control_path(path: &str) -> Result<()> {
if matches!(path, FORMAT_CONFIG_FILE | FORMAT_BOOTSTRAP_FILE) {
Ok(())
} else {
Err(DiskError::MethodNotAllowed)
}
}
/// Per-disk marker present while an erasure-set heal is rebuilding this disk.
/// `LocalDisk::disk_info` reports `healing = true` while the file exists.
pub const HEALING_MARKER_PATH: &str = "healing.bin";
@@ -1186,13 +1170,6 @@ impl DiskAPI for Disk {
}
}
async fn write_format_control(&self, path: &str, data: Bytes) -> Result<()> {
match self {
Disk::Local(local_disk) => local_disk.write_format_control(path, data).await,
Disk::Remote(remote_disk) => remote_disk.write_format_control(path, data).await,
}
}
async fn compare_and_update_file(
&self,
volume: &str,
@@ -1429,16 +1406,6 @@ impl Disk {
}
impl Disk {
/// The progress flag is derived from a verified capability scope.
pub async fn ns_scanner_progress_capability(
&self,
) -> Result<Option<crate::storage_api_contracts::internode::NsScannerCapabilities>> {
match self {
Disk::Local(_) => Ok(None),
Disk::Remote(remote_disk) => remote_disk.ns_scanner_progress_capability().await,
}
}
pub async fn ns_scanner_server_epoch(&self) -> Result<Option<Uuid>> {
match self {
Disk::Local(_) => Ok(None),
@@ -1615,18 +1582,14 @@ pub(crate) async fn new_disk_for_instance(
ep: &Endpoint,
opt: &DiskOption,
) -> Result<DiskStore> {
let disk = new_disk_with_health_tracker(
new_disk_with_health_tracker(
ep,
opt,
None,
#[cfg(feature = "internode-transport")]
Some(_instance),
)
.await?;
if let Disk::Local(wrapper) = disk.as_ref() {
wrapper.get_disk().usage_watch_binding.bind(&_instance.usage_watches);
}
Ok(disk)
.await
}
pub(crate) async fn new_disk_with_health_tracker(
@@ -1942,21 +1905,6 @@ pub trait DiskAPI: Debug + Send + Sync + 'static {
async fn read_multiple(&self, req: ReadMultipleReq) -> Result<Vec<ReadMultipleResp>>;
// CleanAbandonedData
async fn write_all(&self, volume: &str, path: &str, data: Bytes) -> Result<()>;
/// Atomically publish a valid per-drive `FormatV3` control file in the system volume.
/// Deployment, topology and member UUID must agree with existing control records.
/// Pending intents admit equivalent plans, and retired intents reject bootstrap
/// republication. Success requires a durable replacement inode and parent entry.
/// Cancellation can leave the complete plan published. Retries revalidate the
/// plan under the per-disk owner before publishing it durably.
///
/// # Errors
/// Returns [`DiskError::MethodNotAllowed`] for unsupported implementations,
/// paths or retired bootstrap intents, [`DiskError::CorruptedFormat`] for
/// invalid or conflicting plans, and an I/O error when publication or its
/// durability barrier fails.
async fn write_format_control(&self, _path: &str, _data: Bytes) -> Result<()> {
Err(DiskError::MethodNotAllowed)
}
async fn read_all(&self, volume: &str, path: &str) -> Result<Bytes>;
/// Atomically replace or remove a small control file only when its current
/// contents match `expected`. Implementations that cannot provide this
@@ -2912,26 +2860,6 @@ pub fn count_part_not_success(part_errs: &[usize]) -> usize {
#[cfg(test)]
mod tests {
#[test]
fn format_control_paths_are_fixed_system_leaf_names() {
for path in [super::FORMAT_CONFIG_FILE, super::FORMAT_BOOTSTRAP_FILE] {
super::validate_format_control_path(path).expect("allowed format control leaf");
}
for path in [
"",
"../format.json",
"format.json/",
".rustfs.sys/format.json",
"format.json.bootstrap.done",
"pool.bin",
] {
assert!(matches!(
super::validate_format_control_path(path),
Err(super::DiskError::MethodNotAllowed)
));
}
}
use super::*;
#[test]
+30 -26
View File
@@ -3817,6 +3817,20 @@ pub async fn read_dir(path: impl AsRef<Path>, count: i32) -> std::io::Result<Vec
Ok(volumes)
}
#[tracing::instrument(level = "debug", skip_all)]
pub async fn rename_all(
src_file_path: impl AsRef<Path>,
dst_file_path: impl AsRef<Path>,
base_dir: impl AsRef<Path>,
publication_root: &PublicationRoot,
) -> Result<()> {
reliable_rename(src_file_path, dst_file_path.as_ref(), base_dir, publication_root)
.await
.map_err(to_file_error)?;
Ok(())
}
/// Retain mutation ownership through both metadata publication and its directory
/// barriers, even when the async caller stops waiting after the rename starts.
pub(crate) async fn rename_metadata_and_sync_with_lease(
@@ -3861,19 +3875,6 @@ pub(crate) async fn fsync_dir_with_owner(path: &Path, namespace_owner: Option<Ar
}
}
/// Preserve file, symlink, and empty-directory removal semantics while the
/// actual filesystem executor retains namespace ownership after cancellation.
pub(crate) async fn remove_with_owner(path: impl AsRef<Path>, namespace_owner: Option<Arc<dyn Send + Sync>>) -> io::Result<()> {
let path = path.as_ref().to_path_buf();
let lease = acquire_namespace_mutation_lease_with_owner(&path, namespace_owner).await;
run_blocking_namespace_operation(lease, move || {
#[cfg(all(any(test, feature = "test-util"), not(windows)))]
prepared_publication_test_hooks::run(prepared_publication_test_hooks::Stage::Remove, &path);
super::fs::remove_std(path)
})
.await
}
/// Retain namespace ownership in the actual filesystem executor after timeout.
pub(crate) async fn remove_file_with_owner(
path: impl AsRef<Path>,
@@ -4552,7 +4553,6 @@ pub(crate) mod multipart_source_syscall_failures {
use super::*;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub(crate) enum Stage {
Read,
Create,
Write,
FileSync,
@@ -4560,7 +4560,7 @@ pub(crate) mod multipart_source_syscall_failures {
}
type Key = (Stage, PathBuf);
struct Failure {
error: Mutex<Option<io::Error>>,
kind: io::ErrorKind,
triggered: std::sync::atomic::AtomicUsize,
}
static FAILURES: LazyLock<Mutex<HashMap<Key, Arc<Failure>>>> = LazyLock::new(|| Mutex::new(HashMap::new()));
@@ -4585,12 +4585,9 @@ pub(crate) mod multipart_source_syscall_failures {
}
}
pub(crate) fn fail_once(stage: Stage, path: &Path, kind: io::ErrorKind) -> FailureGuard {
fail_once_with_error(stage, path, io::Error::new(kind, "injected native physical syscall failure"))
}
pub(crate) fn fail_once_with_error(stage: Stage, path: &Path, error: io::Error) -> FailureGuard {
let key = (stage, path.to_path_buf());
let failure = Arc::new(Failure {
error: Mutex::new(Some(error)),
kind,
triggered: std::sync::atomic::AtomicUsize::new(0),
});
assert!(
@@ -4602,7 +4599,7 @@ pub(crate) mod multipart_source_syscall_failures {
pub(crate) fn check(stage: Stage, path: &Path) -> io::Result<()> {
if let Some(failure) = FAILURES.lock().remove(&(stage, path.to_path_buf())) {
failure.triggered.fetch_add(1, std::sync::atomic::Ordering::Release);
return Err(failure.error.lock().take().expect("one-shot physical fault owns its error"));
return Err(io::Error::new(failure.kind, "injected native physical syscall failure"));
}
Ok(())
}
@@ -4965,6 +4962,15 @@ pub(crate) fn rename_source_is_missing(src_file_path: &Path, _publication_root:
matches!(std::fs::symlink_metadata(src_file_path), Err(err) if err.kind() == io::ErrorKind::NotFound)
}
async fn reliable_rename(
src_file_path: impl AsRef<Path>,
dst_file_path: impl AsRef<Path>,
base_dir: impl AsRef<Path>,
publication_root: &PublicationRoot,
) -> io::Result<()> {
reliable_rename_inner(src_file_path, dst_file_path, base_dir, publication_root, true).await
}
async fn reliable_rename_inner(
src_file_path: impl AsRef<Path>,
dst_file_path: impl AsRef<Path>,
@@ -8070,8 +8076,6 @@ pub(crate) fn read_multipart_source_metadata_in_pinned(
base: &Path,
publication_root: &PublicationRoot,
) -> io::Result<Vec<u8>> {
#[cfg(test)]
multipart_source_syscall_failures::check(multipart_source_syscall_failures::Stage::Read, &parent.join(name))?;
read_multipart_metadata_in_pinned(pinned, parent, name, base, publication_root, Some(16 * 1024 * 1024))
}
@@ -9161,7 +9165,7 @@ mod tests {
let dst_file_path = dst_file_path.as_ref();
let base_dir = base_dir.as_ref();
let publication_root = test_publication_root(&[src_file_path, dst_file_path, base_dir]);
super::rename_all_with_owner(src_file_path, dst_file_path, base_dir, &publication_root, None).await
super::rename_all(src_file_path, dst_file_path, base_dir, &publication_root).await
}
async fn rename_all_ignore_missing_source(
@@ -10006,7 +10010,7 @@ mod tests {
let configured_dst = configured_base.join("object");
std::fs::create_dir(&configured_base).expect("create bucket through configured root");
std::fs::write(&configured_src, b"configured").expect("write staged object through configured root");
super::rename_all_with_owner(&configured_src, &configured_dst, &configured_base, &publication_root, None)
super::rename_all(&configured_src, &configured_dst, &configured_base, &publication_root)
.await
.expect("publish a configured path relative to the pinned root");
assert_eq!(
@@ -10019,7 +10023,7 @@ mod tests {
let resolved_dst = resolved_base.join("object");
std::fs::create_dir(&resolved_base).expect("create bucket through resolved root");
std::fs::write(&resolved_src, b"resolved").expect("write staged object through resolved root");
super::rename_all_with_owner(&resolved_src, &resolved_dst, &resolved_base, &publication_root, None)
super::rename_all(&resolved_src, &resolved_dst, &resolved_base, &publication_root)
.await
.expect("publish a resolved path relative to the pinned root");
@@ -10439,7 +10443,7 @@ mod tests {
std::fs::write(&dst, b"uncommitted-metadata").expect("write metadata to replace");
let publication_root = PublicationRoot::new(temp_dir.path()).expect("open publication root above the object tree");
super::rename_all_with_owner(&src, &dst, &object_dir, &publication_root, None)
super::rename_all(&src, &dst, &object_dir, &publication_root)
.await
.expect("a rollback source below its destination parent must not conflict with its own guards");
-196
View File
@@ -1,196 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
//! Explicit instance binding at the physical disk boundary. Lock order is this
//! binding mutex, then the registry mutex; registry code never locks a disk.
use crate::runtime::usage_watch::{UsageWatchMutationGuard, UsageWatchRegistry};
use std::sync::{Arc, Mutex, Weak};
/// Existing-version replication status writes change neither size nor version
/// membership. Replication aggregates keep their existing maintenance cadence.
pub(crate) fn status_only_metadata_update(fi: &rustfs_filemeta::FileInfo, opts: &super::UpdateMetadataOpts) -> bool {
use rustfs_utils::http::*;
!opts.replace_user_metadata
&& opts.transition_reconcile.is_none()
&& !fi.metadata.is_empty()
&& fi.metadata.keys().all(|key| {
strip_internal_prefix_preserving_case(key).is_some_and(|suffix| {
[
SUFFIX_REPLICA_STATUS,
SUFFIX_REPLICA_TIMESTAMP,
SUFFIX_REPLICATION_STATUS,
SUFFIX_REPLICATION_TIMESTAMP,
SUFFIX_REPLICATION_GENERATION,
SUFFIX_REPLICATION_RESET,
SUFFIX_PURGESTATUS,
]
.iter()
.any(|known| suffix.eq_ignore_ascii_case(known))
})
})
}
#[derive(Default)]
struct BindingState {
registry: Option<Weak<UsageWatchRegistry>>,
unbound_inflight: u64,
prebinding_guard: Option<UsageWatchMutationGuard>,
conflicted: bool,
}
#[derive(Default)]
pub(crate) struct DiskUsageWatchBinding {
state: Mutex<BindingState>,
}
struct UnboundGuard(Arc<DiskUsageWatchBinding>);
impl Drop for UnboundGuard {
fn drop(&mut self) {
let mut state = self.0.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
if state.unbound_inflight != 0 {
state.unbound_inflight -= 1;
}
if state.unbound_inflight == 0 {
state.prebinding_guard = None;
}
}
}
impl DiskUsageWatchBinding {
pub(crate) fn mark_uncovered_user_stream(&self, bucket: &str) {
if crate::bucket::utils::is_meta_bucketname(bucket) {
return;
}
let mut state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
state.conflicted = true;
if let Some(registry) = state.registry.as_ref().and_then(Weak::upgrade) {
registry.mark_coverage_unavailable();
}
}
pub(crate) fn bind(&self, registry: &Arc<UsageWatchRegistry>) {
let mut state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
if let Some(existing) = state.registry.as_ref().and_then(Weak::upgrade) {
if !Arc::ptr_eq(&existing, registry) {
state.conflicted = true;
// A query may already have checked this binding before
// awaiting disk metadata. Never allow it to reinstall a
// proof after this permanently ambiguous ownership change.
existing.mark_coverage_unavailable();
registry.mark_coverage_unavailable();
}
return;
}
// A newly registered disk can have pre-registration physical tails.
// Keep the whole registry Unknown until those exact guards drain.
if state.unbound_inflight != 0 {
state.prebinding_guard = Some(registry.begin(None));
}
if state.conflicted {
registry.mark_coverage_unavailable();
}
state.registry = Some(Arc::downgrade(registry));
}
pub(crate) fn matches(&self, registry: &Arc<UsageWatchRegistry>) -> bool {
let state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
!state.conflicted
&& state
.registry
.as_ref()
.and_then(Weak::upgrade)
.is_some_and(|bound| Arc::ptr_eq(&bound, registry))
}
pub(crate) fn owner(self: &Arc<Self>, bucket: &str, parent: Option<Arc<dyn Send + Sync>>) -> Option<Arc<dyn Send + Sync>> {
if crate::bucket::utils::is_meta_bucketname(bucket) {
return parent;
}
let mut state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
let guard: Arc<dyn Send + Sync> = if let Some(registry) = state.registry.as_ref().and_then(Weak::upgrade) {
Arc::new(registry.begin((!state.conflicted).then_some(bucket)))
} else {
match state.unbound_inflight.checked_add(1) {
Some(count) => state.unbound_inflight = count,
None => state.conflicted = true,
}
Arc::new(UnboundGuard(Arc::clone(self)))
};
Some(match parent {
Some(parent) => Arc::new((parent, guard)),
None => guard,
})
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::runtime::usage_watch::ScannerUsageWatchRequest;
use uuid::Uuid;
#[test]
fn binding_preserves_mutations_that_started_before_registration() {
let binding = Arc::new(DiskUsageWatchBinding::default());
let registry = Arc::new(UsageWatchRegistry::default());
let tail = binding.owner("bucket", None);
binding.bind(&registry);
assert!(binding.matches(&registry));
let request = ScannerUsageWatchRequest {
bucket: "bucket".into(),
bucket_incarnation: Uuid::from_u128(2),
watch_id: None,
release: false,
session_id: None,
};
assert_eq!(registry.observe(Uuid::from_u128(1), &request), None);
drop(tail);
assert_eq!(
registry
.observe(Uuid::from_u128(1), &request)
.expect("drained binding")
.inflight,
0
);
}
#[test]
fn composite_owner_and_instance_conflicts_fail_closed() {
let binding = Arc::new(DiskUsageWatchBinding::default());
let registry = Arc::new(UsageWatchRegistry::default());
binding.bind(&registry);
let request = ScannerUsageWatchRequest {
bucket: "bucket".into(),
bucket_incarnation: Uuid::from_u128(2),
watch_id: None,
release: false,
session_id: None,
};
registry.observe(Uuid::from_u128(1), &request).expect("initial watch");
let owner = binding.owner("bucket", None).expect("physical owner");
let nested = binding.owner("bucket", Some(owner));
assert_eq!(
registry
.observe(Uuid::from_u128(1), &request)
.expect("both operations active")
.inflight,
2
);
drop(nested);
assert_eq!(
registry
.observe(Uuid::from_u128(1), &request)
.expect("drained owners")
.inflight,
0
);
let other = Arc::new(UsageWatchRegistry::default());
binding.bind(&other);
assert!(!binding.matches(&registry));
assert!(!binding.matches(&other));
assert_eq!(registry.observe(Uuid::from_u128(1), &request), None);
assert_eq!(other.observe(Uuid::from_u128(1), &request), None);
}
}
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// SAFETY: raw arena memory. The block handle owns a pointer into registered
// memory (see `ArenaBlock::new` for the contract) and implements `BufMut` the
// way `Vec<u8>` does.
// Raw arena memory: the block handle owns a pointer into registered memory
// (see `ArenaBlock::new` for the contract) and implements `BufMut` the way
// `Vec<u8>` does.
#![allow(unsafe_code)]
//! Shard buffers for the erasure read path.
@@ -789,13 +789,6 @@ impl BitrotWriter<CustomWriter> {
}
self.write(&buf).await.map(|n| (n, None))
}
pub(crate) fn set_pending_integrity_index(&mut self, idx_file_name: &str, idx_payload: bytes::Bytes) -> bool {
if let Some(local) = self.inner.as_lazy_local_file_writer_mut() {
return local.set_pending_integrity_index(idx_file_name, idx_payload);
}
false
}
}
/// Read into `buf` until it is full or the reader hits EOF, returning the number
@@ -1187,10 +1180,6 @@ impl BitrotWriterWrapper {
self.bitrot_writer.shutdown().await
}
pub(crate) fn set_pending_integrity_index(&mut self, idx_file_name: &str, idx_payload: bytes::Bytes) -> bool {
self.bitrot_writer.set_pending_integrity_index(idx_file_name, idx_payload)
}
/// Extract the inline buffer data, consuming the wrapper
pub fn into_inline_data(self) -> Option<bytes::Bytes> {
match self.writer_type {
+3 -33
View File
@@ -653,36 +653,6 @@ impl<'a> MultiWriter<'a> {
}
}
pub(crate) async fn finish_and_shutdown(&mut self, total: usize) -> std::io::Result<()> {
let mut prewritten = Vec::new();
if let Some(integrity) = self.integrity.as_deref_mut() {
let prepared = integrity.prepare(total).await?;
if let Some(idx_bytes) = prepared.memory_bytes() {
let idx_name = prepared.part.file_name();
prewritten.resize(self.writers.len(), false);
for (index, (writer_opt, err)) in self.writers.iter_mut().zip(self.errs.iter()).enumerate() {
if err.is_none()
&& let Some(writer) = writer_opt.as_mut()
{
prewritten[index] = writer.set_pending_integrity_index(&idx_name, idx_bytes.clone());
}
}
}
}
self.shutdown().await?;
if let Some(integrity) = self.integrity.take()
&& !prewritten.is_empty()
{
for (index, slot) in prewritten.iter_mut().enumerate() {
if self.errs[index].is_some() || self.writers[index].is_none() {
*slot = false;
}
}
integrity.set_prewritten_disks(prewritten);
}
Ok(())
}
pub async fn shutdown(&mut self) -> std::io::Result<()> {
crate::hp_guard!("MultiWriter::shutdown");
let budget = self.next_progress_budget();
@@ -896,7 +866,7 @@ impl Erasure {
let mut mw = MultiWriter::new(writers, write_policy);
mw.integrity = integrity;
mw.write_block(&block).await?;
mw.finish_and_shutdown(total).await?;
mw.shutdown().await?;
Ok((reader, total))
}
@@ -1116,7 +1086,7 @@ impl Erasure {
let (reader, total) = task.join().await??;
let shutdown_stage_start = stage_timer_if_enabled();
writers.finish_and_shutdown(total).await?;
writers.shutdown().await?;
record_internal_stage_if_enabled("erasure_encode_shutdown", shutdown_stage_start);
Ok((reader, total))
}
@@ -1262,7 +1232,7 @@ impl Erasure {
let (reader, total) = task.join().await??;
let shutdown_stage_start = stage_timer_if_enabled();
writers.finish_and_shutdown(total).await?;
writers.shutdown().await?;
record_internal_stage_if_enabled("erasure_encode_batched_shutdown", shutdown_stage_start);
Ok((reader, total))
}
@@ -40,7 +40,6 @@ pub(crate) struct IntegrityBuilder {
part: PartIntegrity,
rows: Vec<u8>,
spill: Option<tokio::fs::File>,
prepared: Option<Box<PreparedIntegrity>>,
}
impl IntegrityBuilder {
@@ -49,7 +48,6 @@ impl IntegrityBuilder {
part: PartIntegrity::new(layout, number).map_err(|_| corrupt())?,
rows: Vec::new(),
spill: None,
prepared: None,
})
}
@@ -102,47 +100,28 @@ impl IntegrityBuilder {
Ok(())
}
async fn take_spool(&mut self) -> io::Result<Spool> {
let rows = std::mem::take(&mut self.rows);
if let Some(mut file) = self.spill.take() {
file.write_all(&rows).await?;
async fn into_spool(self) -> io::Result<Spool> {
if let Some(mut file) = self.spill {
file.write_all(&self.rows).await?;
file.flush().await?;
Ok(Spool::File(file.into_std().await))
} else {
Ok(Spool::Memory(rows))
}
}
pub(crate) async fn prepare(&mut self, size: usize) -> io::Result<&mut PreparedIntegrity> {
if self.prepared.is_none() {
self.part.size = size.try_into().map_err(|_| corrupt())?;
self.part.validate().map_err(|_| corrupt())?;
let part = self.part.clone();
let rows = self.take_spool().await?;
let prepared = if part.stripes < 16 {
build_index(part, rows)?
} else {
tokio::task::spawn_blocking(move || build_index(part, rows))
.await
.map_err(io::Error::other)??
};
self.prepared = Some(Box::new(prepared));
}
self.prepared.as_deref_mut().ok_or_else(corrupt)
}
pub(crate) fn set_prewritten_disks(&mut self, prewritten_disks: Vec<bool>) {
if let Some(prepared) = self.prepared.as_deref_mut() {
prepared.set_prewritten_disks(prewritten_disks);
Ok(Spool::Memory(self.rows))
}
}
pub(crate) async fn finish(mut self, size: usize) -> io::Result<PreparedIntegrity> {
if let Some(prepared) = self.prepared {
return Ok(*prepared);
self.part.size = size.try_into().map_err(|_| corrupt())?;
self.part.validate().map_err(|_| corrupt())?;
let part = self.part.clone();
let rows = self.into_spool().await?;
if part.stripes < 16 {
build_index(part, rows)
} else {
tokio::task::spawn_blocking(move || build_index(part, rows))
.await
.map_err(io::Error::other)?
}
self.prepare(size).await?;
self.prepared.map(|p| *p).ok_or_else(corrupt)
}
}
@@ -234,17 +213,12 @@ fn build_index(mut part: PartIntegrity, mut rows: Spool) -> io::Result<PreparedI
position >>= 1;
}
}
Ok(PreparedIntegrity {
part,
index,
prewritten_disks: Vec::new(),
})
Ok(PreparedIntegrity { part, index })
}
pub(crate) struct PreparedIntegrity {
pub(crate) part: PartIntegrity,
index: Spool,
prewritten_disks: Vec<bool>,
}
impl PreparedIntegrity {
@@ -253,30 +227,16 @@ impl PreparedIntegrity {
part: proof.part.clone(),
rows: proof.part.index_header().to_vec(),
spill: None,
prepared: None,
};
for stripe in 0..proof.part.stripes {
builder.append(&proof.record(stripe).await?).await?;
}
let index = builder.take_spool().await?;
let index = builder.into_spool().await?;
Ok(Self {
part: proof.part.clone(),
index,
prewritten_disks: Vec::new(),
})
}
pub(crate) fn memory_bytes(&self) -> Option<Bytes> {
match &self.index {
Spool::Memory(bytes) => Some(Bytes::copy_from_slice(bytes)),
Spool::File(_) => None,
}
}
pub(crate) fn set_prewritten_disks(&mut self, prewritten_disks: Vec<bool>) {
self.prewritten_disks = prewritten_disks;
}
pub(crate) fn inline_bytes(&self) -> io::Result<Bytes> {
match &self.index {
Spool::Memory(bytes) if bytes.len() <= MAX_INLINE_PROOF_BYTES => Ok(Bytes::copy_from_slice(bytes)),
@@ -307,23 +267,11 @@ impl PreparedIntegrity {
let path = format!("{directory}/{}", self.part.file_name());
let mut file = match self.index {
Spool::Memory(bytes) => {
if disks
.iter()
.enumerate()
.all(|(idx, disk)| disk.is_none() || self.prewritten_disks.get(idx).copied().unwrap_or(false))
{
return Ok(self.part);
}
let payload = Bytes::from(bytes);
let prewritten_disks = &self.prewritten_disks;
futures::future::join_all(disks.iter_mut().enumerate().map(|(idx, disk_opt)| {
futures::future::join_all(disks.iter_mut().map(|disk_opt| {
let path = &path;
let payload = payload.clone();
let already_written = prewritten_disks.get(idx).copied().unwrap_or(false);
async move {
if already_written {
return;
}
let Some(disk) = disk_opt.as_ref() else {
return;
};
-2
View File
@@ -101,7 +101,6 @@ pub(crate) fn legacy_encrypted_range_seek_enabled() -> bool {
mod body_cache_hook;
mod encryption;
mod hook_slot;
mod multipart_completion_binding;
mod object_mutation_hook;
mod read_condition;
mod readers;
@@ -127,7 +126,6 @@ pub use encryption::{
EncryptionResolutionError, EncryptionResolutionErrorKind, ObjectEncryptionResolver, ReadEncryptionMaterial,
ReadEncryptionMode, ReadEncryptionRequest,
};
pub use multipart_completion_binding::MultipartCompletionBinding;
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::*;
@@ -1,79 +0,0 @@
// Copyright 2026 RustFS Team
// SPDX-License-Identifier: Apache-2.0
//! Read-only upload ownership evidence for completion callers, not publication authority.
//! ECStore supplies validated records; completion still rechecks its locked storage state.
use crate::storage_api_contracts::multipart::MultipartInfo;
/// A storage observation of the namespace belonging to an upload.
///
/// This does not reserve an upload or authorize publication. Abort, completion,
/// bucket recreation, and replacement can invalidate it before completion runs.
#[derive(Clone)]
pub struct MultipartCompletionBinding {
bucket: String,
object: String,
active_info: Option<MultipartInfo>,
}
impl MultipartCompletionBinding {
pub(crate) fn active(info: MultipartInfo) -> Self {
Self {
bucket: info.bucket.clone(),
object: info.object.clone(),
active_info: Some(info),
}
}
pub(crate) fn recorded(bucket: &str, object: &str) -> Self {
Self {
bucket: bucket.to_owned(),
object: rustfs_utils::path::decode_dir_object(object),
active_info: None,
}
}
/// The bucket identified by the storage observation.
pub fn bucket(&self) -> &str {
&self.bucket
}
/// The decoded object key identified by the storage observation.
pub fn object(&self) -> &str {
&self.object
}
/// Metadata from an ordinary active lookup, when that lookup succeeded.
/// Completed and retained records never supply active preflight metadata.
pub fn active_info(&self) -> Option<&MultipartInfo> {
self.active_info.as_ref()
}
}
impl std::fmt::Debug for MultipartCompletionBinding {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter
.debug_struct("MultipartCompletionBinding")
.field("bucket", &self.bucket)
.field("object", &self.object)
.field("has_active_info", &self.active_info.is_some())
.finish()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn completion_binding_debug_excludes_preflight_metadata() {
let binding = MultipartCompletionBinding::active(MultipartInfo {
user_defined: [("test-marker".to_owned(), "private-preflight-sentinel".to_owned())].into(),
..Default::default()
});
let debug = format!("{binding:?}");
assert!(!debug.contains("private-preflight-sentinel"));
assert!(debug.contains("has_active_info: true"));
}
}
-13
View File
@@ -99,7 +99,6 @@ pub(crate) struct ScannerPublicationLeaseEntry {
pub(crate) struct NamespaceCommitGuard {
ctx: Arc<InstanceContext>,
counted: bool,
_usage_watch: super::usage_watch::UsageWatchMutationGuard,
}
impl Drop for NamespaceCommitGuard {
@@ -372,7 +371,6 @@ pub struct InstanceContext {
scanner_publication_state: AtomicU8,
namespace_commits: AtomicU64,
namespace_commit_generation: AtomicU64,
pub(crate) usage_watches: Arc<super::usage_watch::UsageWatchRegistry>,
/// Resolves object-encryption material at the application boundary.
object_encryption_resolver: OnceLock<Arc<dyn ObjectEncryptionResolver>>,
delete_recovery_hints: DeleteRecoveryHints,
@@ -498,7 +496,6 @@ impl InstanceContext {
scanner_publication_state: AtomicU8::new(SCANNER_PUBLICATION_STATE_UNKNOWN),
namespace_commits: AtomicU64::new(0),
namespace_commit_generation: AtomicU64::new(0),
usage_watches: Arc::new(super::usage_watch::UsageWatchRegistry::default()),
object_encryption_resolver: OnceLock::new(),
delete_recovery_hints: DeleteRecoveryHints::default(),
tier_delete_journal_recovery_stores: std::sync::Mutex::new(HashSet::new()),
@@ -738,15 +735,6 @@ impl InstanceContext {
}
pub(crate) fn begin_namespace_commit(self: &Arc<Self>) -> Arc<NamespaceCommitGuard> {
self.begin_namespace_commit_scoped(None)
}
pub(crate) fn begin_namespace_commit_for_bucket(self: &Arc<Self>, bucket: &str) -> Arc<NamespaceCommitGuard> {
self.begin_namespace_commit_scoped(Some(bucket))
}
fn begin_namespace_commit_scoped(self: &Arc<Self>, bucket: Option<&str>) -> Arc<NamespaceCommitGuard> {
let usage_watch = self.usage_watches.begin(bucket);
let counted = self
.namespace_commits
.try_update(Ordering::AcqRel, Ordering::Acquire, |count| count.checked_add(1))
@@ -759,7 +747,6 @@ impl InstanceContext {
Arc::new(NamespaceCommitGuard {
ctx: Arc::clone(self),
counted,
_usage_watch: usage_watch,
})
}
-1
View File
@@ -17,4 +17,3 @@
pub(crate) mod global;
pub(crate) mod instance;
pub(crate) mod sources;
pub(crate) mod usage_watch;
-4
View File
@@ -525,9 +525,6 @@ pub(crate) async fn record_local_disks(instance_ctx: &Arc<InstanceContext>, disk
let map = instance_ctx.local_disk_map();
let mut global_local_disk_map = map.write().await;
for disk in disks {
if let crate::disk::Disk::Local(wrapper) = disk.as_ref() {
wrapper.get_disk().usage_watch_binding.bind(&instance_ctx.usage_watches);
}
let path = disk.endpoint().to_string();
global_local_disk_map.insert(path, Some(disk));
}
@@ -614,7 +611,6 @@ pub(crate) async fn initialize_local_disk_maps(
Err(err) => return Err(err.into()),
};
if let crate::disk::Disk::Local(wrapper) = disk.as_ref() {
wrapper.get_disk().usage_watch_binding.bind(&instance_ctx.usage_watches);
wrapper.get_disk().bind_multipart_proof_authority(&multipart_authority)?;
}
let path = disk.endpoint().to_string();
-334
View File
@@ -1,334 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
//! Bounded, same-session bucket mutation watches. The registry lock is a short
//! synchronous critical section shared by installation, mutation begin/end,
//! and observation. No I/O or await occurs while it is held.
use std::{
collections::HashMap,
sync::{Arc, Mutex},
time::{Duration, Instant},
};
use uuid::Uuid;
pub const SCANNER_USAGE_WATCH_COVERAGE_VERSION: u32 = rustfs_protos::usage_watch::USAGE_WATCH_COVERAGE_VERSION;
pub const SCANNER_USAGE_WATCH_MAX_ENTRIES: usize = 256;
pub const SCANNER_USAGE_WATCH_MAX_ACTIVE_BUCKETS: usize = 4096;
pub const SCANNER_USAGE_WATCH_MAX_NAME_BYTES: usize = 16 * 1024;
pub const SCANNER_USAGE_WATCH_MAX_ACTIVE_NAME_BYTES: usize = 256 * 1024;
pub const SCANNER_USAGE_WATCH_LEASE_MS: u64 = rustfs_protos::usage_watch::USAGE_WATCH_MAX_LEASE_MS;
/// A missing watch ID installs a new watch; a supplied ID can only refresh the
/// exact, still-live token. An expired token never silently creates a new one.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct ScannerUsageWatchRequest {
pub bucket: String,
pub bucket_incarnation: Uuid,
pub watch_id: Option<Uuid>,
/// Release only this exact producer session and token after publication.
pub release: bool,
pub session_id: Option<Uuid>,
}
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct ScannerUsageWatchKnown {
pub owner_id: Uuid,
pub session_id: Uuid,
pub watch_id: Uuid,
pub bucket_incarnation: Uuid,
pub revision: u64,
pub inflight: u64,
pub coverage_version: u32,
pub coverage_epoch: u64,
/// Duration from the receiver's observation, never a wall-clock deadline.
pub lease_remaining_ms: u64,
}
impl ScannerUsageWatchKnown {
pub fn is_well_formed(&self) -> bool {
!self.owner_id.is_nil()
&& !self.session_id.is_nil()
&& !self.watch_id.is_nil()
&& !self.bucket_incarnation.is_nil()
&& self.revision != 0
&& self.revision != u64::MAX
&& self.inflight != u64::MAX
&& self.coverage_version == SCANNER_USAGE_WATCH_COVERAGE_VERSION
&& self.coverage_epoch != 0
&& self.coverage_epoch != u64::MAX
&& self.lease_remaining_ms != 0
&& self.lease_remaining_ms <= SCANNER_USAGE_WATCH_LEASE_MS
}
/// Equality of stable proof fields; the caller must also respect its
/// conservative local lease deadline and validate the source/owner set.
pub fn unchanged_since(&self, earlier: &Self) -> bool {
self.is_well_formed()
&& earlier.is_well_formed()
&& self.owner_id == earlier.owner_id
&& self.session_id == earlier.session_id
&& self.watch_id == earlier.watch_id
&& self.bucket_incarnation == earlier.bucket_incarnation
&& self.revision == earlier.revision
&& self.inflight == 0
&& earlier.inflight == 0
&& self.coverage_version == SCANNER_USAGE_WATCH_COVERAGE_VERSION
&& self.coverage_version == earlier.coverage_version
&& self.coverage_epoch == earlier.coverage_epoch
&& self.lease_remaining_ms != 0
&& earlier.lease_remaining_ms != 0
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ScannerUsageWatchObservation {
pub bucket: String,
/// Missing means Unknown. It is never a revision-zero clean value.
pub known: Option<ScannerUsageWatchKnown>,
}
struct Watch {
owner: Uuid,
token: Uuid,
incarnation: Uuid,
revision: u64,
expires_at: Instant,
}
#[derive(Default)]
struct State {
watches: HashMap<Arc<str>, Watch>,
active: HashMap<Arc<str>, u64>,
watch_name_bytes: usize,
active_name_bytes: usize,
untracked: u64,
exhausted: bool,
coverage_epoch: u64,
}
pub(crate) struct UsageWatchRegistry {
session: Uuid,
state: Mutex<State>,
}
enum Mutation {
Tracked(Arc<str>),
Untracked,
}
/// The physical mutation owner retains this value through all detached tails.
pub(crate) struct UsageWatchMutationGuard {
registry: Arc<UsageWatchRegistry>,
mutation: Mutation,
}
impl Default for UsageWatchRegistry {
fn default() -> Self {
Self {
session: Uuid::new_v4(),
state: Mutex::new(State {
coverage_epoch: 1,
..Default::default()
}),
}
}
}
impl State {
fn invalidate_all(&mut self) {
self.watches.clear();
self.watch_name_bytes = 0;
match self.coverage_epoch.checked_add(1).filter(|epoch| *epoch != u64::MAX) {
Some(epoch) => self.coverage_epoch = epoch,
None => self.exhausted = true,
}
}
fn advance_bucket(&mut self, bucket: &str) {
if let Some(watch) = self.watches.get_mut(bucket) {
if let Some(next) = watch.revision.checked_add(1).filter(|next| *next != u64::MAX) {
watch.revision = next;
} else {
self.remove_watch(bucket);
}
}
}
fn remove_watch(&mut self, bucket: &str) {
if let Some((name, _)) = self.watches.remove_entry(bucket) {
self.watch_name_bytes -= name.len();
}
}
}
impl UsageWatchRegistry {
pub(crate) fn session_id(&self) -> Uuid {
self.session
}
pub(crate) fn begin(self: &Arc<Self>, bucket: Option<&str>) -> UsageWatchMutationGuard {
let mut state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
// Internal metadata is outside the user bucket counters. Callers with
// an unknown user scope must pass None, which invalidates every watch.
let bucket = bucket.filter(|bucket| !bucket.is_empty() && bucket.len() <= 63);
let tracked = bucket.and_then(|bucket| {
if let Some((key, count)) = state.active.get_key_value(bucket) {
let key = Arc::clone(key);
let next = count.checked_add(1)?;
state.active.insert(Arc::clone(&key), next);
return Some(key);
}
if state.active.len() >= SCANNER_USAGE_WATCH_MAX_ACTIVE_BUCKETS
|| state.active_name_bytes + bucket.len() > SCANNER_USAGE_WATCH_MAX_ACTIVE_NAME_BYTES
{
return None;
}
let key: Arc<str> = Arc::from(bucket);
state.active_name_bytes += bucket.len();
state.active.insert(Arc::clone(&key), 1);
Some(key)
});
let mutation = match tracked {
Some(bucket) => {
state.advance_bucket(&bucket);
Mutation::Tracked(bucket)
}
None => {
state.invalidate_all();
match state.untracked.checked_add(1) {
Some(count) => state.untracked = count,
None => state.exhausted = true,
}
Mutation::Untracked
}
};
UsageWatchMutationGuard {
registry: Arc::clone(self),
mutation,
}
}
/// Replay and unsupported runtime mode transitions revoke tokens. They
/// never copy a durable generation into a same-session watch revision.
pub(crate) fn invalidate(&self) {
self.state
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner())
.invalidate_all();
}
/// A write mode without a physical completion owner cannot establish
/// same-session coverage again. Keep the global fallback until restart.
pub(crate) fn mark_coverage_unavailable(&self) {
let mut state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
state.exhausted = true;
state.invalidate_all();
}
pub(crate) fn observe(&self, owner: Uuid, request: &ScannerUsageWatchRequest) -> Option<ScannerUsageWatchKnown> {
self.observe_at(owner, request, Instant::now())
}
fn observe_at(&self, owner: Uuid, request: &ScannerUsageWatchRequest, now: Instant) -> Option<ScannerUsageWatchKnown> {
if owner.is_nil() || request.bucket_incarnation.is_nil() || request.bucket.is_empty() || request.bucket.len() > 63 {
return None;
}
let mut state = self.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
if request.release {
if request.session_id == Some(self.session)
&& state.watches.get(request.bucket.as_str()).is_some_and(|watch| {
watch.owner == owner
&& watch.incarnation == request.bucket_incarnation
&& request.watch_id == Some(watch.token)
})
{
state.remove_watch(&request.bucket);
}
// Release is resource retirement, never an assertion of cleanliness.
return None;
}
if request.session_id.is_some_and(|session| session != self.session) {
return None;
}
if state.exhausted || state.untracked != 0 {
return None;
}
// Sweeps are bounded by the fixed watch limit. Never accumulate tombstones.
state.watches.retain(|_, watch| watch.expires_at > now);
state.watch_name_bytes = state.watches.keys().map(|key| key.len()).sum();
let matches = state.watches.get(request.bucket.as_str()).is_some_and(|watch| {
watch.owner == owner
&& watch.incarnation == request.bucket_incarnation
&& request.watch_id.is_none_or(|id| id == watch.token)
});
if !matches {
if request.watch_id.is_some() {
return None;
}
state.remove_watch(&request.bucket);
if state.watches.len() >= SCANNER_USAGE_WATCH_MAX_ENTRIES
|| state.watch_name_bytes + request.bucket.len() > SCANNER_USAGE_WATCH_MAX_NAME_BYTES
{
return None;
}
let key: Arc<str> = Arc::from(request.bucket.as_str());
state.watch_name_bytes += key.len();
state.watches.insert(
key,
Watch {
owner,
token: Uuid::new_v4(),
incarnation: request.bucket_incarnation,
revision: 1,
expires_at: now + Duration::from_millis(SCANNER_USAGE_WATCH_LEASE_MS),
},
);
}
let inflight = state.active.get(request.bucket.as_str()).copied().unwrap_or(0);
let coverage_epoch = state.coverage_epoch;
let watch = state.watches.get_mut(request.bucket.as_str())?;
watch.expires_at = now + Duration::from_millis(SCANNER_USAGE_WATCH_LEASE_MS);
Some(ScannerUsageWatchKnown {
owner_id: owner,
session_id: self.session,
watch_id: watch.token,
bucket_incarnation: watch.incarnation,
revision: watch.revision,
inflight,
coverage_version: SCANNER_USAGE_WATCH_COVERAGE_VERSION,
coverage_epoch,
lease_remaining_ms: SCANNER_USAGE_WATCH_LEASE_MS,
})
}
}
impl Drop for UsageWatchMutationGuard {
fn drop(&mut self) {
let mut state = self.registry.state.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
match &self.mutation {
Mutation::Tracked(bucket) => {
// Advance before exposing inflight=0, including canceled and
// failed operations whose physical outcome may be uncertain.
state.advance_bucket(bucket);
if let Some(count) = state.active.get_mut(bucket) {
*count -= 1;
if *count == 0 {
state.active.remove(bucket);
state.active_name_bytes -= bucket.len();
}
} else {
state.exhausted = true;
state.invalidate_all();
}
}
Mutation::Untracked => {
if state.untracked != 0 {
state.untracked -= 1;
}
}
}
}
}
#[cfg(test)]
mod tests;
@@ -1,321 +0,0 @@
// Copyright 2026 RustFS Team
// Licensed under the Apache License, Version 2.0.
use super::*;
fn request(bucket: &str) -> ScannerUsageWatchRequest {
ScannerUsageWatchRequest {
bucket: bucket.into(),
bucket_incarnation: Uuid::from_u128(7),
watch_id: None,
release: false,
session_id: None,
}
}
fn query(registry: &UsageWatchRegistry, request: &ScannerUsageWatchRequest, at: Instant) -> ScannerUsageWatchKnown {
registry
.observe_at(Uuid::from_u128(1), request, at)
.expect("known bucket proof")
}
#[test]
fn watch_installation_detects_an_already_active_mutation() {
let registry = Arc::new(UsageWatchRegistry::default());
let now = Instant::now();
let mutation = registry.begin(Some("bucket"));
let before = query(&registry, &request("bucket"), now);
assert_eq!(before.inflight, 1);
drop(mutation);
let after = query(&registry, &request("bucket"), now);
assert_eq!(after.inflight, 0);
assert!(after.revision > before.revision);
assert!(!after.unchanged_since(&before));
}
#[test]
fn every_begin_and_physical_tail_end_advances_only_the_target_bucket() {
let registry = Arc::new(UsageWatchRegistry::default());
let now = Instant::now();
let before = query(&registry, &request("cold"), now);
let hot = registry.begin(Some("hot"));
assert!(query(&registry, &request("cold"), now).unchanged_since(&before));
drop(hot);
assert!(query(&registry, &request("cold"), now).unchanged_since(&before));
let owner = Arc::new(registry.begin(Some("cold")));
let physical_tail = Arc::clone(&owner);
let during = query(&registry, &request("cold"), now);
assert_eq!(during.revision, before.revision + 1);
assert_eq!(during.inflight, 1);
drop(owner);
assert_eq!(query(&registry, &request("cold"), now).inflight, 1);
drop(physical_tail);
let after = query(&registry, &request("cold"), now);
assert_eq!(after.revision, before.revision + 2);
assert_eq!(after.inflight, 0);
}
#[test]
fn expiry_reincarnation_and_restart_do_not_resurrect_old_tokens() {
let registry = UsageWatchRegistry::default();
let now = Instant::now();
let before = query(&registry, &request("bucket"), now);
let mut refresh = request("bucket");
refresh.watch_id = Some(before.watch_id);
let expired = now + Duration::from_millis(SCANNER_USAGE_WATCH_LEASE_MS);
assert_eq!(registry.observe_at(Uuid::from_u128(1), &refresh, expired), None);
let after = query(&registry, &request("bucket"), expired);
assert_ne!(after.watch_id, before.watch_id);
assert!(!after.unchanged_since(&before));
refresh.bucket_incarnation = Uuid::new_v4();
assert_eq!(registry.observe_at(Uuid::from_u128(1), &refresh, expired), None);
refresh.watch_id = None;
let recreated = query(&registry, &refresh, expired);
assert_ne!(recreated.watch_id, after.watch_id);
let restarted = UsageWatchRegistry::default();
let restart_proof = query(&restarted, &refresh, expired);
assert!(!restart_proof.unchanged_since(&recreated));
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-12", "assertion_id": "USAGE-12-A05", "status": "PASS",
"evidence": {"expired_token": before.watch_id, "replacement_token": after.watch_id, "lease_ms": SCANNER_USAGE_WATCH_LEASE_MS, "expired_proof_accepted": false}
})
);
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-12", "assertion_id": "USAGE-12-A06", "status": "PASS",
"evidence": {"previous_session": recreated.session_id, "new_session": restart_proof.session_id, "unchanged": restart_proof.unchanged_since(&recreated)}
})
);
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-12", "status": "PASS", "scope": "process-local"})
);
}
#[test]
fn watch_capacity_is_bounded_and_rejected_entries_are_unknown() {
let registry = UsageWatchRegistry::default();
let now = Instant::now();
for index in 0..SCANNER_USAGE_WATCH_MAX_ENTRIES {
query(&registry, &request(&format!("bucket-{index}")), now);
}
assert_eq!(registry.observe_at(Uuid::from_u128(1), &request("overflow"), now), None);
let state = registry.state.lock().expect("registry state");
assert_eq!(state.watches.len(), SCANNER_USAGE_WATCH_MAX_ENTRIES);
assert!(state.watch_name_bytes <= SCANNER_USAGE_WATCH_MAX_NAME_BYTES);
}
#[test]
fn active_mutation_overflow_revokes_all_proofs_until_untracked_work_ends() {
let registry = Arc::new(UsageWatchRegistry::default());
let now = Instant::now();
let old = query(&registry, &request("cold"), now);
let mut active = Vec::new();
for index in 0..SCANNER_USAGE_WATCH_MAX_ACTIVE_BUCKETS {
active.push(registry.begin(Some(&format!("active-{index}"))));
}
let overflow = registry.begin(Some("not-in-active-map"));
assert_eq!(registry.observe_at(Uuid::from_u128(1), &request("cold"), now), None);
{
let state = registry.state.lock().expect("registry state");
assert_eq!(state.active.len(), SCANNER_USAGE_WATCH_MAX_ACTIVE_BUCKETS);
assert!(state.active_name_bytes <= SCANNER_USAGE_WATCH_MAX_ACTIVE_NAME_BYTES);
}
drop(overflow);
let new = query(&registry, &request("cold"), now);
assert_ne!(new.watch_id, old.watch_id);
assert!(new.coverage_epoch > old.coverage_epoch);
drop(active);
println!(
"usage_assertion: {}",
serde_json::json!({
"case_id": "USAGE-12", "assertion_id": "USAGE-12-A04", "status": "PASS",
"evidence": {"active_capacity": SCANNER_USAGE_WATCH_MAX_ACTIVE_BUCKETS, "previous_token": old.watch_id, "replacement_token": new.watch_id, "previous_coverage": old.coverage_epoch, "new_coverage": new.coverage_epoch, "active_after_cleanup": registry.state.lock().expect("drained registry").active.len()}
})
);
println!(
"usage_cleanup: {}",
serde_json::json!({"case_id": "USAGE-12", "status": "PASS", "scope": "process-local"})
);
}
#[test]
fn unknown_scope_and_replay_invalidate_without_reusing_generation() {
let registry = Arc::new(UsageWatchRegistry::default());
let now = Instant::now();
let old = query(&registry, &request("bucket"), now);
let mutation = registry.begin(None);
assert_eq!(registry.observe_at(Uuid::from_u128(1), &request("bucket"), now), None);
drop(mutation);
let new = query(&registry, &request("bucket"), now);
assert_ne!(new.watch_id, old.watch_id);
registry.invalidate();
let replayed = query(&registry, &request("bucket"), now);
assert_ne!(replayed.watch_id, new.watch_id);
assert!(replayed.coverage_epoch > new.coverage_epoch);
}
#[test]
fn revision_exhaustion_invalidates_the_token_without_aba() {
let registry = Arc::new(UsageWatchRegistry::default());
let now = Instant::now();
let old = query(&registry, &request("bucket"), now);
registry
.state
.lock()
.expect("registry state")
.watches
.get_mut("bucket")
.expect("installed watch")
.revision = u64::MAX - 1;
let mutation = registry.begin(Some("bucket"));
let refresh = ScannerUsageWatchRequest {
watch_id: Some(old.watch_id),
..request("bucket")
};
assert_eq!(registry.observe_at(Uuid::from_u128(1), &refresh, now), None);
let during = query(&registry, &request("bucket"), now);
assert_ne!(during.watch_id, old.watch_id);
assert_eq!(during.inflight, 1);
drop(mutation);
assert_eq!(query(&registry, &request("bucket"), now).revision, during.revision + 1);
}
#[test]
fn coverage_epoch_exhaustion_stays_unknown_without_wrapping() {
let registry = UsageWatchRegistry::default();
let now = Instant::now();
query(&registry, &request("bucket"), now);
registry.state.lock().expect("registry state").coverage_epoch = u64::MAX - 1;
registry.invalidate();
assert_eq!(registry.observe_at(Uuid::from_u128(1), &request("bucket"), now), None);
registry.invalidate();
assert_eq!(registry.observe_at(Uuid::from_u128(1), &request("bucket"), now), None);
let state = registry.state.lock().expect("registry state");
assert!(state.exhausted);
assert!(state.watches.is_empty());
assert_eq!(state.coverage_epoch, u64::MAX - 1);
}
#[test]
fn proof_comparison_rejects_every_changed_identity_and_busy_endpoint() {
let registry = UsageWatchRegistry::default();
let original = query(&registry, &request("bucket"), Instant::now());
for field in 0..10 {
let mut changed = original.clone();
match field {
0 => changed.owner_id = Uuid::new_v4(),
1 => changed.session_id = Uuid::new_v4(),
2 => changed.watch_id = Uuid::new_v4(),
3 => changed.bucket_incarnation = Uuid::new_v4(),
4 => changed.revision += 1,
5 => changed.inflight = 1,
6 => changed.coverage_version += 1,
7 => changed.coverage_epoch += 1,
8 => changed.lease_remaining_ms = 0,
_ => {
changed.revision = 0;
changed.watch_id = Uuid::nil();
}
}
assert!(!changed.unchanged_since(&original));
}
}
#[test]
fn watch_contention_cost_preserves_all_mutation_boundaries() {
let registry = Arc::new(UsageWatchRegistry::default());
let before = query(&registry, &request("hot"), Instant::now());
let threads = 8_u64;
let writes_per_thread = 10_000_u64;
let started = Instant::now();
std::thread::scope(|scope| {
for _ in 0..threads {
let registry = Arc::clone(&registry);
scope.spawn(move || {
for _ in 0..writes_per_thread {
drop(registry.begin(Some("hot")));
}
});
}
});
let elapsed = started.elapsed();
let after = query(&registry, &request("hot"), Instant::now());
let writes = threads * writes_per_thread;
assert_eq!(after.revision, before.revision + 2 * writes);
assert_eq!(after.inflight, 0);
assert!(registry.state.lock().expect("drained registry").active.is_empty());
eprintln!(
"usage_watch_cost threads={threads} writes={writes} elapsed_us={} wall_ns_per_begin_end={}",
elapsed.as_micros(),
elapsed.as_nanos() / u128::from(writes)
);
}
#[test]
fn exact_release_preserves_other_sessions_tokens_and_active_mutations() {
let registry = Arc::new(UsageWatchRegistry::default());
let owner = Uuid::from_u128(1);
let now = Instant::now();
let before = query(&registry, &request("bucket"), now);
let release = ScannerUsageWatchRequest {
watch_id: Some(before.watch_id),
session_id: Some(before.session_id),
release: true,
..request("bucket")
};
for case in 0..5 {
let mut wrong = release.clone();
let mut wrong_owner = owner;
match case {
0 => wrong.watch_id = Some(Uuid::new_v4()),
1 => wrong.session_id = Some(Uuid::new_v4()),
2 => wrong.bucket_incarnation = Uuid::new_v4(),
3 => wrong.watch_id = None,
_ => wrong_owner = Uuid::new_v4(),
}
assert_eq!(registry.observe_at(wrong_owner, &wrong, now), None);
assert!(query(&registry, &request("bucket"), now).unchanged_since(&before));
}
let mutation = registry.begin(Some("bucket"));
assert_eq!(registry.observe_at(owner, &release, now), None);
assert!(registry.state.lock().expect("registry state").watches.is_empty());
let replacement = query(&registry, &request("bucket"), now);
assert_ne!(replacement.watch_id, before.watch_id);
assert_eq!(replacement.inflight, 1, "release cannot discard physical mutation ownership");
assert_eq!(registry.observe_at(owner, &release, now), None);
assert_eq!(query(&registry, &request("bucket"), now).watch_id, replacement.watch_id);
drop(mutation);
let after = query(&registry, &request("bucket"), now);
assert_eq!(after.inflight, 0);
assert!(after.revision > replacement.revision);
}
#[test]
fn completed_watch_release_admits_later_buckets_before_lease_expiry() {
let registry = UsageWatchRegistry::default();
let now = Instant::now();
let mut completed = Vec::new();
for index in 0..SCANNER_USAGE_WATCH_MAX_ENTRIES {
let req = request(&format!("bucket-{index:03}"));
let known = query(&registry, &req, now);
completed.push(ScannerUsageWatchRequest {
watch_id: Some(known.watch_id),
session_id: Some(known.session_id),
release: true,
..req
});
}
assert_eq!(registry.observe_at(Uuid::from_u128(1), &request("later-bucket"), now), None);
for release in completed {
assert_eq!(registry.observe_at(Uuid::from_u128(1), &release, now), None);
}
let state = registry.state.lock().expect("registry state");
assert_eq!(state.watches.len(), 0);
assert_eq!(state.watch_name_bytes, 0);
drop(state);
assert!(query(&registry, &request("later-bucket"), now).is_well_formed());
}
@@ -107,7 +107,7 @@ pub(super) async fn run(
result.state = ItemState::Prepared;
result.detail = None;
etag = checkpoint(api, job, &etag, guard).await?;
let staged = match verify_source(api, job, index, &info, &opts, guard).await {
let mut file = match stage(api, job, index, &info, &opts, guard).await {
Ok(file) => file,
Err(IntegrityError::Conflict) => {
job.results[index].state = ItemState::Stale;
@@ -125,7 +125,6 @@ pub(super) async fn run(
if job.request.mode == JobMode::Audit {
job.results[index].state = ItemState::Verified;
} else {
let mut file = staged.ok_or(IntegrityError::Invalid("missing migration payload"))?;
let snapshot = validate_destination(api, job).await?;
file.rewind().await?;
let raw = sha256_bytes(&expected)?;
@@ -232,29 +231,30 @@ async fn ensure_running(api: &Arc<ECStore>, job: &Job, guard: &rustfs_lock::Name
Ok(())
}
async fn verify_source(
async fn stage(
api: &Arc<ECStore>,
job: &Job,
index: usize,
info: &ObjectInfo,
opts: &ObjectOptions,
guard: &rustfs_lock::NamespaceLockGuard,
) -> Result<Option<tokio::fs::File>> {
) -> Result<tokio::fs::File> {
let mut reader = api
.get_object_reader(&job.bucket, &job.request.items[index].key, None, Default::default(), opts)
.await?;
if fingerprint(&reader.object_info) != fingerprint(info) {
return Err(IntegrityError::Conflict);
}
let mut file = staging_file(job.request.mode, tempfile::tempfile).await?;
let std_file = tokio::task::spawn_blocking(tempfile::tempfile)
.await
.map_err(|_| IntegrityError::Invalid("staging task failed"))??;
let mut file = tokio::fs::File::from_std(std_file);
let expected = job.results[index]
.expected_sha256
.as_deref()
.ok_or(IntegrityError::Invalid("missing expected digest"))?;
copy_verified(api, job, &mut reader.stream, file.as_mut(), info.size, expected, guard).await?;
if let Some(file) = file.as_mut() {
file.flush().await?;
}
copy_verified(api, job, &mut reader.stream, Some(&mut file), info.size, expected, guard).await?;
file.flush().await?;
let after = api.get_object_info(&job.bucket, &job.request.items[index].key, opts).await?;
if fingerprint(&after) != fingerprint(info) {
return Err(IntegrityError::Conflict);
@@ -262,20 +262,6 @@ async fn verify_source(
Ok(file)
}
async fn staging_file(
mode: JobMode,
create: impl FnOnce() -> std::io::Result<std::fs::File> + Send + 'static,
) -> Result<Option<tokio::fs::File>> {
// Migration must publish the exact bytes verified here. Audit has no second consumer.
if mode == JobMode::Audit {
return Ok(None);
}
let file = tokio::task::spawn_blocking(create)
.await
.map_err(|_| IntegrityError::Invalid("staging task failed"))??;
Ok(Some(tokio::fs::File::from_std(file)))
}
async fn copy_verified(
api: &Arc<ECStore>,
job: &Job,
@@ -480,31 +466,3 @@ impl tokio::io::AsyncRead for ThrottledFile {
}
}
}
#[cfg(test)]
mod staging_tests {
use super::*;
#[tokio::test]
async fn audit_does_not_need_a_writable_payload_staging_volume() {
let result = staging_file(JobMode::Audit, || Err(std::io::Error::other("staging volume full")))
.await
.expect("audit must not open staging storage");
assert!(result.is_none());
}
#[tokio::test]
async fn migration_requires_writable_payload_staging() {
assert!(
staging_file(JobMode::Migrate, || { Err(std::io::Error::other("staging volume full")) })
.await
.is_err()
);
let mut file = staging_file(JobMode::Migrate, tempfile::tempfile).await.unwrap().unwrap();
file.write_all(b"verified bytes").await.unwrap();
file.rewind().await.unwrap();
let mut bytes = Vec::new();
file.read_to_end(&mut bytes).await.unwrap();
assert_eq!(bytes, b"verified bytes");
}
}
@@ -3211,42 +3211,6 @@ impl NotificationSys {
Ok(true)
}
/// Query exactly the requested peers and buckets. Missing peers and old
/// protocol endpoints fail the query instead of fabricating clean entries.
pub async fn scanner_usage_watches(
&self,
requests: Vec<(String, uuid::Uuid, Vec<crate::runtime::usage_watch::ScannerUsageWatchRequest>)>,
) -> Result<Vec<(String, Vec<crate::runtime::usage_watch::ScannerUsageWatchObservation>)>> {
let clients = self
.peer_clients
.iter()
.flatten()
.map(|client| (client.grid_host.clone(), client.clone()))
.collect::<HashMap<_, _>>();
let mut seen = std::collections::HashSet::new();
let mut futures = Vec::with_capacity(requests.len());
for (host, owner, entries) in requests {
if !seen.insert(host.clone()) {
return Err(Error::other("duplicate usage watch peer"));
}
let client = clients
.get(&host)
.cloned()
.ok_or_else(|| Error::other("usage watch peer is not reachable"))?;
futures.push(async move {
let observations = timeout(SCANNER_ACTIVITY_PROBE_TIMEOUT, client.scanner_usage_watch(owner, entries))
.await
.map_err(|_| Error::other("usage watch peer timed out"))??;
Ok::<_, Error>((host, observations))
});
}
let mut results = Vec::with_capacity(futures.len());
for result in join_all(futures).await {
results.push(result?);
}
Ok(results)
}
pub async fn acknowledge_scanner_dirty_usage(&self, acknowledgements: Vec<ScannerDirtyUsageAcknowledgement>) -> Result<bool> {
let mut by_host = HashMap::with_capacity(acknowledgements.len());
for acknowledgement in acknowledgements {
@@ -306,7 +306,6 @@ pub(in crate::set_disk) struct CleanupSourceMetadata {
pub metadata: Vec<rustfs_filemeta::FileInfo>,
pub errors: Vec<Option<DiskError>>,
pub certified_original: Option<rustfs_filemeta::FileInfo>,
pub inspection_error: Option<DiskError>,
}
/// A successful close is useful only to the guarded cleanup caller. Its owned
@@ -479,10 +478,6 @@ pub(in crate::set_disk) async fn cleanup_source_metadata(
bind_multipart_proof_snapshot(disks, authority)?;
let ids = disk_ids(disks).await;
let inspections = cleanup_inspections(disks, path, None).await;
let inspection_error = inspections.iter().find_map(|inspection| match inspection {
Err(DiskError::UnsupportedDisk) | Ok(_) => None,
Err(error) => Some(error.clone()),
});
if metadata.len() != disks.len() || errors.len() != disks.len() {
return Err(DiskError::FileCorrupt);
}
@@ -524,7 +519,6 @@ pub(in crate::set_disk) async fn cleanup_source_metadata(
metadata,
errors,
certified_original: None,
inspection_error,
});
}
for (slot, original) in originals.iter_mut().enumerate() {
@@ -570,7 +564,6 @@ pub(in crate::set_disk) async fn cleanup_source_metadata(
metadata,
errors,
certified_original,
inspection_error,
})
}
+17 -105
View File
@@ -5620,20 +5620,6 @@ impl SetDisks {
metadata_sys::find_bucket_incarnation_id_in(&self.ctx, bucket).await
}
/// Confirm deletion of this exact generation using immutable retirement evidence.
/// Missing directories or unavailable bucket metadata do not prove retirement.
///
/// # Errors
/// Returns an error when the instance owner or retirement record is unavailable,
/// malformed, or bound to a different deployment or generation.
pub async fn is_bucket_generation_retired(&self, bucket: &str, incarnation: Uuid) -> Result<bool> {
let store = metadata_sys::object_store_in(&self.ctx).await?;
if !Arc::ptr_eq(&store.ctx, &self.ctx) {
return Err(Error::other("bucket retirement metadata belongs to another instance"));
}
crate::bucket::retirement::is_retired(store, bucket, incarnation).await
}
/// Admit one short scanner cache publication under this set's instance
/// movement fence. The caller must hold the returned guard through its
/// final conditional cache write; no scan-round work belongs under it.
@@ -6679,10 +6665,10 @@ impl SetDisks {
pub(crate) async fn storage_info_snapshot(&self) -> rustfs_madmin::StorageInfo {
let disks = self.get_disks_internal().await;
get_storage_info(&disks, &self.set_endpoints, true).await
get_storage_info(&disks, &self.set_endpoints).await
}
pub(crate) async fn local_storage_info_snapshot(&self, include_metrics: bool) -> rustfs_madmin::StorageInfo {
pub(crate) async fn local_storage_info_snapshot(&self) -> rustfs_madmin::StorageInfo {
let disks = self.get_disks_internal().await;
let mut local_disks: Vec<Option<DiskStore>> = Vec::new();
@@ -6695,7 +6681,7 @@ impl SetDisks {
}
}
get_storage_info(&local_disks, &local_endpoints, include_metrics).await
get_storage_info(&local_disks, &local_endpoints).await
}
pub(crate) async fn disk_inventory(&self) -> Vec<Option<DiskStore>> {
@@ -7779,17 +7765,11 @@ fn heal_metadata_identity_matches(meta: &FileInfo, latest_meta: &FileInfo) -> bo
/// drive `disk_info` timeout, and the admin peer probe budget only covers one
/// such timeout; a sequential walk over several stalled drives after a power
/// cut would exceed it and make healthy peers render as unknown (#6488).
async fn get_disks_info(disks: &[Option<DiskStore>], eps: &[Endpoint], include_metrics: bool) -> Vec<rustfs_madmin::Disk> {
join_all(
disks
.iter()
.zip(eps)
.map(|(disk, ep)| disk_admin_info(disk.as_ref(), ep, include_metrics)),
)
.await
async fn get_disks_info(disks: &[Option<DiskStore>], eps: &[Endpoint]) -> Vec<rustfs_madmin::Disk> {
join_all(disks.iter().zip(eps).map(|(disk, ep)| disk_admin_info(disk.as_ref(), ep))).await
}
async fn disk_admin_info(disk: Option<&DiskStore>, ep: &Endpoint, include_metrics: bool) -> rustfs_madmin::Disk {
async fn disk_admin_info(disk: Option<&DiskStore>, ep: &Endpoint) -> rustfs_madmin::Disk {
let Some(disk) = disk else {
return rustfs_madmin::Disk {
endpoint: ep.to_string(),
@@ -7813,14 +7793,14 @@ async fn disk_admin_info(disk: Option<&DiskStore>, ep: &Endpoint, include_metric
let cached_disk_id = disk.cached_disk_id().await;
if !(runtime_state.should_probe_for_admin() || runtime_state == disk::health_state::RuntimeDriveHealthState::Suspect) {
let mut disk_info = build_runtime_snapshot_disk(ep, runtime_state, offline_duration_seconds, capacity_snapshot);
disk_info.metrics = include_metrics.then(|| disk.metrics_snapshot()).flatten();
disk_info.metrics = disk.metrics_snapshot();
disk_info.uuid = cached_disk_id.map_or_else(String::new, |id| id.to_string());
return disk_info;
}
match disk
.disk_info(&DiskInfoOptions {
metrics: include_metrics,
metrics: true,
..Default::default()
})
.await
@@ -7855,7 +7835,7 @@ async fn disk_admin_info(disk: Option<&DiskStore>, ep: &Endpoint, include_metric
utilization: utilization_percent(res.total, res.used),
used_inodes: res.used_inodes,
free_inodes: res.free_inodes,
metrics: include_metrics.then_some(res.metrics),
metrics: Some(res.metrics),
..Default::default()
}
}
@@ -7870,7 +7850,7 @@ async fn disk_admin_info(disk: Option<&DiskStore>, ep: &Endpoint, include_metric
disk_index: ep.disk_idx,
runtime_state: Some(runtime_state.as_str().to_string()),
offline_duration_seconds,
metrics: include_metrics.then(|| disk.metrics_snapshot()).flatten(),
metrics: disk.metrics_snapshot(),
uuid: cached_disk_id.map_or_else(String::new, |id| id.to_string()),
..Default::default()
};
@@ -7941,7 +7921,7 @@ fn capacity_snapshot_age_seconds(probe_unix_secs: u64) -> u64 {
.unwrap_or(probe_unix_secs);
now_unix_secs.saturating_sub(probe_unix_secs)
}
async fn get_storage_info(disks: &[Option<DiskStore>], eps: &[Endpoint], include_metrics: bool) -> rustfs_madmin::StorageInfo {
async fn get_storage_info(disks: &[Option<DiskStore>], eps: &[Endpoint]) -> rustfs_madmin::StorageInfo {
// let mut disks = get_disks_info(disks, eps).await;
// disks.sort_by(|a, b| a.total_space.cmp(&b.total_space));
//
@@ -7952,7 +7932,7 @@ async fn get_storage_info(disks: &[Option<DiskStore>], eps: &[Endpoint], include
// ..Default::default()
// },
// }
let mut disks = get_disks_info(disks, eps, include_metrics).await;
let mut disks = get_disks_info(disks, eps).await;
disks.sort_by_key(|a| a.total_space);
// Provide minimal backend shape for callers. Do NOT guess parity here since it belongs to higher-level config.
@@ -13101,7 +13081,7 @@ mod tests {
.expect("disk 2 should exist")
.force_runtime_state_for_test(RuntimeDriveHealthState::Offline);
let info = get_disks_info(&disks, &endpoints, true).await;
let info = get_disks_info(&disks, &endpoints).await;
assert_eq!(info.len(), 3);
assert_eq!(info[0].state, "ok");
@@ -13146,74 +13126,6 @@ mod tests {
);
}
#[tokio::test]
async fn local_storage_info_without_metrics_preserves_fresh_disk_observations() {
let format = FormatV3::new(1, 4);
let mut temp_dirs = Vec::new();
let mut endpoints = Vec::new();
let mut disks = Vec::new();
for disk_idx in 0..4 {
let (dir, endpoint, disk) = make_formatted_local_disk_for_info_test(disk_idx, &format).await;
temp_dirs.push(dir);
endpoints.push(endpoint);
disks.push(Some(disk));
}
let failed_disk = disks[3].as_ref().expect("failed-probe disk");
failed_disk
.set_disk_id_state(Some(Uuid::new_v4()))
.await
.expect("cache a stale disk identity");
let mut missing = endpoints[3].clone();
missing.set_disk_index(4);
endpoints.push(missing);
disks.push(None);
let mut observations = Vec::new();
for include_metrics in [true, false] {
for (index, state) in [
RuntimeDriveHealthState::Online,
RuntimeDriveHealthState::Returning,
RuntimeDriveHealthState::Offline,
RuntimeDriveHealthState::Suspect,
]
.into_iter()
.enumerate()
{
let disk = disks[index].as_ref().expect("configured test disk");
disk.force_runtime_state_for_test(state);
if state == RuntimeDriveHealthState::Offline {
disk.record_capacity_probe(100, 40, 60);
}
}
let info = get_disks_info(&disks, &endpoints, include_metrics).await;
assert_eq!(info.len(), 5);
assert!(info[..4].iter().all(|disk| disk.metrics.is_some() == include_metrics));
assert!(info[4].metrics.is_none(), "a missing slot has no metric owner");
assert_eq!(info[0].state, "ok", "online disk must retain its live probe");
assert!(info[0].total_space > 0, "online disk must retain capacity information");
assert_eq!(info[0].capacity_observation_source.as_deref(), Some("live_probe"));
assert_eq!(info[1].state, "ok", "returning disk must retain its live probe");
assert_eq!(info[1].runtime_state.as_deref(), Some("returning"));
assert_eq!(info[2].state, "offline");
assert_eq!(info[2].capacity_observation_source.as_deref(), Some("snapshot"));
assert_eq!((info[2].total_space, info[2].used_space, info[2].available_space), (100, 40, 60));
assert_ne!(info[3].state, "ok", "a stale disk identity must still fail its fresh probe");
assert_eq!(info[3].runtime_state.as_deref(), Some("suspect"));
observations.push(info);
}
for (with_metrics, without_metrics) in observations[0].iter().zip(&observations[1]) {
assert_eq!(with_metrics.endpoint, without_metrics.endpoint);
assert_eq!(with_metrics.drive_path, without_metrics.drive_path);
assert_eq!(with_metrics.uuid, without_metrics.uuid);
assert_eq!(with_metrics.state, without_metrics.state);
assert_eq!(with_metrics.runtime_state, without_metrics.runtime_state);
assert_eq!(with_metrics.pool_index, without_metrics.pool_index);
assert_eq!(with_metrics.set_index, without_metrics.set_index);
assert_eq!(with_metrics.disk_index, without_metrics.disk_index);
assert_eq!(with_metrics.total_space, without_metrics.total_space);
}
}
#[tokio::test]
async fn test_get_disks_info_probes_drives_concurrently() {
use crate::disk::disk_store::DISK_INFO_PROBE_DELAY_FOR_TEST;
@@ -13234,7 +13146,7 @@ mod tests {
let probe_delay = std::time::Duration::from_secs(2);
let started = tokio::time::Instant::now();
let info = DISK_INFO_PROBE_DELAY_FOR_TEST
.scope(probe_delay, get_disks_info(&disks, &endpoints, true))
.scope(probe_delay, get_disks_info(&disks, &endpoints))
.await;
let elapsed = started.elapsed();
@@ -13260,7 +13172,7 @@ mod tests {
.expect("remote disk id should be cached");
disk.force_runtime_state_for_test(RuntimeDriveHealthState::Offline);
let info = get_disks_info(&[Some(disk)], &[endpoint], true).await;
let info = get_disks_info(&[Some(disk)], &[endpoint]).await;
assert_eq!(info.len(), 1);
assert_eq!(info[0].state, "offline");
@@ -13278,7 +13190,7 @@ mod tests {
.expect("disk id should be cached before the failed probe");
disk.force_runtime_state_for_test(RuntimeDriveHealthState::Suspect);
let info = get_disks_info(&[Some(disk)], &[endpoint], true).await;
let info = get_disks_info(&[Some(disk)], &[endpoint]).await;
assert_eq!(info.len(), 1);
assert_eq!(info[0].runtime_state.as_deref(), Some("suspect"));
@@ -13297,7 +13209,7 @@ mod tests {
disk.record_capacity_probe(100, 40, 60);
disk.force_runtime_state_for_test(RuntimeDriveHealthState::Offline);
let info = get_disks_info(&[Some(disk)], &[endpoint], true).await;
let info = get_disks_info(&[Some(disk)], &[endpoint]).await;
assert_eq!(info.len(), 1);
assert_eq!(info[0].state, "offline");
assert_eq!(info[0].runtime_state.as_deref(), Some("offline"));
@@ -515,7 +515,7 @@ impl SetDisks {
let owner = context
.namespace_owner
.take()
.unwrap_or_else(|| self.ctx.begin_namespace_commit_for_bucket(bucket));
.unwrap_or_else(|| self.ctx.begin_namespace_commit());
context.namespace_owner = Some(Arc::new((owner, Arc::clone(&transaction_guard))));
let can_commit = context.can_commit;
let can_try_local_fast_path = disks.len() == self.set_drive_count
@@ -791,7 +791,7 @@ impl SetDisks {
let namespace_owner = context
.namespace_owner
.clone()
.unwrap_or_else(|| self.ctx.begin_namespace_commit_for_bucket(bucket));
.unwrap_or_else(|| self.ctx.begin_namespace_commit());
context.namespace_owner = Some(Arc::new((namespace_owner, guard.clone())));
}
let can_commit = context.can_commit;
@@ -821,7 +821,7 @@ impl SetDisks {
let owner = context
.namespace_owner
.take()
.unwrap_or_else(|| self.ctx.begin_namespace_commit_for_bucket(bucket));
.unwrap_or_else(|| self.ctx.begin_namespace_commit());
context.namespace_owner = Some(Arc::new((owner, Arc::clone(&transaction_guard))));
}
let DeleteRecoveryContext {
@@ -1025,7 +1025,7 @@ impl SetDisks {
let namespace_owner = if dry_run {
None
} else {
Some(namespace_owner.unwrap_or_else(|| self.ctx.begin_namespace_commit_for_bucket(bucket)))
Some(namespace_owner.unwrap_or_else(|| self.ctx.begin_namespace_commit()))
};
if !dry_run && metadata_may_change {
self.invalidate_get_object_metadata_cache(bucket, object).await;
+2 -2
View File
@@ -2060,7 +2060,7 @@ impl SetDisks {
_write_lock_guard.clone(),
_read_repair_write_lock_guard.clone(),
bucket_heal_scope.clone(),
self.ctx.begin_namespace_commit_for_bucket(bucket),
self.ctx.begin_namespace_commit(),
))
});
match disk
@@ -3761,7 +3761,7 @@ impl SetDisks {
namespace_owner: (!opts.dry_run).then(|| {
Arc::new((
scope.clone(),
self.ctx.begin_namespace_commit_for_bucket(bucket),
self.ctx.begin_namespace_commit(),
_write_lock_guard.clone(),
transaction_guard.clone(),
)) as Arc<dyn Send + Sync>
@@ -610,9 +610,6 @@ impl SetDisks {
new_disk.enable_health_check();
if new_disk.is_local() {
if let crate::disk::Disk::Local(wrapper) = new_disk.as_ref() {
wrapper.get_disk().usage_watch_binding.bind(&self.ctx.usage_watches);
}
let local_disk_map = runtime_sources::local_disk_map_handle();
let mut global_local_disk_map = local_disk_map.write().await;
let path = new_disk.endpoint().to_string();

Some files were not shown because too many files have changed in this diff Show More