]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fixes BucketInfo for missing buckets 34866/head
authorNick Janus <nickjanus@gmail.com>
Thu, 30 Apr 2020 16:22:33 +0000 (12:22 -0400)
committerMark Kogan <mkogan@redhat.com>
Mon, 12 Oct 2020 10:50:06 +0000 (13:50 +0300)
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>
qa/tasks/radosgw_admin_rest.py
src/rgw/rgw_bucket.cc

index df3fa7a1d1737ea727602245918ceae6f15c663e..95fe5b8ac3819dda9ed953bc9ffadbcd3bc3e489 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 584829919e8b636dfef592cbe84e249bc2039452..0ef697fd07d1e52b49165de775289a6b18481f62 100644 (file)
@@ -1490,8 +1490,15 @@ int RGWBucketAdminOp::info(rgw::sal::RGWRadosStore *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, null_yield);
+    if (ret < 0)
+      return ret;
+  }
+
   Formatter *formatter = flusher.get_formatter();
   flusher.start(0);