Repository navigation
fix: stop re-replicating an object whose retention was removed - #131
Conversation
|
Independent review: one P2 correction required before merge.
The focused reproduction returns |
05ab4ca to
5069251
Compare
Update — timestamp-only tombstone recognized; Codex adversarial review PASSResponding to the 2026-09-06 P2. The helper now recognizes both representations; a present ordering timestamp paired with a non-empty mode is a retention that was set (not removed) and still returns false. Rebased onto current Codex Astra 6 (Max) adversarial review: VERDICT PASS (round 1, no actionable defect within the single-erasure-set scope). Local: |
5069251 to
0192c73
Compare
|
Independent round-2 verification: the previously reported P2 is fixed at I reran the original regression with source metadata produced by The combined #131/#132/#134/#138 candidate passed 152 targeted tests/subtests and 5,701 full cmd/internal tests/subtests (166 skipped). Product patches combine cleanly; the additive #131/#138 test-file conflict requires keeping both test groups and their imports. #117 is updated to verified/awaiting merge. No product correction was added by this review. |
getReplicationAction builds its source map from oi1.UserDefined, where a removed retention is a present key with an empty value, and its target map from the destination's HEAD headers, which can never carry those keys because setObjectHeaders skips empty lock values and FilterObjectLockMetadata drops both keys when the mode is invalid. The comparison then always reports a difference, the replicateNone fast path is dead for such versions, and an otherwise matching version re-copies its metadata on every evaluation. Skip an entry whose value is empty and whose key is x-amz-object-lock-mode or x-amz-object-lock-retain-until-date, case-insensitively, in both comparison loops, using the joined value on the target side. Normalizing only the source would regress the case where both sides hold the empty pair. HEAD also omits a real retention from a credential without s3:GetObjectRetention, which the documented target policy does not grant, so that normalization alone would read a destination hiding a retention as in sync and drop the removal. replicationActionForTarget therefore confirms with the destination before skipping the resend: only an explicit answer, no retention on the version, clears it. Everything else keeps today's metadata resend, including a denied or unreachable destination, a mode the SDK does not recognize, and InvalidRequest, which names a bucket without Object Lock but is also what a destination answers when its own read of that configuration fails. The null version an existing object resync excludes is never reopened. Tests: TestGetReplicationActionEmptyObjectLockValues (eight cases, red on 2 and 3 before this change), TestRetentionRemovedAtSource, TestTargetRetentionConfirmedAbsent, TestReplicationActionForTargetRetentionRemoval, TestReplicationActionForTargetNullVersionResync and TestEmptyRetentionValuesAreOmittedFromObjectResponseHeaders. Compatibility: sender side only, no wire or storage change, so a fixed source converges against any destination version. Fixes #117 Signed-off-by: Feng Ruohang <[email protected]> Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe
…ompare retentionRemovedAtSource only recognized representation (1) of a removed retention: the object lock key present with an empty value. But a removal that arrived by replication persists representation (2): restoreRetention (and the receiver's replica update path) writes only the retention ordering timestamp when the mode is empty, leaving the mode and retain-until-date keys absent. For that shape the helper returned false, so replicationActionForTarget skipped the GetObjectRetention confirmation and let getReplicationAction's replicateNone stand, silently dropping a needed removal when the destination HEAD hides retention behind a permission-filtered credential. Recognize representation (2) as well: a present retention ordering timestamp with the mode value absent or empty is a removal. A present timestamp paired with a non-empty mode is a retention that was set, not removed, and still returns false. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
0192c73 to
7935c84
Compare
Contribution Licensing (no CLA, inbound=outbound, DCO required)
This project does not use a CLA; contributions are accepted inbound=outbound.
By submitting this pull request I represent that I have the right to contribute
the changes, which are licensed under this repository's
GNU Affero General Public License v3.0 or later
and remain my copyright. Every commit carries a DCO
Signed-off-bytrailer.Description
getReplicationActioncompared the source's stored metadata, where a removed retention is a present key with an empty value, against the target's HEAD headers, which never carry those keys (two filters strip an empty or invalid Object Lock value from GET/HEAD responses). Thereflect.DeepEqualtherefore always differed and the "already in sync" short circuit was dead for these versions, so every re-evaluation re-copied their metadata. Emptyx-amz-object-lock-mode/x-amz-object-lock-retain-until-dateare now skipped on both sides of the comparison, so absent and present-empty compare equal.A comparison-only change is not safe on its own, which the adversarial review established: a target whose replication credential lacks
s3:GetObjectRetentionreturns a HEAD with no retention even when it still holds one, so treating "no retention in HEAD" as in-sync would silently drop a real removal. The fix therefore confirms with the destination before skipping a removal:replicationActionForTargetissues aGetObjectRetentionon that narrow path only, and treats onlyNoSuchObjectLockConfigurationor a successful nil/empty mode as confirmed-absent; any ambiguous response (a denied read, an unrecognised mode, orInvalidRequest, which a destination also emits when its own lock-config read fails) is uncertain and the removal is resent exactly as today. The deliberate null-version resync exclusion is preserved via an extracted, byte-identical predicate.Fixes #117. Issue and plan: #117. Adversarial Codex review of this implementation: rounds 1-3 FAIL (each surfaced a distinct way a permission-filtered or error HEAD could be misread as confirmed-absent), round 4 PASS after every case was closed.
Motivation and Context
Inherited from upstream (
getReplicationActionis byte-identical toupstream/master). A removed-retention object was re-sent on every scanner heal, existing-object pass andmc replicate resync; against a lock-disabled destination the resend also failed rather than settling. AWS documents an emptyRetentionas the way to drop retention on a GOVERNANCE object, so the empty stored value is the expected shape.How to test this PR?
The eight-case comparison table is red on cases 2 and 3 (present-empty removal on either side) before the fix and green after; further tests cover the permission-filtered HEAD being treated as uncertain, the
InvalidRequestlock-config-read ambiguity, the null-version exclusion, and that the target genuinely cannot emit empty lock keys.TestReplicationResync,TestReplicatedInfos,TestParseReplicateDecision,TestCompositeReplicationStatusandTestAPICopyObjectReplicaLegalHoldTimestampstay green.gofmtclean,go vetclean, golangci-lint 0 issues.Compatibility impact
No API, wire, storage, config or metrics change. The fix adds a conditional
GetObjectRetentionto the destination only on the ambiguous removed-retention path, where a full metadata copy runs today, so it is strictly less work there. It becomes effective only when the replication target credential can read retention: grantings3:GetObjectRetentionin the replication target policy is now load-bearing, and this should be noted in the replication docs on silo.pgsty.com.getReplicationActionnow diverges from upstream master (recorded divergence). The issue's hope that a lock-disabled destination settles back toCOMPLETEDis explicitly not delivered; that case still resends and still fails, for the same reason the removal cannot be confirmed there.Types of changes
Checklist:
git commit -s) per the DCOmake verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...pgsty/silo.pgsty.com(note the requireds3:GetObjectRetentiontarget permission)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe