]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: rework storage class zone config
authorYehuda Sadeh <yehuda@redhat.com>
Sat, 5 Jan 2019 00:59:09 +0000 (16:59 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Sat, 5 Jan 2019 00:59:09 +0000 (16:59 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc

index 9c9555bdcdfeecd305b18533b7f48b0933bd373b..ff3de8e45a278aa386ee2facb5a046c60ba5bde0 100644 (file)
@@ -4767,24 +4767,41 @@ int main(int argc, const char **argv)
        }
 
         if (opt_cmd == OPT_ZONE_PLACEMENT_ADD) {
-          // pool names are required
-          if (!index_pool || index_pool->empty() ||
-              !data_pool || data_pool->empty()) {
-            cerr << "ERROR: need to specify both --index-pool and --data-pool" << std::endl;
+          RGWZonePlacementInfo& info = zone.placement_pools[placement_id];
+
+         string opt_index_pool = index_pool.value_or(string());
+         string opt_data_pool = data_pool.value_or(string());
+
+         if (!opt_index_pool.empty()) {
+           info.index_pool = opt_index_pool;
+         }
+
+         if (info.index_pool.empty()) {
+            cerr << "ERROR: index pool not configured, need to specify --index-pool" << std::endl;
             return EINVAL;
-          }
+         }
 
-          RGWZonePlacementInfo& info = zone.placement_pools[placement_id];
+         if (opt_data_pool.empty()) {
+           const RGWZoneStorageClass *porig_sc{nullptr};
+           if (info.storage_classes.find(storage_class, &porig_sc)) {
+             if (porig_sc->data_pool) {
+               opt_data_pool = porig_sc->data_pool->to_str();
+             }
+           }
+           if (opt_data_pool.empty()) {
+             cerr << "ERROR: data pool not configured, need to specify --data-pool" << std::endl;
+             return EINVAL;
+           }
+         }
 
-          info.index_pool = *index_pool;
-          rgw_pool dp = data_pool.get();
+          rgw_pool dp = opt_data_pool;
           info.storage_classes.set_storage_class(storage_class, &dp, compression_type.get_ptr());
 
           if (data_extra_pool) {
             info.data_extra_pool = *data_extra_pool;
           }
           if (index_type_specified) {
-            info.index_type = placement_index_type;
+           info.index_type = placement_index_type;
           }
 
           ret = check_pool_support_omap(info.get_data_extra_pool());
index 5786c0f3e9b0afede7ac0cb926c32e38fcb9b18b..13a6549c48c234f355e9a65afd0b804e804ffc84 100644 (file)
@@ -4291,25 +4291,18 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
   boost::optional<RGWPutObj_Compress> compressor;
   CompressorRef plugin;
 
-  const auto& compression_type = svc.zone->get_zone_params().get_compression_type(
-      dest_bucket_info.placement_rule);
-  if (compression_type != "none") {
-    plugin = Compressor::create(cct, compression_type);
-    if (!plugin) {
-      ldout(cct, 1) << "Cannot load plugin for compression type "
-          << compression_type << dendl;
-    }
-  }
-
+  rgw_placement_rule dest_rule;
   RGWRadosPutObj cb(cct, plugin, compressor, &processor, progress_cb, progress_data,
                     [&](const map<string, bufferlist>& obj_attrs) {
                       if (!ptail_rule) {
                         auto iter = obj_attrs.find(RGW_ATTR_STORAGE_CLASS);
                         if (iter != obj_attrs.end()) {
-                          rgw_placement_rule dest_rule;
                           dest_rule.storage_class = iter->second.to_str();
                           dest_rule.inherit_from(dest_bucket_info.placement_rule);
                           processor.set_tail_placement(std::move(dest_rule));
+                          ptail_rule = &dest_rule;
+                        } else {
+                          ptail_rule = &dest_bucket_info.placement_rule;
                         }
                       }
 
@@ -4320,6 +4313,16 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
                       return 0;
                     });
 
+  const auto& compression_type = svc.zone->get_zone_params().get_compression_type(
+      *ptail_rule);
+  if (compression_type != "none") {
+    plugin = Compressor::create(cct, compression_type);
+    if (!plugin) {
+      ldout(cct, 1) << "Cannot load plugin for compression type "
+          << compression_type << dendl;
+    }
+  }
+
   string etag;
   real_time set_mtime;