]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: pubsub: use effective conf
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 9 Jul 2018 22:20:03 +0000 (15:20 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 11 Dec 2018 08:10:42 +0000 (00:10 -0800)
the effective conf has the defaults set if needed

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_sync_module_pubsub.cc
src/rgw/rgw_sync_module_pubsub.h

index fde88f0dd3920ed86c9f25ad5d9b6b263de3b62f..f4c7d3f041d33ca16878585ae11a64d8b4b57fff 100644 (file)
@@ -53,6 +53,7 @@ extern "C" {
 #include "rgw_http_client_curl.h"
 #include "rgw_zone.h"
 #include "rgw_pubsub.h"
+#include "rgw_sync_module_pubsub.h"
 
 #include "services/svc_sync_modules.h"
 
@@ -7990,18 +7991,19 @@ next:
       return EINVAL;
     }
 
-    auto& tier_config = get_tier_config(store);
-
     rgw_pubsub_sub_dest dest_config;
     dest_config.bucket_name = sub_dest_bucket;
     dest_config.oid_prefix = sub_oid_prefix;
     dest_config.push_endpoint = sub_push_endpoint;
 
+    auto psmodule = static_cast<RGWPSSyncModuleInstance *>(store->get_sync_module().get());
+    auto conf = psmodule->get_effective_conf();
+
     if (dest_config.bucket_name.empty()) {
-      dest_config.bucket_name = string(tier_config["data_bucket_prefix"]) + user_info.user_id.to_str() + "-" + topic.topic.name;
+      dest_config.bucket_name = string(conf["data_bucket_prefix"]) + user_info.user_id.to_str() + "-" + topic.topic.name;
     }
     if (dest_config.oid_prefix.empty()) {
-      dest_config.oid_prefix = tier_config["data_oid_prefix"];
+      dest_config.oid_prefix = conf["data_oid_prefix"];
     }
     auto sub = ups.get_sub(sub_name);
     ret = sub->subscribe(topic_name, dest_config);
index 2d17ec2087664f88f17612f9a0560db5c3510d6f..d0c31ea28f57e9320571d936a5226fe9b4debb47 100644 (file)
@@ -1417,7 +1417,6 @@ int RGWRados::init_rados()
   return ret;
 }
 
-
 int RGWRados::register_to_service_map(const string& daemon_type, const map<string, string>& meta)
 {
   map<string,string> metadata = meta;
@@ -1458,19 +1457,20 @@ int RGWRados::init_complete()
 {
   int ret;
 
-  if (run_sync_thread) {
-    auto& zone_public_config = svc.zone->get_zone();
-    ret = svc.sync_modules->get_manager()->create_instance(cct, zone_public_config.tier_type, svc.zone->get_zone_params().tier_config, &sync_module);
-    if (ret < 0) {
-      lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl;
-      if (ret == -ENOENT) {
-        lderr(cct) << "ERROR: " << zone_public_config.tier_type 
-                   << " sync module does not exist. valid sync modules: " 
-                   << svc.sync_modules->get_manager()->get_registered_module_names()
-                   << dendl;
-      }
-      return ret;
+  /* 
+   * create sync module instance even if we don't run sync thread, might need it for radosgw-admin
+   */
+  auto& zone_public_config = svc.zone->get_zone();
+  ret = svc.sync_modules->get_manager()->create_instance(cct, zone_public_config.tier_type, svc.zone->get_zone_params().tier_config, &sync_module);
+  if (ret < 0) {
+    lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl;
+    if (ret == -ENOENT) {
+      lderr(cct) << "ERROR: " << zone_public_config.tier_type 
+        << " sync module does not exist. valid sync modules: " 
+        << svc.sync_modules->get_manager()->get_registered_module_names()
+        << dendl;
     }
+    return ret;
   }
 
   period_puller.reset(new RGWPeriodPuller(this));
index 24a7286271411d61566d202c11dd2fead307a129..61045a1d3af878a29e74794cd9e01e1501532e49 100644 (file)
@@ -1164,11 +1164,21 @@ public:
                             << " versioned=" << versioned << " versioned_epoch=" << versioned_epoch << dendl;
     return new RGWPSGenericObjEventCBCR(sync_env, env, bucket_info, key, mtime, DELETE_MARKER_CREATE);
   }
+
+  PSConfigRef& get_conf() { return conf; }
 };
 
 RGWPSSyncModuleInstance::RGWPSSyncModuleInstance(CephContext *cct, const JSONFormattable& config)
 {
   data_handler = std::unique_ptr<RGWPSDataSyncModule>(new RGWPSDataSyncModule(cct, config));
+  string jconf = json_str("conf", *data_handler->get_conf());
+  JSONParser p;
+  if (!p.parse(jconf.c_str(), jconf.size())) {
+    ldout(cct, 0) << "ERROR: failed to parse sync module effective conf: " << jconf << dendl;
+    effective_conf = config;
+  } else {
+    effective_conf.decode_json(&p);
+  }
 }
 
 RGWDataSyncModule *RGWPSSyncModuleInstance::get_data_handler()
index b12bf904583801d45bcccf4dc93f2d15666b5fb0..72259ba69c706bf0a0c875ddc0f202137188959a 100644 (file)
@@ -17,6 +17,7 @@ class RGWRESTConn;
 
 class RGWPSSyncModuleInstance : public RGWSyncModuleInstance {
   std::unique_ptr<RGWPSDataSyncModule> data_handler;
+  JSONFormattable effective_conf;
 public:
   RGWPSSyncModuleInstance(CephContext *cct, const JSONFormattable& config);
   RGWDataSyncModule *get_data_handler() override;
@@ -24,6 +25,9 @@ public:
   bool supports_user_writes() override {
     return true;
   }
+  const JSONFormattable& get_effective_conf() {
+    return effective_conf;
+  }
 };
 
 #endif