]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix radosgw-admin buckets list
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 26 Jun 2013 18:28:57 +0000 (11:28 -0700)
committerSage Weil <sage@inktank.com>
Thu, 27 Jun 2013 04:31:21 +0000 (21:31 -0700)
Fixes: #5455
Backport: cuttlefish
This commit fixes a regression, where radosgw-admin buckets list
operation wasn't returning any data.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit e1f9fe58d2860fcbb18c92d3eb3946236b49a6ce)

src/rgw/rgw_bucket.cc
src/rgw/rgw_rados.cc

index 2f05264778eddd17597409859f3ccdcd697b4bbf..99de568d92a5fe8cd32b6591c395791487c7a66e 100644 (file)
@@ -863,11 +863,16 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
                   RGWFormatterFlusher& flusher)
 {
   RGWBucket bucket;
-  int ret = bucket.init(store, op_state);
-  if (ret < 0)
-    return ret;
+  int ret;
+
   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);
 
@@ -911,7 +916,8 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
   } else {
     RGWAccessHandle handle;
 
-    if (store->list_buckets_init(&handle) > 0) {
+    formatter->open_array_section("buckets");
+    if (store->list_buckets_init(&handle) >= 0) {
       RGWObjEnt obj;
       while (store->list_buckets_next(obj, &handle) >= 0) {
        formatter->dump_string("bucket", obj.name);
@@ -919,6 +925,8 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
           bucket_stats(store, obj.name, formatter);
       }
     }
+
+    formatter->close_section();
   }
 
   flusher.flush();
index 7d038639a74808ed479b3c8591cc338316c5ac4d..5ca27a06a0369d93fbd9cf97da3f4a73634a5309 100644 (file)
@@ -428,9 +428,7 @@ int RGWRados::list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle)
 
     obj.name = (*state)->first;
     (*state)++;
-  } while (obj.name[0] == '.');
-
-  /* FIXME: should read mtime/size vals for bucket */
+  } while (obj.name[0] == '.'); /* skip all entries starting with '.' */
 
   return 0;
 }