]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't pass sync module to rest filter in creation
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 12 Apr 2017 23:45:55 +0000 (16:45 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 30 May 2017 20:26:54 +0000 (13:26 -0700)
sync module instance might change due to reconfiguration. Pass it into the
handler when executing op.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_sync_module_es.cc
src/rgw/rgw_sync_module_es_rest.cc
src/rgw/rgw_sync_module_es_rest.h

index 40459864c396ecc6edb75bc06c01c686d41ce94e..7c80a3177ee11631f4ca06aa2c8ff22113bb8d0c 100644 (file)
@@ -566,7 +566,7 @@ RGWRESTMgr *RGWElasticSyncModuleInstance::get_rest_filter(int dialect, RGWRESTMg
   if (dialect != RGW_REST_S3) {
     return orig;
   }
-  return new RGWRESTMgr_MDSearch_S3(this);
+  return new RGWRESTMgr_MDSearch_S3();
 }
 
 int RGWElasticSyncModule::create_instance(CephContext *cct, map<string, string, ltstr_nocase>& config, RGWSyncModuleInstanceRef *instance) {
index fec51040298ba5206de5577402bbe6ca4c0362b4..a7bc7f3b4ceec85ecabfcbead46e5c99c52f08ee 100644 (file)
@@ -111,6 +111,7 @@ struct es_search_response {
 };
 
 class RGWMetadataSearchOp : public RGWOp {
+  RGWSyncModuleInstanceRef sync_module_ref;
   RGWElasticSyncModuleInstance *es_module;
 protected:
   string expression;
@@ -126,7 +127,9 @@ protected:
   es_search_response response;
 
 public:
-  RGWMetadataSearchOp(RGWElasticSyncModuleInstance *_es_module) : es_module(_es_module) {}
+  RGWMetadataSearchOp(const RGWSyncModuleInstanceRef& sync_module) : sync_module_ref(sync_module) {
+    es_module = static_cast<RGWElasticSyncModuleInstance *>(sync_module_ref.get());
+  }
 
   int verify_permission() {
     return 0;
@@ -254,7 +257,7 @@ void RGWMetadataSearchOp::execute()
 
 class RGWMetadataSearch_ObjStore_S3 : public RGWMetadataSearchOp {
 public:
-  RGWMetadataSearch_ObjStore_S3(RGWElasticSyncModuleInstance *_es_module) : RGWMetadataSearchOp(_es_module) {
+  RGWMetadataSearch_ObjStore_S3(const RGWSyncModuleInstanceRef& _sync_module) : RGWMetadataSearchOp(_sync_module) {
     custom_prefix = "x-amz-meta-";
   }
 
@@ -346,11 +349,10 @@ public:
 };
 
 class RGWHandler_REST_MDSearch_S3 : public RGWHandler_REST_S3 {
-  RGWElasticSyncModuleInstance *es_module;
 protected:
   RGWOp *op_get() {
     if (s->info.args.exists("query")) {
-      return new RGWMetadataSearch_ObjStore_S3(es_module);
+      return new RGWMetadataSearch_ObjStore_S3(store->get_sync_module());
     }
     if (!s->init_state.url_bucket.empty() &&
         s->info.args.exists("mdsearch")) {
@@ -365,8 +367,7 @@ protected:
     return nullptr;
   }
 public:
-  RGWHandler_REST_MDSearch_S3(const rgw::auth::StrategyRegistry& auth_registry,
-                              RGWElasticSyncModuleInstance *_es_module) : RGWHandler_REST_S3(auth_registry), es_module(_es_module) {}
+  RGWHandler_REST_MDSearch_S3(const rgw::auth::StrategyRegistry& auth_registry) : RGWHandler_REST_S3(auth_registry) {}
   virtual ~RGWHandler_REST_MDSearch_S3() {}
 };
 
@@ -386,7 +387,7 @@ RGWHandler_REST* RGWRESTMgr_MDSearch_S3::get_handler(struct req_state* const s,
     return nullptr;
   }
 
-  RGWHandler_REST *handler = new RGWHandler_REST_MDSearch_S3(auth_registry, es_module);
+  RGWHandler_REST *handler = new RGWHandler_REST_MDSearch_S3(auth_registry);
 
   ldout(s->cct, 20) << __func__ << " handler=" << typeid(*handler).name()
                    << dendl;
index 7578b81273f05e11583832e5a2d79d98ffb3db80..4dd0698f23517dc48b759204ad1cf396f4b207ba 100644 (file)
@@ -6,9 +6,8 @@
 class RGWElasticSyncModuleInstance;
 
 class RGWRESTMgr_MDSearch_S3 : public RGWRESTMgr {
-  RGWElasticSyncModuleInstance *es_module;
 public:
-  explicit RGWRESTMgr_MDSearch_S3(RGWElasticSyncModuleInstance *_es_module) : es_module(_es_module) {}
+  explicit RGWRESTMgr_MDSearch_S3() {}
 
   RGWHandler_REST *get_handler(struct req_state* s,
                                const rgw::auth::StrategyRegistry& auth_registry,