]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: make max number of bucket/object tags configurble
authorChang Liu <liuchang0812@gmail.com>
Wed, 8 May 2019 09:16:03 +0000 (17:16 +0800)
committerChang Liu <liuchang0812@gmail.com>
Tue, 4 Jun 2019 02:36:31 +0000 (10:36 +0800)
Signed-off-by: Chang Liu <liuchang0812@gmail.com>
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_tag.cc
src/rgw/rgw_tag.h

index 5855ec26116205a00361628881c468bd232b6083..dc9a7866b35d7be2e2f4b3f9bfd7bf06e04e21e5 100644 (file)
@@ -534,7 +534,7 @@ int RGWPutBucketTags_ObjStore_S3::get_params()
     return -ERR_MALFORMED_XML;
   }
 
-  RGWObjTags obj_tags;
+  RGWObjTags obj_tags(50); // A tag set can contain as many as 50 tags, or it can be empty.
   r = tagging.rebuild(obj_tags);
   if (r < 0)
     return r;
index f793c0ab8b1a752c526a8ab71f263bfd6607f194..6aa039ba9d8d1960d88da2d14882cde8aabf6041 100644 (file)
@@ -9,10 +9,6 @@
 
 #include "rgw_tag.h"
 
-static constexpr uint32_t MAX_OBJ_TAGS=10;
-static constexpr uint32_t MAX_TAG_KEY_SIZE=128;
-static constexpr uint32_t MAX_TAG_VAL_SIZE=256;
-
 bool RGWObjTags::add_tag(const string&key, const string& val){
   return tag_map.emplace(std::make_pair(key,val)).second;
 }
@@ -22,9 +18,9 @@ bool RGWObjTags::emplace_tag(std::string&& key, std::string&& val){
 }
 
 int RGWObjTags::check_and_add_tag(const string&key, const string& val){
-  if (tag_map.size() == MAX_OBJ_TAGS ||
-      key.size() > MAX_TAG_KEY_SIZE ||
-      val.size() > MAX_TAG_VAL_SIZE ||
+  if (tag_map.size() == max_obj_tags ||
+      key.size() > max_tag_key_size ||
+      val.size() > max_tag_val_size ||
       key.size() == 0){
     return -ERR_INVALID_TAG;
   }
index fe8bbc348593a0722c53ff5cf74e2514fe3cfa62..84ddd943befba2463b1091bc99297fa5a28414de 100644 (file)
@@ -15,9 +15,16 @@ class RGWObjTags
  protected:
   using tag_map_t = boost::container::flat_map <std::string, std::string>;
   tag_map_t tag_map;
+
+  uint32_t max_obj_tags{10};
+  uint32_t max_tag_key_size{128};
+  uint32_t max_tag_val_size{256};
+
  public:
-  RGWObjTags() {}
-  ~RGWObjTags() {}
+  RGWObjTags() = default;
+  RGWObjTags(uint32_t max_obj_tags):max_obj_tags(max_obj_tags) {}
+
+  virtual ~RGWObjTags() = default;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1,1,bl);