]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fixes BucketInfo for missing buckets
authorNick Janus <nickjanus@gmail.com>
Thu, 30 Apr 2020 16:22:33 +0000 (12:22 -0400)
committerNathan Cutler <ncutler@suse.com>
Fri, 15 Jan 2021 10:45:41 +0000 (11:45 +0100)
The admin api BucketInfo endpoint should now return 404 for buckets that
are not found where only the bucket name is passed as a parameter.

Fixes: https://tracker.ceph.com/issues/45193
Signed-off-by: Nick Janus <njanus@digitalocean.com>
(cherry picked from commit d70ca81502d25bd7a76dd2ed2a538bf5e6584822)

Conflicts:
        src/rgw/rgw_bucket.cc
- omitted null_yield parameter from bucket.init() call for nautilus purposes

qa/tasks/radosgw_admin_rest.py
src/rgw/rgw_bucket.cc

index 8902ca15c6e2039fd2dbacf1bec707d2bdeeee66..24330ad3bb912cc9df33848f53930464f4f2e8df 100644 (file)
@@ -464,6 +464,11 @@ def task(ctx, config):
     assert out['usage']['rgw.main']['num_objects'] == 1
     assert out['usage']['rgw.main']['size_kb'] > 0
 
+    # TESTCASE 'bucket-stats6', 'bucket', 'stats', 'non-existent bucket', 'fails, 'bucket not found error'
+    (ret, out) = rgwadmin_rest(admin_conn, ['bucket', 'info'], {'bucket' : 'doesnotexist'})
+    assert ret == 404
+    assert out['Code'] == 'NoSuchBucket'
+
     # reclaim it
     key.delete()
 
index e7ebfeefa2ce974e8f10fdbefc239b5b52d14e7e..830efa60e58bee8bdc49bd7b5f8434f315c869c5 100644 (file)
@@ -1644,8 +1644,15 @@ int RGWBucketAdminOp::limit_check(RGWRados *store,
 int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
                   RGWFormatterFlusher& flusher)
 {
+  RGWBucket bucket;
   int ret = 0;
   const std::string& bucket_name = op_state.get_bucket_name();
+  if (!bucket_name.empty()) {
+    ret = bucket.init(store, op_state);
+    if (ret < 0)
+      return ret;
+  }
+
   Formatter *formatter = flusher.get_formatter();
   flusher.start(0);