]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: prevent creation of bucket with non-existent storage class
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 31 Oct 2018 20:22:48 +0000 (13:22 -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_zone.h
src/rgw/services/svc_zone.cc

index 22f638eecef960ff5a3c42401081f2b6585acf29..adee749d6574f216a03752cf3d4b5a0f3eb57643 100644 (file)
@@ -208,6 +208,11 @@ public:
     return true;
   }
 
+  bool exists(const string& sc) const {
+    auto iter = m.find(sc);
+    return (iter != m.end());
+  }
+
   const map<string, RGWZoneStorageClass>& get_all() const {
     return m;
   }
@@ -330,6 +335,10 @@ struct RGWZonePlacementInfo {
     return storage_class->compression_type.get_value_or(no_compression);
   }
 
+  bool storage_class_exists(const string& sc) const {
+    return storage_classes.exists(sc);
+  }
+
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
 
index aa3d745808442ce5ea12eab7d3e6500b35637268..d8368fb7c2f69c93471d1344dca594ff44e85b04 100644 (file)
@@ -1038,7 +1038,12 @@ int RGWSI_Zone::select_bucket_location_by_rule(const rgw_placement_rule& locatio
     return -EINVAL;
   }
 
-#warning FIXME check that location_rule.storage_class exists in piter->second
+  auto storage_class = location_rule.get_storage_class();
+  if (!piter->second.storage_class_exists(storage_class)) {
+    ldout(cct, 5) << "requested storage class does not exist: " << storage_class << dendl;
+    return -EINVAL;
+  }
+
 
   RGWZonePlacementInfo& placement_info = piter->second;