Skip to content

rgw: answer 412 when a CopyObject source precondition fails - #73201

Open
RaminNietzsche wants to merge 1 commit into
ceph:mainfrom
RaminNietzsche:wip-rgw-copy-source-precondition-412
Open

RaminNietzsche wants to merge 1 commit into
ceph:mainfrom
RaminNietzsche:wip-rgw-copy-source-precondition-412

Conversation

@RaminNietzsche

Copy link
Copy Markdown
Member

A CopyObject whose x-amz-copy-source-if-none-match matches the source, or whose x-amz-copy-source-if-modified-since finds it unmodified, is answered 304 Not Modified. AWS answers 412 PreconditionFailed, and RFC 9110 13.1.2 and 13.1.3 define 304 only for GET and HEAD.

  • The driver evaluates the copy-source conditions with the read prepare used by GET, where these failures are -ERR_NOT_MODIFIED. RGWCopyObj now maps that to -ERR_PRECONDITION_FAILED, so every SAL driver and both the S3 and Swift copy paths answer 412. A system request with copy-if-newer still gets 304, which tells it the destination is already current.
  • The D4N filter remapped this case itself, but assigned ERR_PRECONDITION_FAILED without the minus sign, so its copy returned a positive value. That remap is dropped.
  • s3-tests: fails_on_rgw is removed from test_copy_object_ifnonematch_good (now passes) and test_copy_object_ifmatch_failed (already passed on main); new cases cover If-None-Match: * and If-Modified-Since.

Fixes: https://tracker.ceph.com/issues/82230

Testing

On a single-host vstart cluster:

Condition main this branch
CopySourceIfNoneMatch=<etag of src> 304 412 PreconditionFailed
CopySourceIfNoneMatch=* 304 412 PreconditionFailed
CopySourceIfModifiedSince=2100-01-01 304 412 PreconditionFailed
CopySourceIfModifiedSince=2000-01-01 200 200
CopySourceIfUnmodifiedSince=2000-01-01 412 412
CopySourceIfMatch="bad" 412 412
CopySourceIfNoneMatch="other" 200 200

s3-tests on this branch:

  • -k test_copy_object: 7 passed (on main, test_copy_object_ifnonematch_good fails with 304).
  • -m "not fails_on_rgw" -k "(copy or ifmatch or ifnonematch or ifmodified or ifunmodified) and not enc": 59 passed.
  • The SSE variants of test_copy_enc / test_copy_part_enc were not run meaningfully: the test cluster has no SSE-S3/KMS backend, so they fail with InvalidArgument before any precondition is evaluated.

The test build has D4N disabled, so the D4N change (removing three lines) was not compiled there.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@RaminNietzsche
RaminNietzsche requested a review from a team as a code owner October 28, 2026 13:06
@RaminNietzsche

Copy link
Copy Markdown
Member Author

The probe script used for the before/after checks is here: https://gist.github.com/RaminNietzsche/818ad8dd6b8d8093560183cd09d2b169

It runs against a vstart RGW (python3 rgw-rfc9110-repro.py, defaults to localhost:8000 with the vstart credentials). The case for this PR is T4 CopyObject x-amz-copy-source-if-none-match matches: HTTP 304 on main, 412 with this branch. The If-None-Match: * and If-Modified-Since rows in the description were checked the same way with boto3 copy_object, and are covered by the new s3-tests cases. The other cases in the script cover separate RFC 9110 items and are not affected by this change.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

RFC 9110 RGW audit — series context

This PR is one focused change from an RFC 9110 conformance review of RGW (S3, Swift, Admin, STS). Each PR is meant to review and merge on its own; there is no batch dependency unless called out below.

Item PR Tracker
T1 — 416 + Content-Range #73200 #82229
T4b — CopyObject source preconditions → 412 #73201 #82230
T4a — If-Match before If-Modified-Since #73205 #82233 (Fixes #19965)
T5 — 405 + Allow, 501 for unknown methods #73206 #82235
T6 — Swift 401 + WWW-Authenticate #73209 #82242

Same audit, already tracked on other PRs (not part of this series authorship):

Item PR Tracker
T2 — Range header parsing #71300 #13412
T3 — whole-tag If-Match / If-None-Match #72117 #80924

Follow-ups from the audit not opened yet: T4d If-Range (best after #71300 and #72117 land), T8b header field section too large → 431, T9 admin GET ?sync=true side effects.

Shared repro script and sample output: https://gist.github.com/RaminNietzsche/818ad8dd6b8d8093560183cd09d2b169 (rgw-rfc9110-repro.py; cases T1–T8).

This PR (T4b): CopyObject source If-None-Match / If-Modified-Since should fail with 412, not 304 on the destination response. Related tracker #40808 was marked duplicate of #82230.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

@adamemerson Could you take a look when you have a cycle? You approved the sibling RFC 9110 changes (#73200, #73205). All checks are green on the current tip 722308601; the change only makes CopyObject answer 412 when an x-amz-copy-source-if-* precondition fails, with tests.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@RaminNietzsche
RaminNietzsche force-pushed the wip-rgw-copy-source-precondition-412 branch from 7223086 to 464eee5 Compare November 14, 2026 12:23
@RaminNietzsche

Copy link
Copy Markdown
Member Author

Rebased onto current main (464eee5e77f). Resolved conflict in rgw_op.cc (412 mapping + log_record(..., false) from main).

jenkins test make check

A CopyObject whose x-amz-copy-source-if-none-match matches the source,
or whose x-amz-copy-source-if-modified-since finds it unmodified, is
answered 304 Not Modified. The driver evaluates the copy-source
conditions with the read prepare used by GET, where these failures are
-ERR_NOT_MODIFIED, and RGWCopyObj returns it as is. AWS answers 412
PreconditionFailed, and RFC 9110 13.1.2 and 13.1.3 define 304 only for
GET and HEAD.

Map -ERR_NOT_MODIFIED to -ERR_PRECONDITION_FAILED in RGWCopyObj, so
every SAL driver and both the S3 and Swift copy paths answer 412. A
system request with copy-if-newer still gets 304, which tells it the
destination is already current.

The D4N filter remapped this case itself, but assigned
ERR_PRECONDITION_FAILED without the minus sign, so its copy returned a
positive value. Drop that remap.

Remove fails_on_rgw from test_copy_object_ifnonematch_good, which now
passes, and from test_copy_object_ifmatch_failed, which already did, and
add cases for If-None-Match: * and If-Modified-Since.

Fixes: https://tracker.ceph.com/issues/82230
Signed-off-by: ramin.najarbashi <[email protected]>
@RaminNietzsche
RaminNietzsche force-pushed the wip-rgw-copy-source-precondition-412 branch from 464eee5 to 23263a8 Compare November 25, 2026 14:36
@anrao19

anrao19 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao2-testing-2026-11-26-0630-main.

@RaminNietzsche

RaminNietzsche commented Nov 28, 2026 •

Copy link
Copy Markdown
Member Author

Hi @anrao19 — dev-pipeline #11296 failed only on jammy x86_64 default: apt 404 on libtiff5 during the crimson build-container step (infra/mirror), not an #73201 compile error.

Thanks for queuing this.

@mheler

mheler commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Hi @anrao19 — dev-pipeline #11296 failed only on jammy x86_64 default: apt 404 on libtiff5 during the crimson build-container step (infra/mirror), not an #73201 compile error.

Thanks for queuing this.

Hi @RaminNietzsche typically the component leads will review the QA runs, and make a decision on passing, dropping or rejecting a change. Let's please wait for the review feedback. Thank you.

@RaminNietzsche

Copy link
Copy Markdown
Member Author

Hi @RaminNietzsche typically the component leads will review the QA runs, and make a decision on passing, dropping or rejecting a change. Let's please wait for the review feedback. Thank you.

@mheler Thanks — understood. I was not asking for a queue change; my note to @anrao19 was only context (Shaman jammy looked like an apt/mirror infra issue, not #73201). I will wait for the component lead’s QA review feedback and follow their pass / drop / reject decision. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants