From e5d9457f3cc5de8ed6fc45ae24c67e602e4f06cd Mon Sep 17 00:00:00 2001 From: Giuseppe Baccini Date: Tue, 31 Oct 2023 10:59:29 +0100 Subject: [PATCH] rgw/sfs: recognize delete-marker on DeleteObj RGWDeleteObj::execute() relies on the return code from rgw::sal::Object::get_obj_state() to ascert the object being deleted is a regular object rather than a delete-marker. The rule is to return -ENOENT to signal a delete-marker. get_obj_state() in rgw/sfs was returning always 0 for any object, therefore also a delete-marker fell into a regular object in RGWDeleteObj::execute(). This is wrong because, when dealing with object lock checks, a delete-marker is always allowed to be deleted regardless of the object's retention mode. Returing 0 was incorrectly preventing a delete-marker to be deleted for object-lock protected objects. Fixes: https://github.com/aquarist-labs/s3gw/issues/690 Signed-off-by: Giuseppe Baccini --- qa/rgw/store/sfs/tests/fixtures/s3-tests.txt | 2 +- qa/rgw/store/sfs/tests/fixtures/s3tr_excuses.csv | 1 - src/rgw/driver/sfs/object.cc | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/qa/rgw/store/sfs/tests/fixtures/s3-tests.txt b/qa/rgw/store/sfs/tests/fixtures/s3-tests.txt index 3649c74459aa3..7c55617b68c55 100644 --- a/qa/rgw/store/sfs/tests/fixtures/s3-tests.txt +++ b/qa/rgw/store/sfs/tests/fixtures/s3-tests.txt @@ -470,7 +470,7 @@ test_object_lock_get_obj_retention_invalid_bucket # test_object_lock_put_obj_retention_shorten_period # test_object_lock_put_obj_retention_shorten_period_bypass # test_object_lock_delete_object_with_retention -# test_object_lock_delete_object_with_retention_and_marker +test_object_lock_delete_object_with_retention_and_marker # test_object_lock_multi_delete_object_with_retention # test_object_lock_put_legal_hold test_object_lock_put_legal_hold_invalid_bucket diff --git a/qa/rgw/store/sfs/tests/fixtures/s3tr_excuses.csv b/qa/rgw/store/sfs/tests/fixtures/s3tr_excuses.csv index e291b986ec3ef..fc67247c933bb 100755 --- a/qa/rgw/store/sfs/tests/fixtures/s3tr_excuses.csv +++ b/qa/rgw/store/sfs/tests/fixtures/s3tr_excuses.csv @@ -18,7 +18,6 @@ test_bucket_recreate_overwrite_acl;https://github.com/aquarist-labs/s3gw/issues/ test_logging_toggle;https://tracker.ceph.com/issues/984;Not supported by RGW test_object_copy_replacing_metadata;https://github.com/aquarist-labs/s3gw/issues/525;BUG test_object_copy_to_itself_with_metadata;https://github.com/aquarist-labs/s3gw/issues/525;BUG -test_object_lock_delete_object_with_retention_and_marker;https://github.com/aquarist-labs/s3gw/issues/690;BUG test_object_read_unreadable;https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html;Broken test, Object names are UTF-8 test_object_requestid_matches_header_on_error;https://github.com/aquarist-labs/s3gw/issues/689;BUG test_object_set_get_unicode_metadata;https://github.com/aquarist-labs/s3gw/issues/688;BUG, maybe upstream diff --git a/src/rgw/driver/sfs/object.cc b/src/rgw/driver/sfs/object.cc index c2e686295df3b..8ad4f7e696f51 100644 --- a/src/rgw/driver/sfs/object.cc +++ b/src/rgw/driver/sfs/object.cc @@ -463,7 +463,7 @@ int SFSObject::get_obj_state( ) { refresh_meta(); *_state = &state; - return 0; + return objref->deleted ? -ENOENT : 0; } int SFSObject::set_obj_attrs(