]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: lifcycle: don't reject compound rules with empty prefix
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 10 Jan 2019 23:05:23 +0000 (18:05 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 15 Jan 2019 16:40:13 +0000 (11:40 -0500)
A rule containing a tag filter but no constraining prefix is
legal, as is a sequence of >1 such rules.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_lc.cc

index fe056655e2a3593f4017542c35373d1199602106..d4b558dbcf6321db1008d4872171e85724765629 100644 (file)
@@ -90,8 +90,14 @@ bool RGWLifecycleConfiguration::_add_rule(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 is optional, update prefix map only if prefix...exists */
+  if (!prefix.empty()) {
+    auto ret = prefix_map.emplace(std::move(prefix), std::move(op));
+    return ret.second;
+  }
+
+  return true;
 }
 
 int RGWLifecycleConfiguration::check_and_add_rule(LCRule *rule)