Repository navigation
Conversation
A DeleteObject with If-Match that finds no object is answered 204 No Content, on two paths: - delete_obj returns -ENOENT for a key with no object before it checks any condition, and RGWDeleteObj_ObjStore_S3::send_response answers -ENOENT as success. In a versioned bucket, check_preconditions returns -ENOENT when there is no current version, with the same answer. - A removal that finds the head already gone, removed by a racing delete, ends in complete_del, whose return replaces the -ENOENT. S3 answers a conditional delete that finds no object 404 Not Found, including one that a concurrent delete beat (S3 User Guide, "How to perform conditional deletes"). With If-Match used to release a lease, two clients releasing the same lease are both told they released it. Answer -ENOENT as 404 NoSuchKey when the delete carries If-Match, and return -ENOENT from delete_obj when a conditional delete's removal found no head. A delete without If-Match still succeeds for a missing object, and so does one with only the directory-bucket conditions, x-amz-if-match-size and x-amz-if-match-last-modified-time, which S3 documents as 204. DeleteObjects reports a key whose ETag condition finds no object as a NoSuchKey error, and deletes any other missing key as before. s3-tests' test_delete_object_if_match and test_delete_object_current_if_match assert the 204; they date from when S3 offered conditional deletes only for directory buckets. Fixes: https://tracker.ceph.com/issues/80922 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyle Bader <[email protected]>
This was referenced Sep 27, 2026
mmgaggle
marked this pull request as ready for review
September 27, 2026 09:39
In a versioned bucket a DeleteObject without a version id checks its conditions against the key's current version. When that is a delete marker, the olh has no current version, and the conditions were checked against the olh's own head instead: If-Match: * passed, and a second delete marker was linked over the first. S3 answers 412 Precondition Failed for a delete marker, If-Match: * included. Refuse any condition there, as DeleteObjects does through the same path. This applies to a bucket whose versioning is suspended as well, whose delete of a key with an olh links a null delete marker. Tested on vstart, with versioning enabled and suspended: DeleteObject and DeleteObjects with If-Match: *, the old ETag, or another ETag, when the current version is a delete marker. Without this change If-Match: * is answered 204 and adds a delete marker; with it each is answered 412 and no delete marker is added. s3-tests' test_delete_object_current_if_match expects the old answer. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyle Bader <[email protected]>
5 of 14 tasks
smanjara
reviewed
Oct 8, 2026
|
|
||
| // a conditional delete that removed nothing found no object to delete, | ||
| // like one that found no head to begin with | ||
| if (r >= 0 && removed_nothing && params.if_match) { |
Contributor
There was a problem hiding this comment.
delete_obj()'s return value r after this point is the index_op.complete_del()'s, not the head delete. if complete_del() returns -ENOENT for whatever reason, this check and the checks in RGWDeleteObj_ObjStore_S3::send_response() are skipped. so even a successful head removal gets reported as 404.
the current behaviour is to just return success for an -ENOENT https://github.com/ceph/ceph/blob/main/src/rgw/rgw_rest_s3.cc#L3905. how about we just move that up here just before this check so that complete_del()'s -ENOENT still gets ignored?
if (r == -ENOENT) {
r = 0;
} else if (r >= 0 && removed_nothing && params.if_match) {
r = -ENOENT;
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A DeleteObject with If-Match that finds no object is answered 204 No Content: delete_obj returns -ENOENT before it checks the condition, RGWDeleteObj_ObjStore_S3::send_response answers -ENOENT as success, and a removal that finds the head already gone ends in complete_del, whose return replaces the -ENOENT. For general purpose buckets S3 answers such a delete 404 Not Found, including one that a concurrent delete beat (S3 User Guide, "How to perform conditional deletes"). With If-Match used to release a lease, two clients releasing the same lease are both told they released it.
This answers the -ENOENT of a delete that carries If-Match as 404 NoSuchKey, on both paths, and in a versioned bucket, where check_preconditions returns -ENOENT when there is no current version. A delete without If-Match still succeeds for a missing object, and so does one with only x-amz-if-match-size or x-amz-if-match-last-modified-time, which S3 documents as 204. DeleteObjects reports a key whose ETag condition finds no object as a NoSuchKey error.
s3-tests' test_delete_object_if_match, test_delete_object_current_if_match and test_delete_object_version_if_match assert the 204; ceph/s3-tests#764 updates them.
The P model of RGW overwrites (#72110) checks this answer (S3Answers, finding 15).
Fixes: https://tracker.ceph.com/issues/80922
Validated on a single-host vstart cluster: test_delete_object_if_match_no_object (ceph/s3-tests#763) fails on main and passes with this change; with the companion s3-tests change all 12 conditional-delete tests pass, and test_s3.py as the rgw suite runs it shows no other new failures.
Versioned buckets
In a versioned or suspended bucket whose current version is a delete marker, the conditions were checked against the olh's own head: If-Match: * passed, and a second delete marker was linked. S3 answers 412 Precondition Failed for a delete marker, If-Match: * included. A new commit answers any delete condition 412 there. DeleteObjects takes the same path.
s3-tests
test_delete_object_if_match_delete_markerand_suspendedfail without the new commit and pass with it.test_delete_object_current_if_matchmust expect 412 on the delete marker, and remove the delete marker rather than the version before it retests If-Match: *; ceph/s3-tests#764 needs that change too.Checklist