]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: lifecycle: alternate solution to prefix_map conflict
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 19 Feb 2019 18:29:03 +0000 (13:29 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 21 May 2019 06:59:38 +0000 (02:59 -0400)
A rule containing a tag filter but no constraining prefix is
legal, as is a sequence of >1 such rules.

As currently designed, enforcement requires rules to be
installed in prefix_map as well as rule_map, though only the
latter is encoded.

Fixes: http://tracker.ceph.com/issues/37879
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h

index bea92b2b18bd25f0629b0c5d65075ad26c5fd70e..36c75a4c06812fc7d56515861142a68f7b46c812 100644 (file)
@@ -127,8 +127,8 @@ bool RGWLifecycleConfiguration::_add_rule(const LCRule& rule)
   if (rule.get_filter().has_tags()){
     op.obj_tags = rule.get_filter().get_tags();
   }
-  auto ret = prefix_map.emplace(std::move(prefix), std::move(op));
-  return ret.second;
+  prefix_map.emplace(std::move(prefix), std::move(op));
+  return true;
 }
 
 int RGWLifecycleConfiguration::check_and_add_rule(const LCRule& rule)
@@ -334,7 +334,8 @@ static bool obj_has_expired(CephContext *cct, ceph::real_time mtime, int days, c
   return (timediff >= cmp);
 }
 
-int RGWLC::handle_multipart_expiration(RGWRados::Bucket *target, const map<string, lc_op>& prefix_map)
+int RGWLC::handle_multipart_expiration(
+  RGWRados::Bucket *target, const multimap<string, lc_op>& prefix_map)
 {
   MultipartMetaFilter mp_filter;
   vector<rgw_bucket_dir_entry> objs;
@@ -983,7 +984,12 @@ int RGWLC::bucket_lc_process(string& shard_id)
       return -1;
     }
 
-  map<string, lc_op>& prefix_map = config.get_prefix_map();
+  multimap<string, lc_op>& prefix_map = config.get_prefix_map();
+
+  ldpp_dout(this, 10) << __func__ <<  "() prefix_map size="
+                     << prefix_map.size()
+                     << dendl;
+
   rgw_obj_key pre_marker;
   rgw_obj_key next_marker;
   for(auto prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) {
index 3566f7c1ce96839154a059785b098768d0d21c83..4097ffcfdfae17e96edb881f1e48a72f69e38c14 100644 (file)
@@ -391,7 +391,7 @@ class RGWLifecycleConfiguration
 {
 protected:
   CephContext *cct;
-  map<string, lc_op> prefix_map;
+  multimap<string, lc_op> prefix_map;
   multimap<string, LCRule> rule_map;
   bool _add_rule(const LCRule& rule);
   bool has_same_action(const lc_op& first, const lc_op& second);
@@ -432,7 +432,7 @@ public:
   bool valid();
 
   multimap<string, LCRule>& get_rule_map() { return rule_map; }
-  map<string, lc_op>& get_prefix_map() { return prefix_map; }
+  multimap<string, lc_op>& get_prefix_map() { return prefix_map; }
 /*
   void create_default(string id, string name) {
     ACLGrant grant;
@@ -499,7 +499,8 @@ class RGWLC : public DoutPrefixProvider {
 
   private:
 
-  int handle_multipart_expiration(RGWRados::Bucket *target, const map<string, lc_op>& prefix_map);
+  int handle_multipart_expiration(RGWRados::Bucket *target,
+                                 const multimap<string, lc_op>& prefix_map);
 };
 
 namespace rgw::lc {