]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: show bucket tagging when user stats bucket
authorChang Liu <liuchang0812@gmail.com>
Tue, 14 May 2019 14:11:40 +0000 (22:11 +0800)
committerChang Liu <liuchang0812@gmail.com>
Tue, 4 Jun 2019 06:34:05 +0000 (14:34 +0800)
Signed-off-by: Chang Liu <liuchang0812@gmail.com>
src/rgw/rgw_bucket.cc

index 7bb82ef757129b273302e1eb46814018a9d2c8ca..fce0d0b8e8151a57eda4a49cd9b5ee5b7bc840fa 100644 (file)
@@ -17,6 +17,7 @@
 #include "rgw_zone.h"
 #include "rgw_acl.h"
 #include "rgw_acl_s3.h"
+#include "rgw_tag_s3.h"
 
 #include "include/types.h"
 #include "rgw_bucket.h"
@@ -1422,10 +1423,11 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st
 {
   RGWBucketInfo bucket_info;
   map<RGWObjCategory, RGWStorageStats> stats;
+  map<string, bufferlist> attrs;
 
   real_time mtime;
   auto obj_ctx = store->svc.sysobj->init_obj_ctx();
-  int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, &mtime, null_yield);
+  int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, &mtime, null_yield, &attrs);
   if (r < 0)
     return r;
 
@@ -1457,6 +1459,22 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st
   formatter->dump_string("max_marker", max_marker);
   dump_bucket_usage(stats, formatter);
   encode_json("bucket_quota", bucket_info.quota, formatter);
+
+  // bucket tags
+  auto iter = attrs.find(RGW_ATTR_TAGS);
+  if (iter != attrs.end()) {
+    RGWObjTagSet_S3 tagset;
+    bufferlist::const_iterator piter{&iter->second};
+    try {
+      tagset.decode(piter);
+      tagset.dump(formatter); 
+    } catch (buffer::error& err) {
+      cerr << "ERROR: caught buffer:error, couldn't decode TagSet" << std::endl;
+    }
+  }
+
+  // TODO: bucket CORS
+  // TODO: bucket LC
   formatter->close_section();
 
   return 0;