From: Chang Liu Date: Tue, 14 May 2019 14:11:40 +0000 (+0800) Subject: rgw: show bucket tagging when user stats bucket X-Git-Tag: v15.1.0~2575^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=371b683a9cf695928045d290eae28153d96a79e3;p=ceph-ci.git rgw: show bucket tagging when user stats bucket Signed-off-by: Chang Liu --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 7bb82ef7571..fce0d0b8e81 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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 stats; + map 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;