* fix(ecstore,sse): close rio-v2 interop gaps on imported drive sets
A rio-v2 build that takes over a drive set written in the compatible format could not start once a KMS was configured, and several object reads and writes disagreed with what the other server stores or expects.
- Startup: the IAM migration now opens KMS-sealed IAM records. The record path is part of the key context, so the migration callback receives it, and the context text is escaped the way it was sealed.
- GET of a single-part encrypted object: whether an object holds one cipher stream per part is read from the marker the object records, not guessed from the ETag length. A sealed ETag is longer than an MD5 and sent these objects down the per-part path, which failed authentication.
- ETag: a sealed ETag is opened for GET and HEAD responses.
- HEAD: the public SSE headers are derived from the stored sealing metadata, and the KMS key id is answered in ARN form on GET and HEAD.
- Content length: an object sealed under an object key records no plaintext size when it is a single-part upload; the size is derived from the stored size of its parts.
- Compression: the compression and actual-size keys are also written in the casing the other server looks up.
- User metadata is stored under the x-amz-meta- prefix so it comes back as user metadata on both sides. Keys starting with "internal-" keep their bare form, because the prefixed form falls into a namespace reads hide.
- Replication: the metadata comparison skips the prefixed user metadata, which the target's HEAD answers without the prefix and which therefore never compared equal.
- ListObjectVersions and the metadata listing extension report the plaintext size of encrypted and compressed versions. This is the only intended behaviour change in a default build.
Three differences stay as they are: the other server cannot read SSE-S3 objects this build writes, listings do not open sealed ETags, and an SSE-KMS write is refused when only a static master key is configured.
Each fix has a regression test that fails without it.
* build: rename cargo feature rio-v2 to m-compatible
The feature selects the stored layout a build reads and writes, not a version of the stream crate, so it is named after that. The rename covers the feature key in every crate that forwards it, all cfg attributes, the CI job ids, names and artifacts, the CI gate and its tests, the validation scripts, the compat compose build argument, the debug launch configuration and the documentation.
The crate rustfs-rio-v2, its path and module name, the tests named after that reader implementation, and the backend_name() strings are unchanged. There is no alias: a build that passed --features rio-v2 must pass --features m-compatible.
No behaviour change in either build.
* refactor(ecstore,sse): select the build variant at one point per module
The m-compatible feature was tested at about 220 places, most of them inside function bodies. Each area that differs between the two builds now has a pair of modules exporting the same functions, and one place that picks between them, so call sites no longer name the build.
- ecstore: io_support/rio.rs selects rio/{native,m_compatible}.rs for the stream readers and writers, the compression scheme and index encoding, and the write-side encryptors. object_api/readers.rs selects readers/{native,m_compatible}.rs for range plans, the multipart layout, plaintext sizes that are not recorded, empty parts and the decompressed stream.
- sse: the sealed-ETag branch moves out of core/read.rs into core/keying/, where this crate keeps its build-specific code, and decrypt_kms_sealed_config is exported in both builds.
- utils: the four checks in metadata_compat.rs become one predicate.
- Tests that exist in only one build move to tests/native.rs and tests/m_compatible.rs child modules, gated once where they are declared. The set of test names is unchanged apart from one rename.
The attribute now appears 95 times; in ecstore it is left on the two selection points and on tests. crates/ecstore/AGENTS.md records the convention.
scripts/error-other-format-baseline.txt changes because that ratchet counts per file: 11 existing call sites moved from object_api/readers.rs (19 to 8) into the new readers/m_compatible.rs (11). The total stays at 564.
No behaviour change in either build. docs/architecture/minio-file-format-compat.md gains a table of where the variant lives and a corrected statement of what a default build can read.
* fix(s3): compare read preconditions with the answered ETag
A HEAD or GET of an object whose stored ETag is sealed answers with the ETag clients were shown for it, but If-Match and If-None-Match were still compared with the stored form. A client sending back the ETag HEAD answered with got 412 for If-Match and no 304 for If-None-Match.
- HEAD and GET compare the ETag conditions with the ETag the response carries, and a 304 carries that ETag.
- The storage layer ends a conditional read on the stored ETag before a body is opened, and cannot await the answered one. For a stored ETag in sealed form it no longer ends the read on an ETag condition and leaves the decision to the request layer. Without this a matching If-Match ended the read with no body to answer with.
- A default build stores no sealed ETag: the form test is constant false there and its behaviour is unchanged.
Tests: a round trip on a real store takes the ETag from HEAD and sends it back to GET and HEAD as If-Match and If-None-Match, and sends the stored form to show it matches nothing; unit tests cover the precondition helper, the storage-layer decision and the form test in both builds. With either half of the fix switched off the round trip fails.
* fix(s3): compare copy-source conditions with the answered ETag
x-amz-copy-source-if-match and x-amz-copy-source-if-none-match on CopyObject and UploadPartCopy were compared with the stored ETag of the source. For a source whose stored ETag is sealed that is not the ETag a read answers with, so the ETag from HEAD was refused with 412.
Both compare the ETag a read of the source answers with, as GET and HEAD do since the previous commit. It is resolved after the source's key authorization and only when the request names an ETag. A default build stores no sealed ETag and is unchanged.
Tests: on a real store, a customer-key source with a sealed stored ETag is copied with the ETag from HEAD as copy-source-if-match through both operations; the stored form as if-match and the answered ETag as if-none-match are refused. The fixture is shared with the read round trip. With either call site switched back the test fails.
* fix(s3): answer a date-conditioned GET 304 with the answered ETag
A GET that carried only If-Modified-Since resolved no answered ETag, because the lookup was limited to requests naming an ETag, and its 304 fell back to the stored ETag. For an object whose stored ETag is sealed the 304 then carried a different validator than HEAD answers with.
GET resolves the answered ETag for every conditional request, so a 304 carries it whichever condition produced it. HEAD already did. An unconditional GET still skips the lookup, and a default build stores no sealed ETag and is unchanged.
Tests: the sealed-ETag round trip takes Last-Modified from HEAD, sends it back as If-Modified-Since to GET and HEAD, and requires the 304 of both to carry the ETag HEAD answered with. With the lookup limited to ETag conditions again, the GET half fails.
---------
Co-authored-by: overtrue <anzhengchao@gmail.com>
16 KiB
ECStore Validation Suite
Use this when: you run or extend scripts/run_ecstore_validation_suite.sh, or add an erasure-coding test and need the scenario row it must satisfy.
Source of truth: scripts/run_ecstore_validation_suite.sh (profiles, flags, step commands, coverage scope, default thresholds); docs/architecture/erasure-coding.md (the invariants the rows enforce).
Runner contract
scripts/run_ecstore_validation_suite.sh --profile <quick|full|destructive|fuzz> \
[--out-dir <path>] [--skip-e2e] [--skip-s3-tests] [--skip-coverage] [--require-fixtures] \
[--unit-coverage-min <percent>] [--unit-coverage-scope <ec-critical|crate>] [--dry-run]
The runner is a local and release-validation tool; no CI workflow invokes it.
| Profile | Steps (each profile includes the one above it) | Cost |
|---|---|---|
quick |
rustfs-filemeta lib tests; focused rustfs-ecstore lib filters (erasure, set_disk::read, set_disk::core::io_primitives, the rename-rollback test, disk::local); the two isolated global-state tests named at the top of the runner; the whole rustfs-ecstore --lib with --test-threads=1; e2e reliability_disk_fault_test, heal_erasure_disk_rebuild_test, namespace_lock_quorum_test |
minutes |
full |
fixture gate; legacy-bitrot and MinIO generated-read fixture tests; s3-tests subset TESTEXPR="multipart or range or versioning or delete" with DEPLOY_MODE=build MAXFAIL=0; unit coverage gate |
hours |
destructive |
disk::local::test::crash_consistency (power loss at each pre-commit step; object reopens as old or new, never mixed); e2e cluster_concurrency_test, stale_multipart_cleanup_cluster_test, delete_marker_migration_semantics_test |
hours+ |
fuzz |
scripts/fuzz/run.sh bounded by MAX_TOTAL_TIME (default in the runner) |
bounded |
Artifacts under <out-dir> (default target/ecstore-validation/<timestamp>/):
| File | Content |
|---|---|
run-metadata.env |
profile, flags, thresholds, environment |
summary.tsv |
one row per step: pass / fail / skip with reason |
blackbox-matrix.tsv |
every black-box and fixture row with command, fixture env, and status enabled / disabled / missing-optional / missing-required; written on every invocation regardless of profile |
logs/*.log |
per-step transcripts |
coverage/ecstore/lcov.info, summary.tsv, files.tsv |
coverage export, gate summary, per-file table (full and destructive) |
Fixture rows:
| Row | Profile | Fixture env |
|---|---|---|
legacy bitrot read (crates/ecstore/tests/legacy_bitrot_read_test.rs) |
full |
RUSTFS_LEGACY_TEST_ROOT, RUSTFS_LEGACY_TEST_DISK |
MinIO generated encrypted read and negative restore (storage::minio_generated_read_test in rustfs/src/storage/mod.rs, --features m-compatible, --ignored) |
full |
RUSTFS_MINIO_FIXTURE_ROOT, RUSTFS_MINIO_STATIC_KMS_KEY_B64 |
A missing fixture is recorded as a missing-optional skip. --require-fixtures turns it into an early ecstore-fixture-gate failure before the expensive black-box steps run.
Acceptance rules
A run passes only when every selected step passes. Every scenario asserts API-visible behaviour and, where applicable, on-disk state; a test that only checks constants, helper calls, deleted branches, or implementation details does not satisfy a row.
Fail-closed invariants every row enforces:
- never return corrupted object bytes;
- never silently accept forged or split-brain metadata;
- never downgrade write quorum to read quorum;
- never leave a mixed old/new object after a partial commit;
- never panic on malformed EC metadata;
- return typed errors or quorum failures for invalid states.
Fault injection is explicit and deterministic: local disk mocks for unit tests, process-level disk manipulation (crates/e2e_test/src/chaos.rs) for e2e tests. Property tests replay a fixed seed for payload, range, and missing-shard selection.
PUT completion fixtures
ObjectOptions::default() uses WriteCompletion::Quorum: a namespace-lock-owning PUT may acknowledge write quorum while its rename tail retains the lock. A fixture that immediately inspects every disk or primes a metadata generation must set write_completion: WriteCompletion::TailDrained and keep normal locking. TailDrained waits for the existing rename fan-out; it does not require every disk to succeed or change fsync policy. Codec-only no_lock fixtures do not cover namespace locking.
The object tests reuse rename_fanout_barrier::arm(object, disk_slot, phase) and observe_tasks(object). The fixture uses typed rename, rollback, cleanup, read-version and hedge-timer phases; multiple disk/phase checkpoints can be armed for one object. A duplicate live checkpoint is rejected instead of replacing its owner. wait_until_paused_before(deadline) reports the exact unreached checkpoint on timeout. Wait for the barrier with a deadline, observe actual metadata quorum with wait_for_paused_tail_metadata_quorum, then release or cancel. The metadata check distinguishes a real quorum from disk tasks that have not started. Assert zero remaining rename tasks after the owned coordinator releases its lock; cancellation tests also wait for staging cleanup.
| Fixture | Completion boundary |
|---|---|
early_ack_tail_drain_retains_namespace_lock_until_background_rename_finishes |
Default PUT returns before the parked tail; a second writer remains blocked. |
tail_drained_put_* |
Explicit full-tail PUT retains its guard, preserves quorum success with a failed minority, rejects quorum-minus-one, and survives ACK waiter cancellation. |
transition_and_restore_reclaim_prior_metadata_generations |
Both source fixtures use TailDrained before cache priming, with normal namespace locks. |
object_transaction_fencing_persists_epoch_on_multipart_commit |
Multipart completion already always drains rename before inspecting all per-disk transaction UUIDs. |
decommission_durable_ilm_receipt_pagination_fails_closed_on_second_page, dispatch_completion_cas_is_bounded_and_reaches_the_tail |
Durable receipt, journal, and manifest writers choose TailDrained; the pagination fixture also drains deliberate receipt replacement writes. |
Select these checks with cargo nextest list -p rustfs-ecstore --features test-util -E 'test(tail_drained_put) | test(early_ack_tail_drain) | test(no_lock_put_waits_for_rename_tail) | test(object_transaction_fencing_persists_epoch_on_multipart_commit) | test(transition_and_restore_reclaim) | test(decommission_durable_ilm_receipt_pagination) | test(dispatch_completion_cas)', then run the same expression under the default and CI profiles without retries. Remaining crash, reopen, rollback, and lock-loss schedules use the existing domain tests; this completion fixture is not a replacement for those checks.
seeded_put_completion_pressure_drains_every_real_tail uses seed 0x2248_0009 for four finite rounds: Quorum and TailDrained, each with a normal or cancelled caller. Every round parks the target and two non-inline pressure PUTs on a real four-disk set, observes their three-disk metadata quorum, and releases their rename phases in a seeded order. It checks the target's namespace owner, quorum versus tail ACK, cancellation handoff, exact bodies, immediate same-key CAS, zero remaining fan-out tasks, physical mutation-lease release, and staging drain. Select this one test with cargo nextest list --locked -p rustfs-ecstore --lib -E 'test(=set_disk::ops::object::put_object_tmp_cleanup_tests::seeded_put_completion_pressure_drains_every_real_tail)'; run the same expression with cargo nextest run --profile default --retries 0, then --profile ci --retries 0. Both profiles must select and pass one test; the test performs all four rounds without environment overrides or sleeps.
Coverage gate
full and destructive run cargo llvm-cov -p rustfs-ecstore --lib and fail when line coverage of the gate scope is below --unit-coverage-min. The default minimum and the 100% target for EC read, write, decode, heal, metadata-quorum, and rollback paths are the UNIT_COVERAGE_* constants at the top of the runner. cargo-llvm-cov must be installed unless --skip-coverage is passed explicitly. The default scope ec-critical is:
crates/ecstore/src/erasure/**crates/ecstore/src/set_disk/read.rscrates/ecstore/src/set_disk/shard_source.rscrates/ecstore/src/set_disk/metadata.rscrates/ecstore/src/set_disk/ops/object.rscrates/ecstore/src/set_disk/core/io_primitives.rscrates/ecstore/src/disk/local.rs
--unit-coverage-scope crate measures the whole crate instead; that number is an observation metric and must not hide EC regressions behind unrelated modules. Lowering the minimum requires a documented exception tied to missing testability or unreachable code. Uncovered branches in reconstruction, quorum, and error paths are either intentionally unreachable or tracked.
White-box scenario matrix
Each row is a scenario the unit layer covers; a new EC unit test names the row it satisfies.
Erasure algorithm (crates/ecstore/src/erasure/)
| Area | Scenarios | Assertions |
|---|---|---|
| Shard geometry | legacy/current shard-size formulas; lengths 0, 1, block-1, block, block+1, multi-block tail |
no divide-by-zero; shard/file/range offsets match expected |
| Encode/decode | (data, parity) sets 2+2, 4+2, 8+8; random payloads; missing shards up to parity |
reconstructed data equals original |
| Negative reconstruction | missing shards above parity; inconsistent shard lengths; corrupt surplus parity | typed error, no partial success |
| Source verification | missing data shard plus extra parity source | rebuilt parity matches source parity |
| Legacy compatibility | old shard formula and legacy checksum data | legacy files decode and heal correctly |
| Streaming decode | legacy engine vs RustFS codec engine on the same stripe stream | bytes and errors are equivalent |
| Range output | head/middle/tail/suffix; cross-block and final-short-stripe ranges | exact byte range, no over-read or under-read |
Bitrot and reader alignment (erasure/coding/bitrot.rs, decode.rs, set_disk/core/io_primitives.rs, set_disk/shard_source.rs)
| Area | Scenarios | Assertions |
|---|---|---|
| Hash framing | valid hash+data; wrong hash; truncated hash; truncated data | invalid data never succeeds |
| Short shard | short read under normal hash, skip_verify, and hash-none |
UnexpectedEof or equivalent typed error |
| Lockstep reads | mid-stream data shard failure; pending/timeout reader; final short stripe | each live reader advances exactly one stripe; failed reader retires |
| Adaptive reads | hedged parity fallback and timeout retirement | no shard desync; reconstructed bytes match original |
| Shard source order | out-of-order read completion and missing slots | slots resolve by shard index |
| Deferred readers | data-blocks-first setup opens deferred parity at the correct offset | parity fallback uses aligned data |
Instrumented readers record shard index, stripe index, read count, offset, and retirement reason.
Metadata, quorum, and commit atomicity (crates/filemeta/src/filemeta/version.rs, set_disk/read.rs, set_disk/metadata.rs, set_disk/ops/object.rs, disk/local.rs)
| Area | Scenarios | Assertions |
|---|---|---|
| Metadata tamper | same version_id/mod_time, divergent data dir, parts, ETag, size, checksum, inline flag, erasure distribution |
previous committed version or read-quorum error; no arbitrary latest |
| Early stop | valid quorum, stale quorum, corrupt trailing disks, slow trailing disks | early-stop only on safe identity |
| Quorum downgrade | read quorum vs write quorum; delete-marker quorum; version-not-found quorum | no mutation below write quorum |
| Rename atomicity | failure before data rename, after data rename, after metadata rename, cleanup failure | object is old or new; never mixed |
| Rollback | failed commit quorum and stale temp data | rollback preserves old metadata and data |
| Malformed metadata | oversized lengths, bad CRC, invalid versions, invalid UUID/timestamp/enum, huge parts | bounded memory; typed error; no panic |
Black-box scenario matrix
Real S3 and admin behaviour runs through crates/e2e_test. Extend crates/e2e_test/src/chaos.rs rather than adding ad hoc fault helpers.
Single-node 4-disk EC (reliability_disk_fault_test.rs, heal_erasure_disk_rebuild_test.rs, chaos.rs)
| Scenario | Required assertions |
|---|---|
| baseline PUT/GET/HEAD/List for tiny, inline, block-boundary, multi-block, multipart objects | SHA256 manifest matches; metadata is consistent on all disks |
| one disk offline during read | existing objects readable; no corrupted bytes |
| one disk offline during write | write succeeds only when write quorum holds; restored disk is healed |
| above-parity disk loss | GET/PUT fails with a quorum error; no partial bytes accepted |
| corrupt data shard and parity shard | GET returns original bytes or fails closed; read-repair/heal restores |
corrupt inline xl.meta |
fail closed or heal; no forged inline data |
| range read with offline/corrupt shard | exact range bytes; invalid ranges produce the expected S3 errors |
| multipart part resend and concurrent same-part writes | final object matches the chosen committed parts |
| crash during multipart complete/put/delete | after restart only the old or the new full version is visible |
Distributed 4-node / 16-disk EC (cluster_concurrency_test.rs, namespace_lock_quorum_test.rs, stale_multipart_cleanup_cluster_test.rs)
Single-process unit tests cannot prove RPC, HTTP/2, timeout, or distributed-quorum behaviour, so this layer is mandatory.
| Scenario | Required assertions |
|---|---|
| node/disk outage while reading large objects | no EOF/truncation; SHA256 manifest matches |
| write while one remote node is down | write follows quorum; later heal reconstructs the remote disk |
| remote shard bitrot | degraded read uses clean shards; no bad bytes |
| concurrent GET/PUT/DELETE/List on the same key | no 500 for expected conflicts; no dirty reads |
| range GET matrix for large objects | sequential and parallel ranges match the full-object hash |
| internode timeout / slow disk | typed error or fallback; no desync |
Versioning, delete markers, and migration (delete_marker_migration_semantics_test.rs)
| Scenario | Required assertions |
|---|---|
| latest delete marker | GET/HEAD/ListObjectVersions match S3 semantics |
explicit versionId for old versions |
exact old bytes and metadata |
| suspended/null version | no version-ordering regression |
| delete marker during heal/rebalance/decommission | marker visibility and history are preserved |
| orphan directory cleanup | real objects are not purged; tombstones behave correctly |
Heal, rebalance, and decommission
| Scenario | Required assertions |
|---|---|
| auto heal and admin deep heal | data hash unchanged; xl.meta and format data rebuilt |
| heal interruption/restart | idempotent recovery; no dangling temp objects |
| two-pool rebalance with versioned/multipart objects | source and target pools have consistent versions |
| decommission cancel/restart/finalize | target readable; source cleanup safe |
| rebalance/decommission with node outage | progress resumes; no duplicate or missing versions |
scripts/test/decommission_*.sh cover parts of this table but are not runner steps because they emit no machine-readable pass/fail artifact.
Large-object and fuzz gates
Stand-alone harnesses indexed in scripts/README.md, not runner steps: scripts/run_get_codec_streaming_smoke.sh (legacy vs codec GET parity), scripts/run_gt1g_get_http_matrix.sh (sequential and parallel range GET above 1 GiB), scripts/run_gt1g_multipart_put_matrix.sh (multipart PUT above 1 GiB).
The fuzz profile delegates to scripts/fuzz/run.sh; targets, corpus rules, and crash-reproducer locations are in fuzz/README.md. Malformed-storage-input surfaces the corpus must cover: xl.meta MessagePack and legacy filemeta versions, RPC payload decoding, checksum and bitrot headers, range offset/length overflow, object names with path traversal or encoded separators, huge inline metadata and part counts.