]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: report correct error code for non-existent bucket on deletion 63135/head
authorSeena Fallah <seenafallah@gmail.com>
Wed, 30 Apr 2025 18:40:13 +0000 (20:40 +0200)
committerSeena Fallah <seenafallah@gmail.com>
Tue, 6 May 2025 13:02:54 +0000 (15:02 +0200)
admin api should return the correct error code when the bucket doesn't
exist on bucket deletion. apparently a regression by 9ae2d8c4e95807179fc17f84be6754d2b19fe639.

Fixes: https://tracker.ceph.com/issues/71159
Signed-off-by: Seena Fallah <seenafallah@gmail.com>
(cherry picked from commit ede013f4adc837968b7152e3c76753d85c3df35a)

qa/tasks/radosgw_admin_rest.py
src/rgw/driver/rados/rgw_rest_bucket.cc

index 4b07ad330d342d5a87c7b62ed8304073b0b592fe..049a7903b1cc8b0537645ec8de7cf2cea415157a 100644 (file)
@@ -858,6 +858,11 @@ def task(ctx, config):
     (ret, out) = rgwadmin_rest(admin_conn, ['bucket', 'rm'], {'bucket' : bucket_name, 'purge-objects' : True})
     assert ret == 200
 
+    # TESTCASE 'rm-bucket', 'bucket', 'rm', 'non-existent bucket', 'correct error'
+    (ret, out) = rgwadmin_rest(admin_conn, ['bucket', 'rm'], {'bucket' : bucket_name})
+    assert ret == 404
+    assert out['Code'] == 'NoSuchBucket'
+
     # TESTCASE 'caps-add', 'caps', 'add', 'add user cap', 'succeeds'
     caps = 'usage=read'
     (ret, out) = rgwadmin_rest(admin_conn, ['caps', 'add'], {'uid' :  user1, 'user-caps' : caps})
index bdbafe2d1ebedaca0ec750d450f3520cf0ce5626..3468aa0de7bc0cf9337d2ebd063d1a5d651df595 100644 (file)
@@ -234,6 +234,9 @@ void RGWOp_Bucket_Remove::execute(optional_yield y)
   const bool is_forwarded = s->info.args.exists(RGW_SYS_PARAM_PREFIX "zonegroup");
 
   op_ret = RGWBucketAdminOp::remove_bucket(driver, *s->penv.site, op_state, y, s, bypass_gc, true, is_forwarded);
+  if (op_ret == -ENOENT) {
+    op_ret = -ERR_NO_SUCH_BUCKET;
+  }
 }
 
 class RGWOp_Set_Bucket_Quota : public RGWRESTOp {