]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check that placement rule is valid if bucket exists
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 31 Oct 2018 22:16:28 +0000 (15:16 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Jan 2019 03:00:22 +0000 (19:00 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_zone.h

index 30282babbf23c06cc3a660e587508af74d79584b..fea79e9cecfdb1a007e0bb0eda7cb748b942bdfd 100644 (file)
@@ -660,6 +660,11 @@ int rgw_build_bucket_policies(RGWRados* store, struct req_state* s)
     if (s->bucket_exists) {
       s->dest_placement.storage_class = s->info.storage_class;
       s->dest_placement.inherit_from(s->bucket_info.placement_rule);
+
+      if (!store->svc.zone->get_zone_params().valid_placement(s->dest_placement)) {
+        ldpp_dout(s, 0) << "NOTICE: invalid dest placement: " << s->dest_placement.to_str() << dendl;
+        return -EINVAL;
+      }
     }
   }
 
index adee749d6574f216a03752cf3d4b5a0f3eb57643..6f1bd64378a87cd121133c6006e2652eac585c83 100644 (file)
@@ -209,6 +209,9 @@ public:
   }
 
   bool exists(const string& sc) const {
+    if (sc.empty()) {
+      return true;
+    }
     auto iter = m.find(sc);
     return (iter != m.end());
   }
@@ -521,6 +524,14 @@ struct RGWZoneParams : RGWSystemMetaObj {
     }
     return true;
   }
+
+  bool valid_placement(const rgw_placement_rule& rule) const {
+    auto iter = placement_pools.find(rule.name);
+    if (iter == placement_pools.end()) {
+      return false;
+    }
+    return iter->second.storage_class_exists(rule.storage_class);
+  }
 };
 WRITE_CLASS_ENCODER(RGWZoneParams)